From 080ff49649d3f3d0cfb599da79b2b3d490e28917 Mon Sep 17 00:00:00 2001 From: DrNuget Date: Sun, 2 Nov 2025 15:54:22 +0200 Subject: attempt at optimising the drawing of frames, currently broken --- src/brailleboi.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/brailleboi.c b/src/brailleboi.c index d7f3e67..fce293a 100644 --- a/src/brailleboi.c +++ b/src/brailleboi.c @@ -39,6 +39,11 @@ void braillePrint(int data) wprintf(L"%lc", (0x2800|data)); } +void braillePrintCoords(wchar_t *wcs, int len, int data, int x, int y) +{ + swprintf(wcs, len, L"\033[%d;%dH%lc", x+1, y+1, (0x2800|data)); +} + int braillePlot(int x, int y, image_buffer* buf) { //Check if plot is within bounds @@ -56,10 +61,13 @@ void brailleClearBuffer(image_buffer* buf) void brailleUpdateScreen(image_buffer* buf) { wprintf(L"\033[2J"); + int len = (buf->char_width * buf->char_height); + wchar_t* frame = malloc(len * sizeof(wchar_t)); for (int x=0;xchar_width;x++) { for (int y=0;ychar_height;y++) { - wprintf(L"\033[%d;%dH", y+1, x+1); - braillePrint(brailleReorganizeBits(buf->contents[y * buf->char_width + x])); + braillePrintCoords(frame, len, brailleReorganizeBits(buf->contents[y * buf->char_width + x]), x, y); } } + wprintf(frame); + free(frame); } -- cgit v1.2.3