mirror of
https://github.com/gwenhael-le-moine/x49gp.git
synced 2024-12-26 21:58:41 +01:00
merge grayscale.diff by datajerk
This commit is contained in:
parent
e865764785
commit
f7913eb03a
3 changed files with 88 additions and 55 deletions
|
@ -15,6 +15,22 @@ typedef enum {
|
|||
UI_COLOR_SILVER,
|
||||
UI_COLOR_ORANGE,
|
||||
UI_COLOR_BLUE,
|
||||
UI_COLOR_GRAYSCALE_0,
|
||||
UI_COLOR_GRAYSCALE_1,
|
||||
UI_COLOR_GRAYSCALE_2,
|
||||
UI_COLOR_GRAYSCALE_3,
|
||||
UI_COLOR_GRAYSCALE_4,
|
||||
UI_COLOR_GRAYSCALE_5,
|
||||
UI_COLOR_GRAYSCALE_6,
|
||||
UI_COLOR_GRAYSCALE_7,
|
||||
UI_COLOR_GRAYSCALE_8,
|
||||
UI_COLOR_GRAYSCALE_9,
|
||||
UI_COLOR_GRAYSCALE_10,
|
||||
UI_COLOR_GRAYSCALE_11,
|
||||
UI_COLOR_GRAYSCALE_12,
|
||||
UI_COLOR_GRAYSCALE_13,
|
||||
UI_COLOR_GRAYSCALE_14,
|
||||
UI_COLOR_GRAYSCALE_15,
|
||||
UI_COLOR_MAX
|
||||
} x49gp_ui_color_t;
|
||||
|
||||
|
|
112
s3c2410_lcd.c
112
s3c2410_lcd.c
|
@ -90,14 +90,39 @@ x49gp_schedule_lcd_update(x49gp_t *x49gp)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
x49gp_get_pixel_color(s3c2410_lcd_t *lcd, int x, int y)
|
||||
{
|
||||
uint32_t bank, addr, data, offset, pixel_offset;
|
||||
int bits_per_pixel = lcd->lcdcon5 > 2 ? 1 : 4 >> lcd->lcdcon5;
|
||||
|
||||
bank = (lcd->lcdsaddr1 << 1) & 0x7fc00000;
|
||||
addr = bank | ((lcd->lcdsaddr1 << 1) & 0x003ffffe);
|
||||
|
||||
pixel_offset = (160 * y + x) * bits_per_pixel;
|
||||
offset = (pixel_offset >> 3) & 0xfffffffc;
|
||||
|
||||
data = ldl_phys(addr + offset);
|
||||
data >>= pixel_offset & 31;
|
||||
data &= (1 << bits_per_pixel) - 1;
|
||||
|
||||
switch (bits_per_pixel) {
|
||||
case 1:
|
||||
return 15 * data;
|
||||
case 2:
|
||||
return 15 & (lcd->bluelut >> (2 * data));
|
||||
default:
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
x49gp_lcd_update(x49gp_t *x49gp)
|
||||
{
|
||||
x49gp_ui_t *ui = x49gp->ui;
|
||||
s3c2410_lcd_t *lcd = x49gp->s3c2410_lcd;
|
||||
GdkRectangle rect;
|
||||
uint32_t bank, addr, offset, data;
|
||||
int row, i, b, x, y;
|
||||
int color, x, y;
|
||||
|
||||
if (!(lcd->lcdcon1 & 1)) {
|
||||
gdk_draw_drawable(ui->lcd_pixmap, ui->window->style->bg_gc[0],
|
||||
|
@ -107,69 +132,44 @@ x49gp_lcd_update(x49gp_t *x49gp)
|
|||
goto done;
|
||||
}
|
||||
|
||||
bank = (lcd->lcdsaddr1 << 1) & 0x7fc00000;
|
||||
addr = bank | ((lcd->lcdsaddr1 << 1) & 0x003ffffe);
|
||||
|
||||
gdk_draw_drawable(ui->lcd_pixmap, ui->window->style->bg_gc[0],
|
||||
ui->bg_pixmap,
|
||||
ui->lcd_x_offset, ui->lcd_y_offset,
|
||||
0, 0, ui->lcd_width, ui->lcd_height);
|
||||
|
||||
data = ldl_phys(addr + 16);
|
||||
if (data & (1 << 3)) {
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_io_gc, TRUE,
|
||||
236, 0, 15, 12);
|
||||
}
|
||||
data = ldl_phys(addr + 36);
|
||||
if (data & (1 << 3)) {
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_left_gc, TRUE,
|
||||
11, 0, 15, 12);
|
||||
}
|
||||
data = ldl_phys(addr + 56);
|
||||
if (data & (1 << 3)) {
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_right_gc, TRUE,
|
||||
56, 0, 15, 12);
|
||||
}
|
||||
data = ldl_phys(addr + 76);
|
||||
if (data & (1 << 3)) {
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_alpha_gc, TRUE,
|
||||
101, 0, 15, 12);
|
||||
}
|
||||
data = ldl_phys(addr + 96);
|
||||
if (data & (1 << 3)) {
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_battery_gc, TRUE,
|
||||
146, 0, 15, 12);
|
||||
}
|
||||
data = ldl_phys(addr + 116);
|
||||
if (data & (1 << 3)) {
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_busy_gc, TRUE,
|
||||
191, 0, 15, 12);
|
||||
}
|
||||
color = x49gp_get_pixel_color(lcd, 131, 0);
|
||||
gdk_gc_set_rgb_fg_color(ui->ann_io_gc, &(ui->colors[UI_COLOR_GRAYSCALE_0 + color]));
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_io_gc, TRUE, 236, 0, 15, 12);
|
||||
|
||||
offset = 0;
|
||||
for (row = 0; row < ui->lcd_height / 2; row++) {
|
||||
y = 2 * row;
|
||||
x = 0;
|
||||
for (i = 0; i < 5; i++) {
|
||||
data = ldl_phys(addr + offset);
|
||||
offset += sizeof(uint32_t);
|
||||
color = x49gp_get_pixel_color(lcd, 131, 1);
|
||||
gdk_gc_set_rgb_fg_color(ui->ann_left_gc, &(ui->colors[UI_COLOR_GRAYSCALE_0 + color]));
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_left_gc, TRUE, 11, 0, 15, 12);
|
||||
|
||||
for (b = 0; b < 32; b++) {
|
||||
if (data & (1 << b)) {
|
||||
gdk_draw_rectangle(ui->lcd_pixmap,
|
||||
ui->window->style->fg_gc[0],
|
||||
TRUE, x, y + ui->lcd_top_margin, 2, 2);
|
||||
}
|
||||
x += 2;
|
||||
color = x49gp_get_pixel_color(lcd, 131, 2);
|
||||
gdk_gc_set_rgb_fg_color(ui->ann_right_gc, &(ui->colors[UI_COLOR_GRAYSCALE_0 + color]));
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_right_gc, TRUE, 56, 0, 15, 12);
|
||||
|
||||
if (x >= ui->lcd_width) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
color = x49gp_get_pixel_color(lcd, 131, 3);
|
||||
gdk_gc_set_rgb_fg_color(ui->ann_alpha_gc, &(ui->colors[UI_COLOR_GRAYSCALE_0 + color]));
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_alpha_gc, TRUE, 101, 0, 15, 12);
|
||||
|
||||
addr = bank | ((lcd->lcdsaddr2 << 1) & 0x003ffffe);
|
||||
color = x49gp_get_pixel_color(lcd, 131, 4);
|
||||
gdk_gc_set_rgb_fg_color(ui->ann_battery_gc, &(ui->colors[UI_COLOR_GRAYSCALE_0 + color]));
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_battery_gc, TRUE, 146, 0, 15, 12);
|
||||
|
||||
color = x49gp_get_pixel_color(lcd, 131, 5);
|
||||
gdk_gc_set_rgb_fg_color(ui->ann_busy_gc, &(ui->colors[UI_COLOR_GRAYSCALE_0 + color]));
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->ann_busy_gc, TRUE, 191, 0, 15, 12);
|
||||
|
||||
for (y = 0; y < (ui->lcd_height - ui->lcd_top_margin) / 2; y++) {
|
||||
for (x = 0; x < ui->lcd_width / 2; x++) {
|
||||
color = x49gp_get_pixel_color(lcd, x, y);
|
||||
gdk_gc_set_rgb_fg_color(ui->window->style->fg_gc[0],
|
||||
&(ui->colors[UI_COLOR_GRAYSCALE_0 + color]));
|
||||
gdk_draw_rectangle(ui->lcd_pixmap, ui->window->style->fg_gc[0], TRUE,
|
||||
2 * x, 2 * y + ui->lcd_top_margin, 2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
done:
|
||||
rect.x = 0;
|
||||
|
|
17
ui.c
17
ui.c
|
@ -2289,6 +2289,23 @@ gui_load(x49gp_module_t *module, GKeyFile *keyfile)
|
|||
x49gp_ui_color_init(&ui->colors[UI_COLOR_ORANGE], 0xc0, 0x6e, 0x60);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_BLUE], 0x40, 0x60, 0xa4);
|
||||
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_0], 0xab, 0xd2, 0xb4);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_1], 0xa0, 0xc4, 0xa8);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_2], 0x94, 0xb6, 0x9c);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_3], 0x89, 0xa8, 0x90);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_4], 0x7d, 0x9a, 0x84);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_5], 0x72, 0x8c, 0x78);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_6], 0x67, 0x7e, 0x6c);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_7], 0x5b, 0x70, 0x60);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_8], 0x50, 0x62, 0x54);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_9], 0x44, 0x54, 0x48);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_10], 0x39, 0x46, 0x3c);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_11], 0x2e, 0x38, 0x30);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_12], 0x22, 0x2a, 0x24);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_13], 0x17, 0x1c, 0x18);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_14], 0x0b, 0x03, 0x0c);
|
||||
x49gp_ui_color_init(&ui->colors[UI_COLOR_GRAYSCALE_15], 0x00, 0x00, 0x00);
|
||||
|
||||
|
||||
ui->lcd_canvas = gtk_drawing_area_new();
|
||||
gtk_drawing_area_size(GTK_DRAWING_AREA(ui->lcd_canvas),
|
||||
|
|
Loading…
Reference in a new issue