Subversion Repositories freemyipod

Rev

Rev 243 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 243 Rev 293
Line 28... Line 28...
28
#include "contextswitch.h"
28
#include "contextswitch.h"
29
 
29
 
30
#define OFFSETX LCDCONSOLE_OFFSETX
30
#define OFFSETX LCDCONSOLE_OFFSETX
31
#define OFFSETY LCDCONSOLE_OFFSETY
31
#define OFFSETY LCDCONSOLE_OFFSETY
32
#define PIXELBYTES (LCD_BYTESPERPIXEL)
32
#define PIXELBYTES (LCD_BYTESPERPIXEL)
33
#define LINEBYTES (LCD_WIDTH * PIXELBYTES)
33
#define LINEBYTES (FRAMEBUF_WIDTH * PIXELBYTES)
34
#define COLBYTES (FONT_WIDTH * PIXELBYTES)
34
#define COLBYTES (FONT_WIDTH * PIXELBYTES)
35
#define ROWBYTES (FONT_HEIGHT * LINEBYTES)
35
#define ROWBYTES (FONT_HEIGHT * LINEBYTES)
36
#define OFFSETBYTES (LINEBYTES * OFFSETY + PIXELBYTES * OFFSETX)
36
#define OFFSETBYTES (LINEBYTES * OFFSETY + PIXELBYTES * OFFSETX)
37
 
37
 
38
 
38
 
39
static unsigned char framebuf[LCD_FRAMEBUFSIZE];
39
static unsigned char framebuf[LCD_FRAMEBUFSIZE] IBSS_ATTR;
40
static unsigned int current_row IBSS_ATTR;
40
static unsigned int current_row;
41
static unsigned int current_col IBSS_ATTR;
41
static unsigned int current_col;
42
static bool lcdconsole_needs_update IBSS_ATTR;
42
static bool lcdconsole_needs_update;
43
 
-
 
44
 
43
 
45
void lcdconsole_init()
44
void lcdconsole_init()
46
{
45
{
-
 
46
    displaylcd(0, LCD_WIDTH - 1, 0, LCD_HEIGHT - 1, (void*)0xffffffff, 0);
47
    memset(framebuf, -1, sizeof(framebuf));
47
    memset(framebuf, -1, sizeof(framebuf));
48
    current_row = 0;
48
    current_row = 0;
49
    current_col = -1;
49
    current_col = -1;
50
    lcdconsole_needs_update = false;
50
    lcdconsole_needs_update = false;
51
}
51
}
Line 78... Line 78...
78
        memset(&framebuf[LINEBYTES * OFFSETY + ROWBYTES * (LCDCONSOLE_ROWS - offset)],
78
        memset(&framebuf[LINEBYTES * OFFSETY + ROWBYTES * (LCDCONSOLE_ROWS - offset)],
79
            -1, ROWBYTES * offset);
79
            -1, ROWBYTES * offset);
80
        current_row = LCDCONSOLE_ROWS - 1;
80
        current_row = LCDCONSOLE_ROWS - 1;
81
    }
81
    }
82
    renderchar(&framebuf[OFFSETBYTES + ROWBYTES * current_row + COLBYTES * current_col],
82
    renderchar(&framebuf[OFFSETBYTES + ROWBYTES * current_row + COLBYTES * current_col],
83
               fgcolor, bgcolor, string, LCD_WIDTH);
83
               fgcolor, bgcolor, string, FRAMEBUF_WIDTH);
84
}
84
}
85
 
85
 
86
void lcdconsole_puts_noblit(const char* string, int fgcolor, int bgcolor)
86
void lcdconsole_puts_noblit(const char* string, int fgcolor, int bgcolor)
87
{
87
{
88
    while (*string) lcdconsole_putc_noblit(*string++, fgcolor, bgcolor);
88
    while (*string) lcdconsole_putc_noblit(*string++, fgcolor, bgcolor);
Line 101... Line 101...
101
        lcdconsole_needs_update = true;
101
        lcdconsole_needs_update = true;
102
        leave_critical_section(mode);
102
        leave_critical_section(mode);
103
        return;
103
        return;
104
    }
104
    }
105
    leave_critical_section(mode);
105
    leave_critical_section(mode);
106
    displaylcd(0, LCD_WIDTH - 1, 0, LCD_HEIGHT - 1, framebuf, 0);
106
    displaylcd((LCD_WIDTH - FRAMEBUF_WIDTH) / 2,
-
 
107
               (LCD_WIDTH - FRAMEBUF_WIDTH) / 2 + FRAMEBUF_WIDTH - 1,
-
 
108
               (LCD_HEIGHT - FRAMEBUF_HEIGHT) / 2,
-
 
109
               (LCD_HEIGHT - FRAMEBUF_HEIGHT) / 2 + FRAMEBUF_HEIGHT - 1,
-
 
110
               framebuf, 0);
107
}
111
}
108
 
112
 
109
void lcdconsole_putc(char string, int fgcolor, int bgcolor)
113
void lcdconsole_putc(char string, int fgcolor, int bgcolor)
110
{
114
{
111
    lcdconsole_putc_noblit(string, fgcolor, bgcolor);
115
    lcdconsole_putc_noblit(string, fgcolor, bgcolor);
Line 126... Line 130...
126
 
130
 
127
void lcdconsole_callback()
131
void lcdconsole_callback()
128
{
132
{
129
    if (lcdconsole_needs_update)
133
    if (lcdconsole_needs_update)
130
    {
134
    {
131
        displaylcd(0, LCD_WIDTH - 1, 0, LCD_HEIGHT - 1, framebuf, 0);
135
        displaylcd((LCD_WIDTH - FRAMEBUF_WIDTH) / 2,
-
 
136
                   (LCD_WIDTH - FRAMEBUF_WIDTH) / 2 + FRAMEBUF_WIDTH - 1,
-
 
137
                   (LCD_HEIGHT - FRAMEBUF_HEIGHT) / 2,
-
 
138
                   (LCD_HEIGHT - FRAMEBUF_HEIGHT) / 2 + FRAMEBUF_HEIGHT - 1,
-
 
139
                   framebuf, 0);
132
        lcdconsole_needs_update = false;
140
        lcdconsole_needs_update = false;
133
    }
141
    }
134
}
142
}
135
 
143
 
136
int lcdconsole_get_current_x()
144
int lcdconsole_get_current_x()