Mail Archives: djgpp/1994/10/26/16:51:38
The following short program tries to read the palette from the
video card and print each rgb triplet. On either of the systems
I've tried it on it dumps in the readpal routine
f I optimize
it. The systems I've tried are a 386 with unknown vga card and
a dx2/66 with Tseng chipset svga card. Both with go32 1.11maint5
and gcc 2.5.7
Can anybody give me a clue as to what I've done wrong? or is
the optimizer really breaking good code?
----
/* palette.h
* Copyright 1994 Robert Reay.
*/
#include <cnc/typedef.h>
typedef struct {
ints16 r;
intu8 g;
intu8 b;
} COLOR;
typedef struct {
int num;
COLOR color[256];
} PALETTE;
void fade(PALETTE *, PALETTE *, int);
void readpal(COLOR *, int);
----
/*
* readpal.c
* Copyright 1994 Robert Reay and Pat F.
*/
#include "palette.h"
#include <dpmi.h>
static _go32_dpmi_registers regs;
void readpal(COLOR *c, int n) {
regs.x.bx = n; /* which palette reg? */
regs.x.ax = 0x1015; /* read palette */
_go32_dpmi_simulate_int(0x10, ®s);
c->r = regs.h.dh;
c->g = regs.h.ch;
c->b = regs.h.cl;
}
----
/* copyright 1994 rob reay */
#include "palette.h"
void
main () {
int x;
COLOR *c;
for (x=0; x < 256 ; ++x) {
readpal(c, x);
printf("%d <%d,%d,%d>\n", x,c->r, c->g, c->b);
}
}
- Raw text -