From e2fde68c4f27fccbfa2d430e1fd795bf459cb615 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 16 Apr 2018 19:10:21 +0200 Subject: Move normalization math back to the function it belongs --- engine.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'engine.c') diff --git a/engine.c b/engine.c index 5188fbd..ada3756 100644 --- a/engine.c +++ b/engine.c @@ -23,6 +23,13 @@ static void highlight_line(int value, int y, int max_x, uint32_t color); static int64_t engine_normalize(int height, int y) { + /* + double xf = ((double)x) / 100.0f; + double yf = g_normalize_factor * (xf*xf-xf) + xf; + y = ax^2 + x - ax = a * (x^2 - x) + x + int y = scale(g_min_y + (int)(((double)height) * yf)); + */ + int64_t yf = (y << 16) / height; yf = (((yf * yf - (yf << 16)) * ((int64_t)g_normalize_factor))) + (yf << 32); return (((int64_t)height) * yf) >> 32; @@ -58,17 +65,6 @@ engine_redraw() for (int x=0; x> 48; - - double xf = ((double)x) / 100.0f; - double yf = g_normalize_factor * (xf*xf-xf) + xf; - y = ax^2 + x - ax = a * (x^2 - x) + x - int y = scale(g_min_y + (int)(((double)height) * yf)); - */ - display_line_color(0, scale(g_min_y + (y>>16)), MAX_X, scale(g_min_y + (y>>16)), 0x1f1f1f1f); if (y >> 16 > (tos2 * height) / 100 ) t1++; -- cgit v1.2.3