aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDrNuget <drnuget@outlook.com>2025-12-27 14:01:57 +0200
committerDrNuget <drnuget@outlook.com>2025-12-27 14:01:57 +0200
commit38f795d10bbd69c54cb7036946f4e941142e1482 (patch)
tree785a137ebedc3f655d6e40f37be43cfce04ea361 /src
parent080ff49649d3f3d0cfb599da79b2b3d490e28917 (diff)
downloadbrailleboi-dev.tar.gz
optimized the renderingdev
Diffstat (limited to 'src')
-rw-r--r--src/brailleboi.c20
-rw-r--r--src/brailleboi.h4
2 files changed, 8 insertions, 16 deletions
diff --git a/src/brailleboi.c b/src/brailleboi.c
index fce293a..b914e2d 100644
--- a/src/brailleboi.c
+++ b/src/brailleboi.c
@@ -34,16 +34,6 @@ int brailleReorganizeBits(int old)
return new;
}
-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
@@ -61,12 +51,14 @@ void brailleClearBuffer(image_buffer* buf)
void brailleUpdateScreen(image_buffer* buf)
{
wprintf(L"\033[2J");
- int len = (buf->char_width * buf->char_height);
+ int len = (buf->char_width * buf->char_height + 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++) {
- braillePrintCoords(frame, len, brailleReorganizeBits(buf->contents[y * buf->char_width + x]), x, y);
+ memset(frame, 0, len);
+ for (int y=0;y<buf->char_height;y++) {
+ for (int x=0;x<buf->char_width;x++) {
+ braillePrint(frame, len, brailleReorganizeBits(buf->contents[y * buf->char_width + x]));
}
+ swprintf(frame+wcslen(frame), len, L"\n");
}
wprintf(frame);
free(frame);
diff --git a/src/brailleboi.h b/src/brailleboi.h
index 26ada93..1d3e989 100644
--- a/src/brailleboi.h
+++ b/src/brailleboi.h
@@ -1,6 +1,8 @@
#ifndef BRAILLEBOI_H
#define BRAILLEBOI_H
+#define braillePrint(wcs, len, data) swprintf(wcs+wcslen(wcs), len, L"%lc", (0x2800|data))
+
typedef struct image_buffer {
int width, height;
int char_width, char_height;
@@ -13,8 +15,6 @@ int brailleStop(image_buffer* buf);
int brailleReorganizeBits(int old);
-void braillePrint(int data);
-
int braillePlot(int x, int y, image_buffer* buf);
void brailleClearBuffer(image_buffer* buf);