From 14bea573767bfe37d536929c16dedceb06bbd5cf Mon Sep 17 00:00:00 2001 From: DrNuget Date: Wed, 29 Oct 2025 19:56:06 +0200 Subject: add braille character printing, change c standard to c23 and pedantic compiler warnings --- Makefile | 2 +- brailleboi.c | 19 +++++++++++++++++++ brailleboi.h | 8 ++++++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ba61ab3..d52f23b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc -CFLAGS = -std=c99 +CFLAGS = -std=c23 -Wpedantic SRC = main.c brailleboi.c brailleboi.h diff --git a/brailleboi.c b/brailleboi.c index a892dfa..e04d17c 100644 --- a/brailleboi.c +++ b/brailleboi.c @@ -1,15 +1,34 @@ #include +#include +#include +#include #include "brailleboi.h" int brailleInit(int width, int height, image_buffer* buf) { + setlocale(LC_ALL, ""); buf->contents = malloc((width * height) * sizeof(int)); buf->width = width; buf->height = height; + return 0; } int brailleStop(image_buffer* buf) { free(buf->contents); + return 0; +} + +int brailleReorganizeBits(int old) +{ + int new = (old&0b10000111) | + (old&0b01110000)>>1 | + (old&0b00001000)<<3; + return new; +} + +void braillePrint(int data) +{ + wprintf(L"%lc", (0x2800|data)); } diff --git a/brailleboi.h b/brailleboi.h index 87d3e35..f909181 100644 --- a/brailleboi.h +++ b/brailleboi.h @@ -6,8 +6,12 @@ typedef struct image_buffer { int* contents; } image_buffer; -int brailleInit(int, int, image_buffer*); +int brailleInit(int width, int height, image_buffer* buf); -int brailleStop(image_buffer*); +int brailleStop(image_buffer* buf); + +int brailleReorganizeBits(int old); + +void braillePrint(int data); #endif -- cgit v1.2.3