From ce4c80f4da6472d7bc53ee3b3e04fb404562a30d Mon Sep 17 00:00:00 2001 From: Curtis McEnroe Date: Thu, 1 Feb 2018 00:14:58 -0500 Subject: Remove fb.c and color.c --- bin/color.c | 16 ----------- bin/fb.c | 89 ------------------------------------------------------------- 2 files changed, 105 deletions(-) delete mode 100644 bin/color.c delete mode 100644 bin/fb.c diff --git a/bin/color.c b/bin/color.c deleted file mode 100644 index 75118226..00000000 --- a/bin/color.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -static uint32_t color; - -void init() { -} - -void draw(uint32_t *buf, uint32_t xres, uint32_t yres) { - for (uint32_t i = 0; i < xres * yres; ++i) { - buf[i] = color; - } -} - -void input(char c) { - color = color << 4 | (c & 0xF); -} diff --git a/bin/fb.c b/bin/fb.c deleted file mode 100644 index fdc14ef5..00000000 --- a/bin/fb.c +++ /dev/null @@ -1,89 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern void init(int argc, char *argv[]); -extern void draw(uint32_t *buf, uint32_t xres, uint32_t yres); -extern void input(char in); - -static size_t bufLen; -static uint32_t *buf; -static uint32_t *saveBuf; - -static struct termios saveTerm; - -static void restoreBuf(void) { - memcpy(buf, saveBuf, bufLen); -} - -static void restoreTerm(void) { - tcsetattr(STDERR_FILENO, TCSADRAIN, &saveTerm); -} - -int main(int argc, char *argv[]) { - int error; - - char *path = getenv("FRAMEBUFFER"); - if (!path) path = "/dev/fb0"; - - int fd = open(path, O_RDWR); - if (fd < 0) err(EX_OSFILE, "%s", path); - - struct fb_fix_screeninfo fixInfo; - error = ioctl(fd, FBIOGET_FSCREENINFO, &fixInfo); - if (error) err(EX_IOERR, "%s", path); - - struct fb_var_screeninfo varInfo; - error = ioctl(fd, FBIOGET_VSCREENINFO, &varInfo); - if (error) err(EX_IOERR, "%s", path); - - assert(!varInfo.xoffset); - assert(!varInfo.yoffset); - assert(varInfo.bits_per_pixel == 32); - assert(!varInfo.grayscale); - assert(varInfo.red.offset == 16); - assert(varInfo.green.offset == 8); - assert(varInfo.blue.offset == 0); - assert(fixInfo.line_length == varInfo.xres * 4); - - bufLen = varInfo.xres * varInfo.yres * 4; - buf = mmap(NULL, bufLen, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); - if (buf == MAP_FAILED) err(EX_IOERR, "%s", path); - - saveBuf = malloc(bufLen); - if (!saveBuf) err(EX_OSERR, "malloc(%zu)", bufLen); - memcpy(saveBuf, buf, bufLen); - atexit(restoreBuf); - - error = tcgetattr(STDERR_FILENO, &saveTerm); - if (error) err(EX_IOERR, "tcgetattr"); - atexit(restoreTerm); - - struct termios raw; - cfmakeraw(&raw); - error = tcsetattr(STDERR_FILENO, TCSADRAIN, &raw); - if (error) err(EX_IOERR, "tcsetattr"); - - init(argc, argv); - - for(;;) { - draw(buf, varInfo.xres, varInfo.yres); - - char in; - ssize_t len = read(STDIN_FILENO, &in, 1); - if (len < 0) err(EX_IOERR, "read"); - if (!len) return EX_DATAERR; - if (in == CTRL('C')) return EX_USAGE; - - input(in); - } -} -- cgit 1.4.1