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

Subversion Repositories or1k

[/] [or1k/] [tags/] [initial/] [orpmon/] [common/] [screen.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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