Jspice3
vgacolor.c File Reference
#include <dos.h>
Include dependency graph for vgacolor.c:

Go to the source code of this file.

Functions

void vga_get_color (int num, int *red, int *green, int *blue)
 
void vga_set_color (int num, int red, int green, int blue)
 
void vga_get_cblock (char *p, int i, int n)
 
void vga_set_cblock (char *p, int i, int n)
 
void vga_get_cpblock (char *p)
 
void vga_set_cpblock (char *p)
 

Function Documentation

void vga_get_cblock ( char *  p,
int  i,
int  n 
)

Definition at line 46 of file vgacolor.c.

51 {
52  int j;
53 
54  if (i+n > 256 || i < 0 || n < 0) return;
55  outp(0x3c4,1); /* sequencer clock mode */
56  outp(0x3c5,0x21); /* blank the display */
57  outp(0x3c7,i); /* write index */
58  for (j = 0; j < n; j++) {
59  p[j][0] = inp(0x3c9); /* read rgb */
60  p[j][1] = inp(0x3c9);
61  p[j][2] = inp(0x3c9);
62  }
63  outp(0x3c5,0x1); /* turn display on */
64 }
Definition: cddefs.h:215
void vga_get_color ( int  num,
int *  red,
int *  green,
int *  blue 
)

Definition at line 16 of file vgacolor.c.

20 {
21  if (num > 255 || num < 0) return;
22  outp(0x3c7,num); /* write index */
23  while (!(inp(0x3da) & 0x8)) ; /* wait for V retrace */
24  *red = inp(0x3c9); /* read rgb */
25  *green = inp(0x3c9);
26  *blue = inp(0x3c9);
27 }
void vga_get_cpblock ( char *  p)

Definition at line 90 of file vgacolor.c.

94 {
95  int j;
96 
97  while (!(inp(0x3da) & 0x8)) ; /* wait for V retrace */
98  for (j = 0; j < 16; j++) {
99  outp(0x3c0,j); /* index, enable xfer */
100  p[j] = inp(0x3c1); /* read data */
101  inp(0x3da); /* reset to address mode */
102  outp(0x3c0,j | 0x20); /* index, enable EGA */
103  inp(0x3da); /* reset to address mode */
104  }
105 }
Definition: cddefs.h:215
void vga_set_cblock ( char *  p,
int  i,
int  n 
)

Definition at line 68 of file vgacolor.c.

73 {
74  int j;
75 
76  if (i+n > 256 || i < 0 || n < 0) return;
77  outp(0x3c4,1); /* sequencer clock mode */
78  outp(0x3c5,0x21); /* blank the display */
79  outp(0x3c8,i); /* write index */
80  for (j = 0; j < n; j++) {
81  outp(0x3c9,p[j][0]); /* write rgb */
82  outp(0x3c9,p[j][1]);
83  outp(0x3c9,p[j][2]);
84  }
85  outp(0x3c5,0x1); /* turn display on */
86 }
Definition: cddefs.h:215
void vga_set_color ( int  num,
int  red,
int  green,
int  blue 
)

Definition at line 31 of file vgacolor.c.

35 {
36  if (num > 255 || num < 0) return;
37  outp(0x3c8,num); /* write index */
38  while (!(inp(0x3da) & 0x8)) ; /* wait for V retrace */
39  outp(0x3c9,red); /* write rgb */
40  outp(0x3c9,green);
41  outp(0x3c9,blue);
42 }
void vga_set_cpblock ( char *  p)

Definition at line 109 of file vgacolor.c.

113 {
114  int j;
115 
116  while (!(inp(0x3da) & 0x8)) ; /* wait for V retrace */
117  for (j = 0; j < 16; j++) {
118  outp(0x3c0,j); /* index, enable xfer */
119  outp(0x3c0,p[j]); /* write data */
120  inp(0x3da); /* reset to address mode */
121  outp(0x3c0,j | 0x20); /* index, enable EGA */
122  inp(0x3da); /* reset to address mode */
123  }
124 }
Definition: cddefs.h:215