| Index: embios/trunk/target/ipodnano2g/lcd.S | 
| — | — | @@ -122,7 +122,7 @@ | 
| 123 | 123 | add	r3, r3, #1 | 
| 124 | 124 | mul	r2, r1, r3 | 
| 125 | 125 | ldr	r1, [sp,#0x18] | 
| 126 |  | -	cmp	r1, #0x40000000
 | 
|  | 126 | +	cmp	r1, #-1 | 
| 127 | 127 | bne	displaylcd_dma | 
| 128 | 128 | displaylcd_pixel: | 
| 129 | 129 | ldr	r0, [sp,#0x1c] | 
| — | — | @@ -245,3 +245,22 @@ | 
| 246 | 246 | bl	lcdconsole_callback | 
| 247 | 247 | ldr	pc, [sp], #4 | 
| 248 | 248 | .size INT_DMA8, .-INT_DMA8 | 
|  | 249 | + | 
|  | 250 | +.section .icode.lcd_translate_color, "ax", %progbits | 
|  | 251 | +.align 2 | 
|  | 252 | +.global lcd_translate_color | 
|  | 253 | +.type lcd_translate_color, %function | 
|  | 254 | +lcd_translate_color: | 
|  | 255 | +	cmp	r0, #0xff | 
|  | 256 | +	moveq	r0, #-1 | 
|  | 257 | +	moveq	pc, lr | 
|  | 258 | +	cmp	r0, #0 | 
|  | 259 | +	movne	r0, #0xff000000 | 
|  | 260 | +	orrne	r0, r0, #0xff0000 | 
|  | 261 | +	mov	r2, r2,lsr#2 | 
|  | 262 | +	mov	r1, r1,lsr#3 | 
|  | 263 | +	orr	r0, r0, r3,lsr#3 | 
|  | 264 | +	orr	r0, r0, r2,lsl#5 | 
|  | 265 | +	orr	r0, r0, r1,lsl#11 | 
|  | 266 | +	mov	pc, lr | 
|  | 267 | +.size lcd_translate_color, .-lcd_translate_color | 
| Index: embios/trunk/target/ipodnano4g/lcd.S | 
| — | — | @@ -89,7 +89,7 @@ | 
| 90 | 90 | add	r3, r3, #1 | 
| 91 | 91 | mul	r2, r1, r3 | 
| 92 | 92 | ldr	r1, [sp,#0x10] | 
| 93 |  | -	cmp	r1, #0x40000000
 | 
|  | 93 | +	cmp	r1, #-1 | 
| 94 | 94 | bne	displaylcd_framebuf | 
| 95 | 95 | displaylcd_color: | 
| 96 | 96 | ldr	r0, [sp,#0x14] | 
| — | — | @@ -144,3 +144,21 @@ | 
| 145 | 145 | mov	pc, lr | 
| 146 | 146 | .size displaylcd_safe, .-displaylcd_safe | 
| 147 | 147 |  | 
|  | 148 | +.section .icode.lcd_translate_color, "ax", %progbits | 
|  | 149 | +.align 2 | 
|  | 150 | +.global lcd_translate_color | 
|  | 151 | +.type lcd_translate_color, %function | 
|  | 152 | +lcd_translate_color: | 
|  | 153 | +	cmp	r0, #0xff | 
|  | 154 | +	moveq	r0, #-1 | 
|  | 155 | +	moveq	pc, lr | 
|  | 156 | +	cmp	r0, #0 | 
|  | 157 | +	movne	r0, #0xff000000 | 
|  | 158 | +	orrne	r0, r0, #0xff0000 | 
|  | 159 | +	mov	r2, r2,lsr#2 | 
|  | 160 | +	mov	r1, r1,lsr#3 | 
|  | 161 | +	orr	r0, r0, r3,lsr#3 | 
|  | 162 | +	orr	r0, r0, r2,lsl#5 | 
|  | 163 | +	orr	r0, r0, r1,lsl#11 | 
|  | 164 | +	mov	pc, lr | 
|  | 165 | +.size lcd_translate_color, .-lcd_translate_color | 
| Index: embios/trunk/lcd.h | 
| — | — | @@ -31,15 +31,16 @@ | 
| 32 | 32 | #define LCD_FRAMEBUFSIZE (LCD_WIDTH * LCD_HEIGHT * LCD_BYTESPERPIXEL) | 
| 33 | 33 |  | 
| 34 | 34 |  | 
| 35 |  | -void lcd_init();
 | 
| 36 |  | -int lcd_get_width();
 | 
| 37 |  | -int lcd_get_height();
 | 
| 38 |  | -int lcd_get_bytes_per_pixel();
 | 
|  | 35 | +void lcd_init() INITCODE_ATTR; | 
|  | 36 | +int lcd_get_width() ICODE_ATTR; | 
|  | 37 | +int lcd_get_height() ICODE_ATTR; | 
|  | 38 | +int lcd_get_bytes_per_pixel() ICODE_ATTR; | 
|  | 39 | +int lcd_translate_color(uint8_t alpha, uint8_t red, uint8_t green, uint8_t blue) ICODE_ATTR; | 
| 39 | 40 | void displaylcd(unsigned int startx, unsigned int endx, | 
| 40 |  | -                unsigned int starty, unsigned int endy, void* data, int color);
 | 
| 41 |  | -void displaylcd_sync();
 | 
| 42 |  | -bool displaylcd_busy();
 | 
| 43 |  | -bool displaylcd_safe();
 | 
|  | 41 | +                unsigned int starty, unsigned int endy, void* data, int color) ICODE_ATTR; | 
|  | 42 | +void displaylcd_sync() ICODE_ATTR; | 
|  | 43 | +bool displaylcd_busy() ICODE_ATTR; | 
|  | 44 | +bool displaylcd_safe() ICODE_ATTR; | 
| 44 | 45 |  | 
| 45 | 46 |  | 
| 46 | 47 | #endif | 
| Index: embios/trunk/progressbar.c | 
| — | — | @@ -0,0 +1,70 @@ | 
|  | 2 | +// | 
|  | 3 | +// | 
|  | 4 | +//    Copyright 2010 TheSeven | 
|  | 5 | +// | 
|  | 6 | +// | 
|  | 7 | +//    This file is part of emBIOS. | 
|  | 8 | +// | 
|  | 9 | +//    emBIOS is free software: you can redistribute it and/or | 
|  | 10 | +//    modify it under the terms of the GNU General Public License as | 
|  | 11 | +//    published by the Free Software Foundation, either version 2 of the | 
|  | 12 | +//    License, or (at your option) any later version. | 
|  | 13 | +// | 
|  | 14 | +//    emBIOS is distributed in the hope that it will be useful, | 
|  | 15 | +//    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 16 | +//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 
|  | 17 | +//    See the GNU General Public License for more details. | 
|  | 18 | +// | 
|  | 19 | +//    You should have received a copy of the GNU General Public License along | 
|  | 20 | +//    with emBIOS.  If not, see <http://www.gnu.org/licenses/>. | 
|  | 21 | +// | 
|  | 22 | +// | 
|  | 23 | + | 
|  | 24 | + | 
|  | 25 | +#include "global.h" | 
|  | 26 | +#include "progressbar.h" | 
|  | 27 | +#include "lcd.h" | 
|  | 28 | + | 
|  | 29 | + | 
|  | 30 | +static void progressbar_drawborderbg(struct progressbar_state* state) | 
|  | 31 | +{ | 
|  | 32 | +    state->currentx = state->startx; | 
|  | 33 | +    displaylcd(state->startx + 1, state->endx - 1, state->starty + 1, state->endy - 1, | 
|  | 34 | +               (void*)-1, state->bgcolor); | 
|  | 35 | +    displaylcd(state->startx, state->endx, state->starty, state->starty, | 
|  | 36 | +               (void*)-1, state->bordercolor); | 
|  | 37 | +    displaylcd(state->startx, state->endx, state->endy, state->endy, | 
|  | 38 | +               (void*)-1, state->bordercolor); | 
|  | 39 | +    displaylcd(state->startx, state->startx, state->starty + 1, state->endy - 1, | 
|  | 40 | +               (void*)-1, state->bordercolor); | 
|  | 41 | +    displaylcd(state->endx, state->endx, state->starty + 1, state->endy - 1, | 
|  | 42 | +               (void*)-1, state->bordercolor); | 
|  | 43 | +} | 
|  | 44 | + | 
|  | 45 | +void progressbar_init(struct progressbar_state* state, int startx, int endx, int starty, int endy, | 
|  | 46 | +                      int bordercolor, int bgcolor, int fgcolor, int min, int max) | 
|  | 47 | +{ | 
|  | 48 | +    state->startx = startx; | 
|  | 49 | +    state->endx = endx; | 
|  | 50 | +    state->starty = starty; | 
|  | 51 | +    state->endy = endy; | 
|  | 52 | +    state->bordercolor = bordercolor; | 
|  | 53 | +    state->bgcolor = bgcolor; | 
|  | 54 | +    state->fgcolor = fgcolor; | 
|  | 55 | +    state->min = min; | 
|  | 56 | +    state->max = max; | 
|  | 57 | +    progressbar_drawborderbg(state); | 
|  | 58 | +} | 
|  | 59 | + | 
|  | 60 | +void progressbar_setpos(struct progressbar_state* state, int value, bool redraw) | 
|  | 61 | +{ | 
|  | 62 | +    if (value > state->max) value = state->max; | 
|  | 63 | +    if (value < state->min) value = state->min; | 
|  | 64 | +    int newx = (value - state->min) * (state->endx - state->startx - 1) | 
|  | 65 | +             / (state->max - state->min) + state->startx; | 
|  | 66 | +    if (redraw || newx < state->currentx) progressbar_drawborderbg(state); | 
|  | 67 | +    if (newx > state->currentx) | 
|  | 68 | +        displaylcd(state->currentx + 1, newx, state->starty + 1, state->endy - 1, | 
|  | 69 | +                   (void*)-1, state->fgcolor); | 
|  | 70 | +    state->currentx = newx; | 
|  | 71 | +} | 
| Index: embios/trunk/progressbar.h | 
| — | — | @@ -0,0 +1,52 @@ | 
|  | 2 | +// | 
|  | 3 | +// | 
|  | 4 | +//    Copyright 2010 TheSeven | 
|  | 5 | +// | 
|  | 6 | +// | 
|  | 7 | +//    This file is part of emBIOS. | 
|  | 8 | +// | 
|  | 9 | +//    emBIOS is free software: you can redistribute it and/or | 
|  | 10 | +//    modify it under the terms of the GNU General Public License as | 
|  | 11 | +//    published by the Free Software Foundation, either version 2 of the | 
|  | 12 | +//    License, or (at your option) any later version. | 
|  | 13 | +// | 
|  | 14 | +//    emBIOS is distributed in the hope that it will be useful, | 
|  | 15 | +//    but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 16 | +//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 
|  | 17 | +//    See the GNU General Public License for more details. | 
|  | 18 | +// | 
|  | 19 | +//    You should have received a copy of the GNU General Public License along | 
|  | 20 | +//    with emBIOS.  If not, see <http://www.gnu.org/licenses/>. | 
|  | 21 | +// | 
|  | 22 | +// | 
|  | 23 | + | 
|  | 24 | + | 
|  | 25 | +#ifndef __PROGRESSBAR_H__ | 
|  | 26 | +#define __PROGRESSBAR_H__ | 
|  | 27 | + | 
|  | 28 | + | 
|  | 29 | +#include "global.h" | 
|  | 30 | +#include "lcd.h" | 
|  | 31 | + | 
|  | 32 | + | 
|  | 33 | +struct progressbar_state | 
|  | 34 | +{ | 
|  | 35 | +    int startx; | 
|  | 36 | +    int endx; | 
|  | 37 | +    int starty; | 
|  | 38 | +    int endy; | 
|  | 39 | +    int bordercolor; | 
|  | 40 | +    int bgcolor; | 
|  | 41 | +    int fgcolor; | 
|  | 42 | +    int currentx; | 
|  | 43 | +    int min; | 
|  | 44 | +    int max; | 
|  | 45 | +}; | 
|  | 46 | + | 
|  | 47 | + | 
|  | 48 | +void progressbar_init(struct progressbar_state* state, int startx, int endx, int starty, int endy, | 
|  | 49 | +                      int bordercolor, int bgcolor, int fgcolor, int min, int max); | 
|  | 50 | +void progressbar_setpos(struct progressbar_state* state, int value, bool redraw); | 
|  | 51 | + | 
|  | 52 | + | 
|  | 53 | +#endif | 
| Index: embios/trunk/export/syscallwrappers.h | 
| — | — | @@ -71,6 +71,12 @@ | 
| 72 | 72 | #define lcdconsole_putc(args...) __embios_syscall->lcdconsole_putc(args) | 
| 73 | 73 | #define lcdconsole_puts(args...) __embios_syscall->lcdconsole_puts(args) | 
| 74 | 74 | #define lcdconsole_write(args...) __embios_syscall->lcdconsole_write(args) | 
|  | 75 | +#define lcdconsole_get_current_x(args...) __embios_syscall->lcdconsole_get_current_x(args) | 
|  | 76 | +#define lcdconsole_get_current_y(args...) __embios_syscall->lcdconsole_get_current_y(args) | 
|  | 77 | +#define lcdconsole_get_lineend_x(args...) __embios_syscall->lcdconsole_get_lineend_x(args) | 
|  | 78 | +#define lcdconsole_get_lineend_y(args...) __embios_syscall->lcdconsole_get_lineend_y(args) | 
|  | 79 | +#define progressbar_init(args...) __embios_syscall->progressbar_init(args) | 
|  | 80 | +#define progressbar_setpos(args...) __embios_syscall->progressbar_setpos(args) | 
| 75 | 81 | #define shutdown(args...) __embios_syscall->shutdown(args) | 
| 76 | 82 | #define storage_read_sectors_md(args...) __embios_syscall->storage_read_sectors_md(args) | 
| 77 | 83 | #define storage_write_sectors_md(args...) __embios_syscall->storage_write_sectors_md(args) | 
| — | — | @@ -116,6 +122,7 @@ | 
| 117 | 123 | #define lcd_get_width(args...) __embios_syscall->lcd_get_width(args) | 
| 118 | 124 | #define lcd_get_height(args...) __embios_syscall->lcd_get_height(args) | 
| 119 | 125 | #define lcd_get_bytes_per_pixel(args...) __embios_syscall->lcd_get_bytes_per_pixel(args) | 
|  | 126 | +#define lcd_translate_color(args...) __embios_syscall->lcd_translate_color(args) | 
| 120 | 127 | #define clean_dcache(args...) __embios_syscall->clean_dcache(args) | 
| 121 | 128 | #define invalidate_dcache(args...) __embios_syscall->invalidate_dcache(args) | 
| 122 | 129 | #define invalidate_icache(args...) __embios_syscall->invalidate_icache(args) | 
| Index: embios/trunk/export/syscallapi.h | 
| — | — | @@ -47,6 +47,7 @@ | 
| 48 | 48 | #include "../execimage.h" | 
| 49 | 49 | #include "../backlight.h" | 
| 50 | 50 | #include "../syscall.h" | 
|  | 51 | +#include "../progressbar.h" | 
| 51 | 52 | #include "../libc/include/string.h" | 
| 52 | 53 | #include "../libc/include/stdlib.h" | 
| 53 | 54 | #include "../libc/include/stdio.h" | 
| — | — | @@ -107,6 +108,12 @@ | 
| 108 | 109 | typeof(lcdconsole_putc) *lcdconsole_putc; | 
| 109 | 110 | typeof(lcdconsole_puts) *lcdconsole_puts; | 
| 110 | 111 | typeof(lcdconsole_write) *lcdconsole_write; | 
|  | 112 | +    typeof(lcdconsole_get_current_x) *lcdconsole_get_current_x; | 
|  | 113 | +    typeof(lcdconsole_get_current_y) *lcdconsole_get_current_y; | 
|  | 114 | +    typeof(lcdconsole_get_lineend_x) *lcdconsole_get_lineend_x; | 
|  | 115 | +    typeof(lcdconsole_get_lineend_y) *lcdconsole_get_lineend_y; | 
|  | 116 | +    typeof(progressbar_init) *progressbar_init; | 
|  | 117 | +    typeof(progressbar_setpos) *progressbar_setpos; | 
| 111 | 118 | typeof(shutdown) *shutdown; | 
| 112 | 119 | typeof(storage_read_sectors_md) *storage_read_sectors_md; | 
| 113 | 120 | typeof(storage_write_sectors_md) *storage_write_sectors_md; | 
| — | — | @@ -152,6 +159,7 @@ | 
| 153 | 160 | typeof(lcd_get_width) *lcd_get_width; | 
| 154 | 161 | typeof(lcd_get_height) *lcd_get_height; | 
| 155 | 162 | typeof(lcd_get_bytes_per_pixel) *lcd_get_bytes_per_pixel; | 
|  | 163 | +    typeof(lcd_translate_color) *lcd_translate_color; | 
| 156 | 164 | typeof(clean_dcache) *clean_dcache; | 
| 157 | 165 | typeof(invalidate_dcache) *invalidate_dcache; | 
| 158 | 166 | typeof(invalidate_icache) *invalidate_icache; | 
| Index: embios/trunk/SOURCES | 
| — | — | @@ -40,6 +40,7 @@ | 
| 41 | 41 | #ifdef HAVE_LCD | 
| 42 | 42 | drawing.S | 
| 43 | 43 | lcdconsole.c | 
|  | 44 | +progressbar.c | 
| 44 | 45 | #endif | 
| 45 | 46 | format.c | 
| 46 | 47 | panic.c | 
| Index: embios/trunk/syscallapi.c | 
| — | — | @@ -23,30 +23,6 @@ | 
| 24 | 24 |  | 
| 25 | 25 | #include "global.h" | 
| 26 | 26 | #include "syscallapi.h" | 
| 27 |  | -#include "panic.h"
 | 
| 28 |  | -#include "console.h"
 | 
| 29 |  | -#include "dir.h"
 | 
| 30 |  | -#include "file.h"
 | 
| 31 |  | -#include "format.h"
 | 
| 32 |  | -#include "lcdconsole.h"
 | 
| 33 |  | -#include "storage.h"
 | 
| 34 |  | -#include "shutdown.h"
 | 
| 35 |  | -#include "thread.h"
 | 
| 36 |  | -#include "ucl.h"
 | 
| 37 |  | -#include "bootflash.h"
 | 
| 38 |  | -#include "timer.h"
 | 
| 39 |  | -#include "i2c.h"
 | 
| 40 |  | -#include "interrupt.h"
 | 
| 41 |  | -#include "lcd.h"
 | 
| 42 |  | -#include "mmu.h"
 | 
| 43 |  | -#include "nand.h"
 | 
| 44 |  | -#include "power.h"
 | 
| 45 |  | -#include "execimage.h"
 | 
| 46 |  | -#include "backlight.h"
 | 
| 47 |  | -#include "syscall.h"
 | 
| 48 |  | -#include "libc/include/string.h"
 | 
| 49 |  | -#include "libc/include/stdlib.h"
 | 
| 50 |  | -#include "libc/include/stdio.h"
 | 
| 51 | 27 |  | 
| 52 | 28 |  | 
| 53 | 29 | struct embios_syscall_table syscall_table ICONST_ATTR = | 
| — | — | @@ -153,6 +129,12 @@ | 
| 154 | 130 | .lcdconsole_putc = lcdconsole_putc, | 
| 155 | 131 | .lcdconsole_puts = lcdconsole_puts, | 
| 156 | 132 | .lcdconsole_write = lcdconsole_write, | 
|  | 133 | +    .lcdconsole_get_current_x = lcdconsole_get_current_x, | 
|  | 134 | +    .lcdconsole_get_current_y = lcdconsole_get_current_y, | 
|  | 135 | +    .lcdconsole_get_lineend_x = lcdconsole_get_lineend_x, | 
|  | 136 | +    .lcdconsole_get_lineend_y = lcdconsole_get_lineend_y, | 
|  | 137 | +    .progressbar_init = progressbar_init, | 
|  | 138 | +    .progressbar_setpos = progressbar_setpos, | 
| 157 | 139 | .displaylcd = displaylcd, | 
| 158 | 140 | .displaylcd_sync = displaylcd_sync, | 
| 159 | 141 | .displaylcd_busy = displaylcd_busy, | 
| — | — | @@ -160,6 +142,7 @@ | 
| 161 | 143 | .lcd_get_width = lcd_get_width, | 
| 162 | 144 | .lcd_get_height = lcd_get_height, | 
| 163 | 145 | .lcd_get_bytes_per_pixel = lcd_get_bytes_per_pixel, | 
|  | 146 | +    .lcd_translate_color = lcd_translate_color, | 
| 164 | 147 | #endif | 
| 165 | 148 | #ifdef HAVE_BACKLIGHT | 
| 166 | 149 | .backlight_on = backlight_on, | 
| Index: embios/trunk/lcdconsole.c | 
| — | — | @@ -133,3 +133,23 @@ | 
| 134 | 134 | lcdconsole_needs_update = false; | 
| 135 | 135 | } | 
| 136 | 136 | } | 
|  | 137 | + | 
|  | 138 | +int lcdconsole_get_current_x() | 
|  | 139 | +{ | 
|  | 140 | +    return (current_col + 1) * FONT_WIDTH + OFFSETX; | 
|  | 141 | +} | 
|  | 142 | + | 
|  | 143 | +int lcdconsole_get_current_y() | 
|  | 144 | +{ | 
|  | 145 | +    return current_row * FONT_HEIGHT + OFFSETY; | 
|  | 146 | +} | 
|  | 147 | + | 
|  | 148 | +int lcdconsole_get_lineend_x() | 
|  | 149 | +{ | 
|  | 150 | +    return LCDCONSOLE_COLS * FONT_WIDTH + OFFSETX - 1; | 
|  | 151 | +} | 
|  | 152 | + | 
|  | 153 | +int lcdconsole_get_lineend_y() | 
|  | 154 | +{ | 
|  | 155 | +    return (current_row + 1) * FONT_HEIGHT + OFFSETY - 1; | 
|  | 156 | +} | 
| Index: embios/trunk/lcdconsole.h | 
| — | — | @@ -45,6 +45,10 @@ | 
| 46 | 46 | void lcdconsole_write_noblit(const char* string, size_t length, int fgcolor, int bgcolor) ICODE_ATTR; | 
| 47 | 47 | void lcdconsole_update() ICODE_ATTR; | 
| 48 | 48 | void lcdconsole_callback() ICODE_ATTR; | 
|  | 49 | +int lcdconsole_get_current_x() ICODE_ATTR; | 
|  | 50 | +int lcdconsole_get_current_y() ICODE_ATTR; | 
|  | 51 | +int lcdconsole_get_lineend_x() ICODE_ATTR; | 
|  | 52 | +int lcdconsole_get_lineend_y() ICODE_ATTR; | 
| 49 | 53 |  | 
| 50 | 54 |  | 
| 51 | 55 | #endif |