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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orpmon/] [common/] [screen.c] - Blame information for rev 1770

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

Line No. Rev Author Line
1 809 simons
#include "common.h"
2 858 markom
#include "support.h"
3 809 simons
#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 858 markom
      PUT_PIXEL(x + j, y + i, (t & 1) ? fg_color : bg_color);
23
      t >>= 1;
24 809 simons
    }
25
  }
26
}
27
 
28
static void scroll (void) {
29
  int x,y;
30 858 markom
#if 1
31 809 simons
  for (y = 1; y < CHARSY; y++)
32
    for (x = 0; x < CHARSX; x++)
33
      put_char_xy (x, y-1, screen[y][x]);
34 858 markom
#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 809 simons
  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 858 markom
  case '\b':
60
    if (cx > 0) cx--;
61
    put_char_xy(cx, cy, ' ');
62
    break;
63 809 simons
  default:
64 858 markom
    put_char_xy(cx, cy, c);
65 809 simons
    cx++;
66
    if(cx >= CHARSX) screen_putc ('\n');
67
    break;
68
  }
69
}
70
 
71
void screen_clear () {
72 858 markom
  memset ((unsigned char *)FB_BASE_ADDR, bg_color, RESX * RESY);
73
  memset (&screen[0][0], ' ', CHARSX * CHARSY);
74 809 simons
  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 858 markom
  screen_clear ();
86 809 simons
  SET_PALLETE(COLOR_BLACK, 0, 0, 0);
87 858 markom
  SET_PALLETE(COLOR_WHITE, 127, 127, 127);
88 809 simons
 
89
  /* Set screen offset */
90 817 simons
  *((unsigned long *)CRT_BUFFER_REG) = FB_BASE_ADDR;
91 809 simons
 
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.