Jspice3
mfbgetpx.c
Go to the documentation of this file.
1 /*************************************************************************
2  MFB graphics and miscellaneous library
3  Copyright (c) Stephen R. Whiteley 1992
4  Author: Stephen R. Whiteley
5  *************************************************************************/
6 
7 #include "mfb.h"
8 #include "mfbP.h"
9 #include <dos.h>
10 
11 
12 int
14 
15 /* return color at x,y (0,0 is upper left) */
16 int x, y;
17 {
18  int color = 0, latch;
19  vidmptr rgen;
20  union { unsigned short o[2]; long l; } p;
21  int plane;
22  int bit_number = (x & 7)^7;
23  int bit_mask = (1 << bit_number);
24 
25  if (pc.mfbMODE & 2) {
26  p.l = x + (long) (pc.ysize-1-y)*pc.xsize;
27 #ifndef __GNUC__
28  outp(0x3cd,p.o[1]);
29  return (*(pc.base + p.o[0]));
30 #else
31  return (*(pc.base + p.l));
32 #endif
33  }
34  else {
35  rgen = pc.base + (x >> 3) + y*pc.bytpline;
36  for (plane = 3; plane >= 0; plane--) {
37  outpw(0x3ce,plane << 8 | 4);
38  latch = *rgen & bit_mask;
39  latch >>= bit_number;
40  color <<= 1;
41  color |= latch;
42  }
43  return (color);
44  }
45 }
46 
47 
48 
int MFBGetPixel(int x, int y)
Definition: mfbgetpx.c:13
int mfbMODE
Definition: mfbp.h:41
FILE * p
Definition: proc2mod.c:48
Definition: cddefs.h:312
Definition: cddefs.h:215
char * vidmptr
Definition: mfbp.h:17
int ysize
Definition: mfbp.h:54
vidmptr base
Definition: mfbp.h:38
Definition: cddefs.h:142
int xsize
Definition: mfbp.h:53
int bytpline
Definition: mfbp.h:39
struct mfbpc pc
Definition: mfbopen.c:14