extern unsigned int font_h;
void show_help(char* help) {
- clear_screen(TOP_SCREEN);
+ clear_disp(TOP_SCREEN);
set_cursor(TOP_SCREEN, 0, 0);
header("Any:Back");
fprintf(stdout, "%s", help);
int window_top = 0, window_bottom = window_size;
int less_mode = 0;
- clear_screen(TOP_SCREEN);
+ clear_disp(TOP_SCREEN);
if (options[0].index == -1) {
set_cursor(TOP_SCREEN, 0, 0);
((func_call_t)(options[cursor_y].a))(options[cursor_y].b); // Call 'a' as a function.
} else if (options[cursor_y].allowed == break_menu) {
exit = 1;
- clear_screen(TOP_SCREEN);
+ clear_disp(TOP_SCREEN);
cursor_y = cursor_min;
}
break;
break;
case BUTTON_B:
exit = 1;
- clear_screen(TOP_SCREEN);
+ clear_disp(TOP_SCREEN);
cursor_y = cursor_min;
break;
case BUTTON_SEL:
if (options[cursor_y].desc[0] != 0) {
show_help(options[cursor_y].desc);
- clear_screen(TOP_SCREEN);
+ clear_disp(TOP_SCREEN);
}
break;
}
if (cursor_y < window_top + cursor_min) {
window_top = cursor_y - cursor_min;
window_bottom = window_top + window_size;
- clear_screen(TOP_SCREEN);
+ clear_disp(TOP_SCREEN);
} else if (cursor_y > window_bottom - cursor_min) {
window_bottom = cursor_y + cursor_min;
window_top = window_bottom - window_size;
- clear_screen(TOP_SCREEN);
+ clear_disp(TOP_SCREEN);
}
}
{ OPTION_AUTOBOOT, "Autoboot", "Boot the system automatically, unless the R key is held while booting.", boolean_val, 0, 0 },
{ OPTION_SILENCE, " Silent mode", "Suppress all debug output during autoboot. You'll see the screen turn on and then off once.", boolean_val, 0, 0 },
+ { OPTION_DIM_MODE, "Dim Background", "Experimental! Dims colors on lighter backgrounds to improve readability with text. You won't notice the change until scrolling or exiting the current menu due to the way rendering works.", boolean_val, 0, 0 },
// space
{ 0, "", "", not_option, 0, 0 },
unsigned char color_bottom = 0xf0;
int kill_output = 0;
+#define TRANSP_THRESH 178
+
void std_init() {
top_bg = static_allocate(TOP_SIZE);
bottom_bg = static_allocate(BOTTOM_SIZE);
// See load_bg_bottom for an explanation on the magic value.
dim_factor_top = 0;
- if (max > 178)
- dim_factor_top = max - 178;
+ if (max > TRANSP_THRESH)
+ dim_factor_top = max - TRANSP_THRESH;
}
void load_bg_bottom(char* fname_bottom) {
// 70% of 255 is approximately 178, and 255 - 178 is 77. That's therefore the maximum we want to subtract.
// Thus this is the value for 70% transparency.
dim_factor_bottom = 0;
- if (max > 178)
- dim_factor_bottom = max - 178;
+ if (max > TRANSP_THRESH)
+ dim_factor_bottom = max - TRANSP_THRESH;
}
void set_font(const char* filename) {
screen = framebuffers->bottom;
if (screen == framebuffers->top_left || screen == framebuffers->top_right) {
- memcpy(screen, top_bg, TOP_SIZE);
+ if (kill_output || !config.options[OPTION_DIM_MODE]) {
+ memcpy(screen, top_bg, TOP_SIZE);
+ } else {
+ for(int i=0; i < TOP_SIZE; i++) {
+ screen[i] = 0;
+ if (top_bg[i] > dim_factor_top)
+ screen[i] = top_bg[i] - dim_factor_top;
+ }
+ }
+ top_cursor_x = 0;
+ top_cursor_y = 0;
} else if (screen == framebuffers->bottom) {
- memcpy(screen, bottom_bg, BOTTOM_SIZE);
+ if (kill_output || !config.options[OPTION_DIM_MODE]) {
+ memcpy(screen, bottom_bg, BOTTOM_SIZE);
+ } else {
+ for(int i=0; i < BOTTOM_SIZE; i++) {
+ screen[i] = 0;
+ if (bottom_bg[i] >= dim_factor_bottom)
+ screen[i] = bottom_bg[i] - dim_factor_bottom;
+ }
+ }
+ bottom_cursor_x = 0;
+ bottom_cursor_y = 0;
}
}
-void
-clear_screen(uint8_t *screen)
-{
- // TODO - remove. This is a stub now.
- clear_disp(screen);
-}
-
void
set_cursor(void *channel, unsigned int x, unsigned int y)
{
}
}
-void
-clear_screens()
-{
- clear_screen(framebuffers->top_left);
- clear_screen(framebuffers->bottom);
-}
-
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)
{
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++) {
if (color_bg == 0) {
- screen[pos] = 0;
- screen[pos + 1] = 0;
- screen[pos + 2] = 0;
- if (buffer_bg[pos] >= dim_factor)
- screen[pos] = buffer_bg[pos] - dim_factor;
- if (buffer_bg[pos + 1] >= dim_factor)
- screen[pos + 1] = buffer_bg[pos + 1] - dim_factor;
- if (buffer_bg[pos + 2] >= dim_factor)
- screen[pos + 2] = buffer_bg[pos + 2] - dim_factor;
- } else {
- screen[pos] = color_bg >> 16;
- screen[pos + 1] = color_bg >> 8;
- screen[pos + 2] = color_bg;
- }
-
- if (char_dat & 0x80) {
- if (color_fg == 0) {
+ if (!config.options[OPTION_DIM_MODE]) {
+ screen[pos] = buffer_bg[pos];
+ screen[pos + 1] = buffer_bg[pos + 1];
+ screen[pos + 2] = buffer_bg[pos + 2];
+ } else {
screen[pos] = 0;
screen[pos + 1] = 0;
screen[pos + 2] = 0;
screen[pos + 1] = buffer_bg[pos + 1] - dim_factor;
if (buffer_bg[pos + 2] >= dim_factor)
screen[pos + 2] = buffer_bg[pos + 2] - dim_factor;
+ }
+ } else {
+ screen[pos] = color_bg >> 16;
+ screen[pos + 1] = color_bg >> 8;
+ screen[pos + 2] = color_bg;
+ }
+
+ if (char_dat & 0x80) {
+ if (color_fg == 0) {
+ if (!config.options[OPTION_DIM_MODE]) {
+ screen[pos] = buffer_bg[pos];
+ screen[pos + 1] = buffer_bg[pos + 1];
+ screen[pos + 2] = buffer_bg[pos + 2];
+ } else {
+ screen[pos] = 0;
+ screen[pos + 1] = 0;
+ screen[pos + 2] = 0;
+ if (buffer_bg[pos] >= dim_factor)
+ screen[pos] = buffer_bg[pos] - dim_factor;
+ if (buffer_bg[pos + 1] >= dim_factor)
+ screen[pos + 1] = buffer_bg[pos + 1] - dim_factor;
+ if (buffer_bg[pos + 2] >= dim_factor)
+ screen[pos + 2] = buffer_bg[pos + 2] - dim_factor;
+ }
} else {
screen[pos] = color_fg >> 16;
screen[pos + 1] = color_fg >> 8;
shut_up()
{
kill_output = !kill_output;
+ clear_disp(TOP_SCREEN);
+ clear_disp(BOTTOM_SCREEN);
}
void