diff --git a/CMakeLists.txt b/CMakeLists.txt index 36a086a..570119f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,7 +23,6 @@ set(SOURCES set(ASSETS assets/background.png - assets/bar3.png assets/icons.png ) diff --git a/include/bar.h b/include/bar.h index 755d51d..9403a83 100644 --- a/include/bar.h +++ b/include/bar.h @@ -1,7 +1,6 @@ #pragma once #include -extern bopti_image_t bimg_bar3; extern bopti_image_t bimg_icons; #define BAR_WIDTH 16 @@ -17,7 +16,6 @@ struct Bar { int x; int y; int height; - int limit_height; float fill; }; @@ -25,7 +23,6 @@ struct Bar { enum BarID { BAR_CASH, BAR_HUMAN, BAR_SMILE, BAR_SUN }; struct Bar bar_init(enum BarID bar_id); -void bar_deinit(void); void bar_update(struct Bar *bar); void bar_draw(struct Bar bar); /* Increase/decrease bar fill level. diff --git a/src/bar/draw.c b/src/bar/draw.c index 762a8d8..b6d4d84 100644 --- a/src/bar/draw.c +++ b/src/bar/draw.c @@ -8,22 +8,15 @@ bar_draw(struct Bar bar) { const int height = bar.fill * (float)bar.height; const int low_y = bar.y + bar.height; - const int high_y = bar.y - bar.limit_height + bar.height - height; - int i; + const int high_y = bar.y + bar.height - height; + + /* draw borders */ + drect_border(bar.x, bar.y - 1, bar.x + BAR_WIDTH - 1, low_y + 1, + C_WHITE, 1, C_BLACK); - /* borders */ - drect(bar.x, bar.y - bar.limit_height, bar.x + BAR_WIDTH - 1, - low_y + bar.limit_height - 1, C_BLACK); - /* draw lower limit */ - dsubimage(bar.x, low_y, vimg_bar3, 0, bar.limit_height + 1, - vimg_bar3->width, bar.limit_height, DIMAGE_NOCLIP); - /* draw higher limit */ - dsubimage(bar.x, high_y, vimg_bar3, 0, 0, vimg_bar3->width, - bar.limit_height, DIMAGE_NOCLIP); /* draw fill */ - for (i = high_y + bar.limit_height; i < low_y; i += 1) - dsubimage(bar.x, i, vimg_bar3, 0, bar.limit_height, - vimg_bar3->width, 1, DIMAGE_NOCLIP); + drect(bar.x + 1, high_y, bar.x + BAR_WIDTH - 2, low_y, C_RGB(31, 8, 5)); + /* draw icons */ dsubimage(bar.x + (BAR_WIDTH - BAR_ICON_WIDTH) / 2, BAR_ICON_Y, &bimg_icons, BAR_ICON_WIDTH * bar.id, 0, BAR_ICON_WIDTH, diff --git a/src/bar/init.c b/src/bar/init.c index 7827cde..c06e4c1 100644 --- a/src/bar/init.c +++ b/src/bar/init.c @@ -3,22 +3,11 @@ #include #include -bopti_image_t *vimg_bar3; -color_t *vcol_bar3; /* was black */ - -static void init_vimg_bar3(void); - struct Bar bar_init(enum BarID bar_id) { - static int init_image = 1; int x = 0; - if (init_image) { - init_image = 0; - init_vimg_bar3(); - } - switch (bar_id) { case BAR_CASH: x = BAR_WIDTH; @@ -41,38 +30,6 @@ bar_init(enum BarID bar_id) .x = x, .y = BAR_Y, .height = BAR_HEIGHT, - .limit_height = bimg_bar3.height / 2, .fill = BAR_BASE_FILL, }; } - -void -bar_deinit(void) -{ - free(vimg_bar3); -} - -void -init_vimg_bar3(void) -{ - int i; - color_t *palette; - - const int sizeof_bimg_bar_3 = - sizeof(bimg_bar3) + 16 * sizeof(color_t) + /* palette */ - (bimg_bar3.width + 1) / 2 * bimg_bar3.height; /* data */ - - /* allocate memory! */ - vimg_bar3 = malloc(sizeof_bimg_bar_3); - - /* copy original image to allocated area */ - memcpy(vimg_bar3, &bimg_bar3, sizeof_bimg_bar_3); - - /* find black color in palette */ - palette = vimg_bar3->data; - i = -1; - while (++i < 16) - if (palette[i] == C_BLACK) - break; - vcol_bar3 = &palette[i]; -} diff --git a/src/main.c b/src/main.c index 63ae41a..8b6ebe9 100644 --- a/src/main.c +++ b/src/main.c @@ -35,7 +35,6 @@ main(void) /* deinit */ usb_close(); - bar_deinit(); return 1; }