summaryrefslogtreecommitdiff
path: root/engine.c
diff options
context:
space:
mode:
authorerdgeist <erdgeist@bauklotz.fritz.box>2018-04-16 19:10:21 +0200
committererdgeist <erdgeist@bauklotz.fritz.box>2018-04-16 19:10:21 +0200
commite2fde68c4f27fccbfa2d430e1fd795bf459cb615 (patch)
treeaca1a773d81911685ce556594e4536ebd0f1364c /engine.c
parent800008e018fe6160f7e88d939904c41d185fa9c1 (diff)
Move normalization math back to the function it belongsHEADmaster
Diffstat (limited to 'engine.c')
-rw-r--r--engine.c18
1 files changed, 7 insertions, 11 deletions
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);
23static int64_t 23static int64_t
24engine_normalize(int height, int y) 24engine_normalize(int height, int y)
25{ 25{
26 /*
27 double xf = ((double)x) / 100.0f;
28 double yf = g_normalize_factor * (xf*xf-xf) + xf;
29 y = ax^2 + x - ax = a * (x^2 - x) + x
30 int y = scale(g_min_y + (int)(((double)height) * yf));
31 */
32
26 int64_t yf = (y << 16) / height; 33 int64_t yf = (y << 16) / height;
27 yf = (((yf * yf - (yf << 16)) * ((int64_t)g_normalize_factor))) + (yf << 32); 34 yf = (((yf * yf - (yf << 16)) * ((int64_t)g_normalize_factor))) + (yf << 32);
28 return (((int64_t)height) * yf) >> 32; 35 return (((int64_t)height) * yf) >> 32;
@@ -58,17 +65,6 @@ engine_redraw()
58 65
59 for (int x=0; x<height; x+=20) { 66 for (int x=0; x<height; x+=20) {
60 int y = engine_normalize(height, x); 67 int y = engine_normalize(height, x);
61 /*
62 int64_t xf = (x << 16) / 100;
63 int64_t yf = (((xf * xf - (xf << 16)) * ((int64_t)g_normalize_factor))) + (xf << 32);
64 int64_t yo = (((int64_t)height) * yf) >> 48;
65
66 double xf = ((double)x) / 100.0f;
67 double yf = g_normalize_factor * (xf*xf-xf) + xf;
68 y = ax^2 + x - ax = a * (x^2 - x) + x
69 int y = scale(g_min_y + (int)(((double)height) * yf));
70 */
71
72 display_line_color(0, scale(g_min_y + (y>>16)), MAX_X, scale(g_min_y + (y>>16)), 0x1f1f1f1f); 68 display_line_color(0, scale(g_min_y + (y>>16)), MAX_X, scale(g_min_y + (y>>16)), 0x1f1f1f1f);
73 if (y >> 16 > (tos2 * height) / 100 ) 69 if (y >> 16 > (tos2 * height) / 100 )
74 t1++; 70 t1++;