changeset 2275:e27ab5f4bfe3

Fix off by one in oscilloscope rendering
author Michael Pavone <pavone@retrodev.com>
date Mon, 02 Jan 2023 11:36:16 -0800
parents bf1bb893f104
children 709036ee222a
files oscilloscope.c
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/oscilloscope.c	Thu Dec 29 22:44:35 2022 -0800
+++ b/oscilloscope.c	Mon Jan 02 11:36:16 2023 -0800
@@ -84,8 +84,8 @@
 			//TODO: at least linear filtering
 			int16_t sample = scope->channels[i].samples[(int)(cur_sample + 0.5f)];
 			int y = (float)sample * value_scale + 0.5f;
-			if (y > row_height / 2) {
-				y = row_height / 2;
+			if (y > row_height / 2 - 1) {
+				y = row_height / 2 - 1;
 			} else if (y < -(row_height / 2)) {
 				y = -(row_height / 2);
 			}
@@ -106,15 +106,15 @@
 				cur_sample -= scope->channels[i].period;
 			}
 		}
-	
+
 		offset += column_width;
 		if (offset >= width) {
 			offset = 0;
 			cur_line += pitch * row_height;
 		}
 	}
-	
-	
+
+
 	render_framebuffer_updated(scope->window, WIDTH);
 }