OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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

powered by: WebSVN 2.1.0

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