OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [common/] [screen.c] - Blame information for rev 857

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 marcus.erl
#include "common.h"
2
#include "support.h"
3
#include "screen.h"
4
 
5
#if CRT_ENABLED
6
unsigned long fg_color = COLOR_WHITE;
7
unsigned long bg_color = COLOR_BLACK;
8
int cx = 0;
9
int cy = 0;
10
 
11
extern unsigned char font[256][12];
12
static char screen[CHARSY][CHARSX];
13
 
14 406 julius
void put_char_xy(int x, int y, char c)
15
{
16
        int i, j;
17
        screen[y][x] = c;
18
        x *= CHAR_WIDTH;
19
        y *= CHAR_HEIGHT;
20
        for (i = 0; i < CHAR_HEIGHT; i++) {
21
                int t = font[(unsigned char)c][i];
22
                for (j = 0; j < CHAR_WIDTH; j++) {
23
                        PUT_PIXEL(x + j, y + i, (t & 1) ? fg_color : bg_color);
24
                        t >>= 1;
25
                }
26
        }
27 2 marcus.erl
}
28
 
29 406 julius
static void scroll(void)
30
{
31
        int x, y;
32 2 marcus.erl
#if 1
33 406 julius
        for (y = 1; y < CHARSY; y++)
34
                for (x = 0; x < CHARSX; x++)
35
                        put_char_xy(x, y - 1, screen[y][x]);
36 2 marcus.erl
#else
37 406 julius
        memcpy((unsigned char *)FB_BASE_ADDR,
38
               ((unsigned char *)FB_BASE_ADDR) + RESX * CHAR_HEIGHT,
39
               (RESY - CHAR_HEIGHT) * RESX);
40
        memcpy(&screen[0][0], &screen[1][0], (CHARSY - 1) * CHARSX);
41 2 marcus.erl
#endif
42 406 julius
        for (x = 0; x < CHARSX; x++)
43
                put_char_xy(x, CHARSY - 1, ' ');
44
        cy--;
45 2 marcus.erl
}
46
 
47 406 julius
void screen_putc(char c)
48
{
49
        int t;
50
        switch (c) {
51
        case '\n':
52
                cy++;
53
                cx = 0;
54
                if (cy >= CHARSY)
55
                        scroll();
56
                break;
57
        case '\r':
58
                cx = 0;
59
                break;
60
        case '\t':
61
                for (t = 0; t < 8 - (cx & 7); t++)
62
                        screen_putc(' ');
63
                break;
64
        case '\b':
65
                if (cx > 0)
66
                        cx--;
67
                put_char_xy(cx, cy, ' ');
68
                break;
69
        default:
70
                put_char_xy(cx, cy, c);
71
                cx++;
72
                if (cx >= CHARSX)
73
                        screen_putc('\n');
74
                break;
75
        }
76 2 marcus.erl
}
77
 
78 406 julius
void screen_clear()
79
{
80
        memset((unsigned char *)FB_BASE_ADDR, bg_color, RESX * RESY);
81
        memset(&screen[0][0], ' ', CHARSX * CHARSY);
82
        cx = cy = 0;
83 2 marcus.erl
}
84
 
85 406 julius
void screen_puts(char *s)
86
{
87
        while (*s) {
88
                screen_putc(*s);
89
                s++;
90
        }
91 2 marcus.erl
}
92
 
93 406 julius
void screen_init()
94
{
95
        screen_clear();
96
        SET_PALLETE(COLOR_BLACK, 0, 0, 0);
97
        SET_PALLETE(COLOR_WHITE, 127, 127, 127);
98 2 marcus.erl
 
99 406 julius
        /* Set screen offset */
100
        *((unsigned long *)CRT_BUFFER_REG) = FB_BASE_ADDR;
101 2 marcus.erl
 
102 406 julius
        /* Turn screen on */
103
        *((unsigned long *)CRT_REG) = 0x00000001;
104 2 marcus.erl
}
105
 
106
#endif /* CRT_ENABLED */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.