From f9074149bb4947fce74339af2fed625b25f96364 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Mon, 9 Mar 2020 16:18:29 +0300 Subject: [PATCH] Size fixes, use define exept const, typdef index_t for indexes --- plot.c | 55 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/plot.c b/plot.c index 8aaef85..4e14ca7 100644 --- a/plot.c +++ b/plot.c @@ -40,9 +40,10 @@ uint8_t current_mappage = 0; // Trace data cache, for faster redraw cells // CELL_X[16:31] x position // CELL_Y[ 0:15] y position -static uint32_t trace_index[TRACES_MAX][POINTS_COUNT]; +typedef uint32_t index_t; +static index_t trace_index[TRACES_MAX][POINTS_COUNT]; -#define INDEX(x, y) ((((uint32_t)x)<<16)|(((uint32_t)y))) +#define INDEX(x, y) ((((index_t)x)<<16)|(((index_t)y))) #define CELL_X(i) (int)(((i)>>16)) #define CELL_Y(i) (int)(((i)&0xFFFF)) //#define CELL_P(i, x, y) (((((x)&0x03e0UL)<<22) | (((y)&0x03e0UL)<<17)) == ((i)&0xffc00000UL)) @@ -516,7 +517,7 @@ gamma2reactance(const float v[2]) return 2*v[1] * d; } -static uint32_t +static index_t trace_into_index(int t, int i, float array[POINTS_COUNT][2]) { int y, x; @@ -766,7 +767,7 @@ mark_map(int x, int y) markmap[current_mappage][y] |= 1<= 0; i--) { - uint32_t index = trace_index[uistat.current_trace][i]; + index_t index = trace_index[uistat.current_trace][i]; if ((*compare)(value, CELL_Y(index))) break; value = CELL_Y(index); } for (; i >= 0; i--) { - uint32_t index = trace_index[uistat.current_trace][i]; + index_t index = trace_index[uistat.current_trace][i]; if ((*compare)(CELL_Y(index), value)) { break; } @@ -1115,14 +1116,14 @@ marker_search_right(int from) int value = CELL_Y(trace_index[uistat.current_trace][from]); for (i = from + 1; i < POINTS_COUNT; i++) { - uint32_t index = trace_index[uistat.current_trace][i]; + index_t index = trace_index[uistat.current_trace][i]; if ((*compare)(value, CELL_Y(index))) break; value = CELL_Y(index); } for (; i < POINTS_COUNT; i++) { - uint32_t index = trace_index[uistat.current_trace][i]; + index_t index = trace_index[uistat.current_trace][i]; if ((*compare)(CELL_Y(index), value)) { break; } @@ -1135,7 +1136,7 @@ marker_search_right(int from) int search_nearest_index(int x, int y, int t) { - uint32_t *index = trace_index[t]; + index_t *index = trace_index[t]; int min_i = -1; int min_d = 1000; int i; @@ -1164,8 +1165,9 @@ plot_into_index(float measured[2][POINTS_COUNT][2]) if (!trace[t].enabled) continue; int ch = trace[t].channel; + index_t *index = trace_index[t]; for (i = 0; i < sweep_points; i++) - trace_index[t][i] = trace_into_index(t, i, measured[ch]); + index[i] = trace_into_index(t, i, measured[ch]); } #if 0 for (t = 0; t < TRACES_MAX; t++) @@ -1281,7 +1283,7 @@ draw_cell(int m, int n) i1 = sweep_points-1; else // draw rectangular plot (search index range in cell, save 50-70 system ticks for all screen calls) search_index_range_x(x0, x0+w, trace_index[t], &i0, &i1); - uint32_t *index = trace_index[t]; + index_t *index = trace_index[t]; for (i=i0; i < i1; i++) { int x1 = CELL_X(index[i ]) - x0; int y1 = CELL_Y(index[i ]) - y0; @@ -1303,7 +1305,7 @@ draw_cell(int m, int n) for (t = 0; t < TRACES_MAX; t++) { if (!trace[t].enabled) continue; - uint32_t index = trace_index[t][markers[i].index]; + index_t index = trace_index[t][markers[i].index]; int x = CELL_X(index) - x0 - X_MARKER_OFFSET; int y = CELL_Y(index) - y0 - Y_MARKER_OFFSET; // Check marker icon on cell @@ -1352,7 +1354,7 @@ draw_all_cells(bool flush_markmap){ // START_PROFILE for (m = 0; m < (area_width+CELLWIDTH-1) / CELLWIDTH; m++) for (n = 0; n < (area_height+CELLHEIGHT-1) / CELLHEIGHT; n++) { - if ((markmap[0][n]|markmap[1][n]) & (1<