1 /**
2  ** BCC2GRX  -  Interfacing Borland based graphics programs to LIBGRX
3  ** Copyright (C) 1993-97 by Hartmut Schirmer
4  **
5  **
6  ** Contact :                Hartmut Schirmer
7  **                          Feldstrasse 118
8  **                  D-24105 Kiel
9  **                          Germany
10  **
11  ** e-mail : hsc@techfak.uni-kiel.de
12  **
13  ** This file is part of the GRX graphics library.
14  **
15  ** The GRX graphics library is free software; you can redistribute it
16  ** and/or modify it under some conditions; see the "copying.grx" file
17  ** for details.
18  **
19  ** This library is distributed in the hope that it will be useful,
20  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22  **
23  **/
24 
25 #include "bccgrx00.h"
26 
27 #if 0
28 /* The following io routines were taken from Csaba Biegl's
29    GRX v2.0  source. Many thanks Csaba ! */
30 #define __INLINE_LOW_PORT_TEST__(P)  (                  \
31     (__builtin_constant_p((P))) &&                      \
32     ((unsigned)(P) < 0x100U)                            \
33 )
34 #define inportb(P) ({                                   \
35     register unsigned char _value;                      \
36     if(__INLINE_LOW_PORT_TEST__(P)) __asm__ volatile(   \
37 	"inb %1,%0"                                     \
38 	: "=a"  (_value)                                \
39 	: "n"   ((unsigned short)(P))                   \
40     );                                                  \
41     else __asm__ volatile(                              \
42 	"inb %1,%0"                                     \
43 	: "=a"  (_value)                                \
44 	: "d"   ((unsigned short)(P))                   \
45     );                                                  \
46     _value;                                             \
47 })
48 
49 #define outportb(p,v) ({                                \
50     __asm__ volatile(                                   \
51 	"outb %0,%1"                                    \
52 	: /* no outputs */                              \
53 	: "a" ((unsigned char)(v)),                     \
54 	  "d" ((unsigned short)(p))                     \
55     );                                                  \
56 })
57 
58 static volatile int dummy;
59 
60 #define WAIT() do {               \
61   dummy += inportb(0x80);         \
62 } while(0)
63 
64 void __getrgbpalette(int color, int *red, int *green, int *blue) {
65 #ifdef GO32
66   _DO_INIT_CHECK;
67   WAIT();
68   outportb(0x3c8, color&0xff);
69   WAIT();
70   *red = inportb(0x3c9)<<2;
71   WAIT();
72   *green = inportb(0x3c9)<<2;
73   WAIT();
74   *blue = inportb(0x3c9)<<2;
75 #else
76   *red = *green = *blue = 0;
77 #endif
78 }
79 
80 #else
__getrgbpalette(int color,int * red,int * green,int * blue)81 void __getrgbpalette(int color, int *red, int *green, int *blue) {
82   GrQueryColor(color,red,green,blue);
83 }
84 #endif
85