]> Chaos Git - corbenik/corbenik.git/commitdiff
Background support. These should be 90 degree rotated RGB8 pixel data.
authorchaoskagami <chaos.kagami@gmail.com>
Sat, 25 Jun 2016 21:30:40 +0000 (17:30 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sat, 25 Jun 2016 21:30:40 +0000 (17:30 -0400)
They go at the locations:
  /corbenik/bits/top.bin
  /corbenik/bits/bottom.bin

source/main.c
source/screeninit.c
source/std/draw.c
source/std/draw.h

index 9788ded515cf44afc027bf4300bfa732a337a762..34de34be14183000c4959b2cf96785f3b4a9c1b2 100644 (file)
@@ -20,6 +20,10 @@ main(int argc, char** argv)
 
     int c = fmount();
     screen_init();
+    clear_bg();
+    load_bg_top(PATH_BITS "/top.bin");
+    load_bg_bottom(PATH_BITS "/bottom.bin"); // This is basically a menuhax splash (90deg rotated RGB8 pixel data)
+    clear_screens();
 
     set_font(PATH_BITS "/termfont.bin");
 
index 2dfc0d133352a004c488c5d375d7312593ed7831..81cc4c8f937a76d2c40d69d1c39e69e7ca65ad81 100644 (file)
@@ -26,7 +26,4 @@ screen_init()
         // Turn on backlight
         i2cWriteRegister(I2C_DEV_MCU, 0x22, 0x2A);
     }
-
-    // Flush garbage off the FB.
-    clear_screens();
 }
index fb4c930d6fb99d88b4d887c60de05d1a5893b93f..49327a0b5b42a17c3999b32238c9326d46e58f7f 100644 (file)
@@ -27,6 +27,32 @@ static unsigned int text_top_height = 10;
 static unsigned int text_bottom_width = 20;
 static unsigned int text_bottom_height = 10;
 
+uint8_t top_bg[TOP_SIZE];
+uint8_t bottom_bg[BOTTOM_SIZE];
+
+void clear_bg() {
+    memset(top_bg, 0, TOP_SIZE);
+    memset(bottom_bg, 0, BOTTOM_SIZE);
+}
+
+void load_bg_top(char* fname_top) {
+    FILE* f = fopen(fname_top, "r");
+    if (!f) return;
+
+    fread(top_bg, 1, TOP_SIZE, f);
+
+    fclose(f);
+}
+
+void load_bg_bottom(char* fname_bottom) {
+    FILE* f = fopen(fname_bottom, "r");
+    if (!f)
+        return;
+
+    fread(bottom_bg, 1, BOTTOM_SIZE, f);
+    fclose(f);
+}
+
 void set_font(const char* filename) {
     // TODO - Unicode support. Right now, we only load 32
 
@@ -107,15 +133,16 @@ clear_disp(uint8_t *screen)
         screen = framebuffers->bottom;
 
     if (screen == framebuffers->top_left || screen == framebuffers->top_right) {
-        memset(screen, 0, TOP_SIZE);
+        memcpy(screen, top_bg, TOP_SIZE);
     } else if (screen == framebuffers->bottom) {
-        memset(screen, 0, BOTTOM_SIZE);
+        memcpy(screen, bottom_bg, BOTTOM_SIZE);
     }
 }
 
 void
 clear_screen(uint8_t *screen)
 {
+    // TODO - remove. This is a stub now.
     clear_disp(screen);
 }
 
@@ -146,12 +173,15 @@ draw_character(uint8_t *screen, const uint32_t character, int ch_x, int ch_y, co
 
     _UNUSED int width = 0;
     int height = 0;
+    uint8_t* buffer_bg;
     if (screen == framebuffers->top_left || screen == framebuffers->top_right) {
         width = TOP_WIDTH;
         height = TOP_HEIGHT;
+        buffer_bg = top_bg;
     } else if (screen == framebuffers->bottom) {
         width = BOTTOM_WIDTH;
         height = BOTTOM_HEIGHT;
+        buffer_bg = bottom_bg;
     } else {
         return; // Invalid buffer.
     }
@@ -170,14 +200,26 @@ draw_character(uint8_t *screen, const uint32_t character, int ch_x, int ch_y, co
                unsigned int pos = xDisplacement + yDisplacement;
         unsigned char char_dat = ((char*)FCRAM_FONT_LOC)[(character - ' ') * (c_font_w * font_h) + yy];
         for(unsigned int i=0; i < font_w + font_kern; i++) {
-            screen[pos]     = color_bg >> 16;
-            screen[pos + 1] = color_bg >> 8;
-            screen[pos + 2] = color_bg;
+            if (color_bg == 0) {
+                screen[pos]     = buffer_bg[pos];
+                screen[pos + 1] = buffer_bg[pos + 1];
+                screen[pos + 2] = buffer_bg[pos + 2];
+            } else {
+                screen[pos]     = color_bg >> 16;
+                screen[pos + 1] = color_bg >> 8;
+                screen[pos + 2] = color_bg;
+            }
 
                        if (char_dat & 0x80) {
-                screen[pos]     = color_fg >> 16;
-                screen[pos + 1] = color_fg >> 8;
-                screen[pos + 2] = color_fg;
+                if (color_fg == 0) {
+                    screen[pos]     = buffer_bg[pos];
+                    screen[pos + 1] = buffer_bg[pos + 1];
+                    screen[pos + 2] = buffer_bg[pos + 2];
+                } else {
+                    screen[pos]     = color_fg >> 16;
+                    screen[pos + 1] = color_fg >> 8;
+                    screen[pos + 2] = color_fg;
+                }
                        }
 
             char_dat <<= 1;
index a066ff908d2d8c4d09e4b7e4f8be6e5394631479..40d9ea7b747cf691dbe4ed4bd7337e313cabf323 100644 (file)
@@ -37,6 +37,10 @@ _UNUSED static struct framebuffers
 #define TOP_FB framebuffers->top_left
 #define BOTTOM_FB framebuffers->bottom
 
+void clear_bg();
+void load_bg_top(char* fname_top);
+void load_bg_bottom(char* fname_bottom);
+
 void clear_screen(uint8_t *screen);
 void clear_screens();
 void draw_character(uint8_t *screen, const uint32_t character, int ch_x, int ch_y, const uint32_t color_fg, const uint32_t color_bg);