aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDrNuget <drnuget@outlook.com>2025-11-02 15:54:22 +0200
committerDrNuget <drnuget@outlook.com>2025-11-02 15:54:22 +0200
commit080ff49649d3f3d0cfb599da79b2b3d490e28917 (patch)
tree791881420acc76403f66fb981dc0c3022d5ef51e /src
parentda2c159e7f249091933659babaae9eb6fe8adc89 (diff)
downloadbrailleboi-080ff49649d3f3d0cfb599da79b2b3d490e28917.tar.gz
attempt at optimising the drawing of frames, currently brokendev
Diffstat (limited to 'src')
-rw-r--r--src/brailleboi.c12
1 files changed, 10 insertions, 2 deletions
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;x<buf->char_width;x++) {
for (int y=0;y<buf->char_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);
}