From 60e404006c8027025b29c29d1c10c153942e5ff3 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Thu, 11 Jul 2019 05:44:28 +0000 Subject: [PATCH] The cterm_screen no longer has separate arrays for foreground and background. Also, the vmem is an array of struct vmem_cell. --- src/conio/ciolib.c | 15 --------------- src/conio/ciolib.h | 20 +++++++++----------- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/src/conio/ciolib.c b/src/conio/ciolib.c index acca071189..b2ea72bf2c 100644 --- a/src/conio/ciolib.c +++ b/src/conio/ciolib.c @@ -1842,19 +1842,6 @@ CIOLIBEXPORT struct ciolib_screen * CIOLIBCALL ciolib_savescreen(void) free(ret); return NULL; } - ret->foreground = malloc(ret->text_info.screenwidth * ret->text_info.screenheight * sizeof(ret->foreground[0])); - if (ret->foreground == NULL) { - free(ret->vmem); - free(ret); - return NULL; - } - ret->background = malloc(ret->text_info.screenwidth * ret->text_info.screenheight * sizeof(ret->background[0])); - if (ret->background == NULL) { - free(ret->foreground); - free(ret->vmem); - free(ret); - return NULL; - } if (vmode != -1) { ret->pixels = ciolib_getpixels(0, 0, vparams[vmode].charwidth * vparams[vmode].cols - 1, vparams[vmode].charheight * vparams[vmode].rows - 1); @@ -1875,8 +1862,6 @@ CIOLIBEXPORT void CIOLIBCALL ciolib_freescreen(struct ciolib_screen *scrn) return; ciolib_freepixels(scrn->pixels); - FREE_AND_NULL(scrn->background); - FREE_AND_NULL(scrn->foreground); FREE_AND_NULL(scrn->vmem); free(scrn); } diff --git a/src/conio/ciolib.h b/src/conio/ciolib.h index c04120de0b..75de406875 100644 --- a/src/conio/ciolib.h +++ b/src/conio/ciolib.h @@ -258,26 +258,24 @@ struct ciolib_pixels { uint32_t height; }; +struct vmem_cell { + uint8_t legacy_attr; + uint8_t ch; + uint8_t font; + uint32_t fg; // RGB 00RRGGBB High bit indicates palette colour + uint32_t bg; // RGB 00RRGGBB High bit indicates palette colour +}; + struct ciolib_screen { uint32_t fg_colour; uint32_t bg_colour; int flags; int fonts[5]; struct ciolib_pixels *pixels; - void *vmem; - uint32_t *foreground; - uint32_t *background; + struct vmem_cell *vmem; struct text_info text_info; }; -struct vmem_cell { - uint8_t legacy_attr; - uint8_t ch; - uint8_t font; - uint32_t fg; // RGB 00RRGGBB High bit indicates palette colour - uint32_t bg; // RGB 00RRGGBB High bit indicates palette colour -}; - #define CONIO_FIRST_FREE_FONT 43 typedef struct { -- GitLab