Commits

Trammell Hudson  committed 2a4eacf Draft

Store angle and try to optimize it

  • Participants
  • Parent commits 8d1f823

Comments (0)

Files changed (3)

File textconsole.c

 	{ "Incept date" },
 	{ "1945-05-27" },
 /*
+	{ "012345678901234" },
 	{ "0123456789-=" },
 	{ "~!@#$%^&*\\|_" },
 	{ "+`[]{}()<>/?" },
 };
 
 static vector_rot_t rot = {
-	.scale = 100,
+	.scale = 64,
 	.cx = 128,
-	.cy = 148,
+	.cy = 128,
 };
 
 
 {
 	const uint8_t height = 24;
 
-	int8_t y = 128 - 24;
+	uint8_t y = 256 - height;
 	for (uint8_t row = 0 ; row < MAX_ROWS ; row++)
 	{
-		int8_t x = -128;
+		uint8_t x = 0;
 		for (uint8_t col = 0 ; col < MAX_COLS ; col++)
 		{
-			draw_char_rot(&rot, x, y, text[row][col]);
-			x += 20;
+			draw_char_small(x, y, text[row][col]);
+			x += 16;
 		}
 
 		y -= height;
 	while (!usb_configured()) /* wait */ ;
 	_delay_ms(1000);
 
-	// wait for the user to run their terminal emulator program
-	// which sets DTR to indicate it is ready to receive.
-	while (!(usb_serial_get_control() & USB_SERIAL_DTR))
-		continue;
-
-	// discard anything that was received prior.  Sometimes the
-	// operating system or other software will send a modem
-	// "AT command", which can still be buffered.
-	usb_serial_flush_input();
-
 	DDRB = 0xFF;
 	DDRD = 0xFF;
 	PORTB = 128;
 	uint16_t theta = 0;
 	uint8_t size = 0;
 
-	while (1)
+
+	// wait for the user to run their terminal emulator program
+	// which sets DTR to indicate it is ready to receive.
+	while (!(usb_serial_get_control() & USB_SERIAL_DTR))
 	{
-		vector_rot_init(&rot, (theta++) >> 1);
+		vector_rot_init(&rot, (theta++) / 4);
+
 		if (size >= 128)
 			rot.scale = (32+64) - (size - 128)/2;
 		else
 		line(254, 0, 254, 254);
 		line(254, 254, 0, 254);
 		line(0, 254, 0, 0);
+	}
 
-		//draw_text();
+
+	// discard anything that was received prior.  Sometimes the
+	// operating system or other software will send a modem
+	// "AT command", which can still be buffered.
+	usb_serial_flush_input();
+
+	// No rotation for the text
+	vector_rot_init(&rot, 0);
+	rot.scale = 48;
+
+	while (1)
+	{
+		if (rot.scale < 48)
+			rot.scale = (size++) / 2;
+
+		draw_text();
 		int c = usb_serial_getchar();
 		if (c == -1)
 			continue;
 		if (c == '\f')
 		{
 			col = 0;
+			rot.scale = 0;
+			size = 0;
 			memset(text, '\0', sizeof(text));
 			continue;
 		}
 
 #ifdef CONFIG_SLOW_SCOPE
 	// Allow the scope to reach this point
-	_delay_us((first_dx + first_dy) / 2);
+	_delay_us((first_dx + first_dy) / 3);
 #endif
 }
 
 	uint8_t theta
 )
 {
+	r->theta = theta;
 	r->sin_t = sin_lookup(theta);
 	r->cos_t = cos_lookup(theta);
 }
 )
 {
 	int32_t x2 = x;
-	int32_t y2 = y;
+	int32_t w;
+	if (r->theta != 0)
+	{
+		int32_t y2 = y;
 
-	int32_t w = (r->scale * (x2 * r->cos_t + y2 * r->sin_t)) / (32 * 256);
+		w = (r->scale * (x2 * r->cos_t + y2 * r->sin_t)) / (32 * 256);
+	} else {
+		w = (r->scale * x2) / 64;
+	}
 	
 	return w + r->cx;
 }
 {
 	int32_t x2 = x;
 	int32_t y2 = y;
-	int32_t z = (r->scale * (y2 * r->cos_t - x2 * r->sin_t)) / (32 * 256);
+	int32_t z;
+
+	if (r->theta != 0)
+		z = (r->scale * (y2 * r->cos_t - x2 * r->sin_t)) / (32 * 256);
+	else
+		z = (r->scale * y2) / 64;
+
 	return z + r->cy;
 }
 	
 	// scale of vector, divided by 16
 	int8_t scale;
 
+	// Angle from 0 to 255 (== 2 Pi)
+	uint8_t theta;
+
 	// precomputed sin/cos
 	int8_t sin_t;
 	int8_t cos_t;