Subversion Repositories SvarDOS

Rev

Rev 28 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28 Rev 29
Line 8... Line 8...
8
 */
8
 */
9
 
9
 
10
#include <dos.h>
10
#include <dos.h>
11
#include "video.h" /* include self for control */
11
#include "video.h" /* include self for control */
12
 
12
 
13
/* pointers to VGA/MDA screens */
13
/* pointer to the VGA/MDA screen */
14
static unsigned short far *vga = (unsigned short far *)0xB8000000L;
14
static unsigned short far *scr = (unsigned short far *)0xB8000000L;
15
static unsigned short far *mda = (unsigned short far *)0xB0000000L;
-
 
16
 
15
 
17
void video_clear(unsigned short attr, int offset) {
16
void video_clear(unsigned short attr, int offset) {
18
  int x;
17
  int x;
19
  for (x = offset; x < 2000; x++) {
18
  for (x = offset; x < 2000; x++) {
20
    vga[x] = attr;
-
 
21
    mda[x] = attr;
19
    scr[x] = attr;
22
  }
20
  }
23
}
21
}
24
 
22
 
-
 
23
/* inits screen, returns 0 for color mode, 1 for mono */
-
 
24
int video_init(void) {
-
 
25
  union REGS r;
-
 
26
  int monoflag;
-
 
27
  /* get current video mode to detect color (7 = mono, anything else is color) */
-
 
28
  r.h.ah = 0x0F;
-
 
29
  int86(0x10, &r, &r);
-
 
30
  /* set the monoflag to detected value and prepare the next mode we will set */
-
 
31
  if (r.h.al == 7) {
-
 
32
    monoflag = 1;
-
 
33
    r.h.al = 7; /* 80x25 2 colors (MDA / Hercules) */
-
 
34
    scr = (unsigned short far *)0xB0000000L;
-
 
35
  } else if (r.h.al == 2) { /* 80x25 grayscale */
-
 
36
    monoflag = 1;
-
 
37
    r.h.al = 2; /* 80x25 grayscale */
-
 
38
    scr = (unsigned short far *)0xB8000000L;
-
 
39
  } else {
-
 
40
    monoflag = 0;
-
 
41
    r.h.al = 3; /* 80x25 16 colors */
-
 
42
    scr = (unsigned short far *)0xB8000000L;
-
 
43
  }
-
 
44
  /* (re)set video mode to be sure what we are dealing with */
-
 
45
  r.h.ah = 0;
-
 
46
  int86(0x10, &r, &r);
-
 
47
  return(monoflag);
-
 
48
}
-
 
49
 
25
void video_putchar(int y, int x, unsigned short attr, int c) {
50
void video_putchar(int y, int x, unsigned short attr, int c) {
26
  int offset = (y << 6) + (y << 4) + x;
51
  scr[(y << 6) + (y << 4) + x] = attr | c;
27
  vga[offset] = attr | c;
-
 
28
  mda[offset] = attr | c;
-
 
29
}
52
}
30
 
53
 
31
void video_putcharmulti(int y, int x, unsigned short attr, int c, int repeat, int step) {
54
void video_putcharmulti(int y, int x, unsigned short attr, int c, int repeat, int step) {
32
  int offset = (y << 6) + (y << 4) + x;
55
  int offset = (y << 6) + (y << 4) + x;
33
  while (repeat-- > 0) {
56
  while (repeat-- > 0) {
34
    vga[offset] = attr | c;
-
 
35
    mda[offset] = attr | c;
57
    scr[offset] = attr | c;
36
    offset += step;
58
    offset += step;
37
  }
59
  }
38
}
60
}
39
 
61
 
40
void video_putstring(int y, int x, unsigned short attr, char *s) {
62
void video_putstring(int y, int x, unsigned short attr, char *s) {
41
  x += (y << 6) + (y << 4); /* I use x as an offset now */
63
  x += (y << 6) + (y << 4); /* I use x as an offset now */
42
  while (*s != 0) {
64
  while (*s != 0) {
43
    unsigned short b = attr | *s;
65
    scr[x++] = attr | *s;
44
    vga[x] = b;
-
 
45
    mda[x] = b;
-
 
46
    x++;
-
 
47
    s++;
66
    s++;
48
  }
67
  }
49
}
68
}
50
 
69
 
51
void video_putstringfix(int y, int x, unsigned short attr, char *s, int w) {
70
void video_putstringfix(int y, int x, unsigned short attr, char *s, int w) {
52
  x += (y << 6) + (y << 4); /* I use x as an offset now */
71
  x += (y << 6) + (y << 4); /* I use x as an offset now */
53
  while (w-- > 0) {
72
  while (w-- > 0) {
54
    unsigned short b;
-
 
55
    b = attr | *s;
73
    scr[x++] = attr | *s;
56
    if (*s != 0) s++;
74
    if (*s != 0) s++;
57
    vga[x] = b;
-
 
58
    mda[x] = b;
-
 
59
    x++;
-
 
60
  }
75
  }
61
}
76
}
62
 
77
 
63
void video_movecursor(int y, int x) {
78
void video_movecursor(int y, int x) {
64
  union REGS r;
79
  union REGS r;