diff oscilloscope.c @ 2685:da2e06c42d16

Add a compile-time flag to use RGB565 instead of ABGR/ARGB
author Michael Pavone <pavone@retrodev.com>
date Sun, 30 Mar 2025 00:06:53 -0700
parents d30ea441b92e
children
line wrap: on
line diff
--- a/oscilloscope.c	Sat Mar 29 23:54:45 2025 -0700
+++ b/oscilloscope.c	Sun Mar 30 00:06:53 2025 -0700
@@ -56,15 +56,16 @@
 void scope_render(oscilloscope *scope)
 {
 	int pitch;
-	uint32_t *fb = render_get_framebuffer(scope->window, &pitch);
+	pixel_t *fb = render_get_framebuffer(scope->window, &pitch);
 	memset(fb, 0, HEIGHT * pitch);
-	pitch /= sizeof(uint32_t);
+	pitch /= sizeof(pixel_t);
 	int offset = 0;
 	int column_width = WIDTH/3;
 	int width = column_width * 3;
 	int row_height = HEIGHT / ((scope->num_channels + 2) / 3);
 	float value_scale = (float)row_height / 20000.0f;
-	uint32_t *cur_line = fb;
+	pixel_t *cur_line = fb;
+	pixel_t white = render_map_color(255, 255, 255);
 	for (uint8_t i = 0; i < scope->num_channels; i++)
 	{
 		float samples_per_pixel = (float)scope->channels[i].period / (float)(2*column_width);
@@ -96,13 +97,13 @@
 				int delta = last_y > y ? -1 : 1;
 				while (last_y != y)
 				{
-					cur_line[last_y * pitch + x ] = 0xFFFFFFFF;
+					cur_line[last_y * pitch + x ] = white;
 					last_y += delta;
 				}
 			} else {
 				last_y = y;
 			}
-			cur_line[y * pitch + x ] = 0xFFFFFFFF;
+			cur_line[y * pitch + x ] = white;
 			cur_sample += samples_per_pixel;
 			if (cur_sample + 0.5f >= scope->channels[i].period) {
 				cur_sample -= scope->channels[i].period;