1 /*********************************************************** 2 * K O U L E S * 3 *----------------------------------------------------------* 4 * C1995 JAHUSOFT * 5 * Jan Hubicka * 6 * Dukelskych Bojovniku 1944 * 7 * 390 03 Tabor * 8 * Czech Republic * 9 * Phone: 0041-0361-32613 * 10 * eMail: hubicka@limax.paru.cas.cz * 11 *----------------------------------------------------------* 12 * Copyright(c)1995,1996 by Jan Hubicka.See README for * 13 * licence details. * 14 *----------------------------------------------------------* 15 * interface.h interface for Xlib.h * 16 ***********************************************************/ 17 #include <X11/Xlib.h> 18 #include <X11/Xutil.h> 19 #include "inlstring.h" 20 #ifdef MITSHM 21 #include <sys/ipc.h> 22 #include <sys/shm.h> 23 #include <X11/extensions/XShm.h> 24 #endif 25 #include <input.h> 26 #define XSUPPORT 27 #define EYE_RADIUS (DIV==1?5:6) 28 #define MOUSE_RADIUS 4 29 #define WRITEMODE_OVERWRITE 0 30 #define WRITEMODE_MASKED 1 31 typedef struct 32 { 33 XImage *bitmap; 34 char *mask; 35 #ifdef MITSHM 36 int xsize; 37 char *vbuff; 38 #endif 39 } 40 RawBitmapType; 41 typedef struct 42 { 43 Pixmap bitmap, mask; 44 #ifdef MITSHM 45 unsigned char *vbuff; 46 #endif 47 } 48 BitmapType; 49 typedef struct 50 { 51 Pixmap pixmap; 52 #ifdef MITSHM 53 char *vbuff; 54 XImage *ximage; 55 #endif 56 } 57 VScreenType; 58 59 60 #ifndef PLATFORM_VARIABLES_HERE 61 #define WHERE extern 62 #else 63 #define WHERE 64 #endif 65 WHERE void *fontblack; 66 WHERE void *fontwhite; 67 WHERE int nofade; 68 WHERE int monochrome; 69 WHERE Colormap colormap; 70 WHERE int useprivate; 71 WHERE int fadeenable; 72 WHERE int nopause; 73 WHERE int shm; 74 WHERE int depth; 75 WHERE int notusedc; 76 WHERE int Clipping; 77 WHERE int GAMEWIDTH; 78 WHERE int GAMEHEIGHT; 79 WHERE int MAPWIDTH; 80 WHERE int MAPHEIGHT; 81 WHERE int DIV; 82 WHERE Pixmap screenpixmap; 83 WHERE VScreenType physicalscreen; 84 WHERE VScreenType backscreen; 85 WHERE VScreenType background; 86 WHERE VScreenType starbackground; 87 WHERE VScreenType current; 88 WHERE Display *dp; 89 WHERE Window wi; 90 WHERE XFontStruct *fs; 91 WHERE int screen; 92 WHERE int blackwhite; 93 WHERE int pixels[256]; 94 WHERE long rpixels[256]; 95 WHERE int notrealshm; 96 WHERE float spixels[256]; 97 WHERE float opixels[256]; 98 WHERE GC gc; 99 WHERE GC maskgc; 100 WHERE GC whitegc; 101 WHERE GC blackgc; 102 WHERE GC orgc; 103 #undef WHERE 104 105 106 #undef FastAccess 107 #define CharX 8 108 #define CharY 8 109 #define NODIRECT 110 #ifdef MITSHM 111 extern void ShmPutBitmap (int, int, int, int, void *); 112 extern int ShmBitmapSize (int, int, void *); 113 extern void ShmCompileBitmap (int, int, void *, void *); 114 extern void shmline (int, int, int, int, int); 115 extern void SetFont (int,int,void *); 116 extern void SetWriteMode(int); 117 extern void FWrite(int,int,char *); 118 extern void ExpandFont(int,int,int,void *,void *); 119 extern void DrawBlackMaskedText(int,int,char *); 120 extern void DrawWhiteMaskedText(int,int,char *); 121 extern void DrawText(int,int,char *); 122 123 #endif 124 125 extern void SetColor (int); 126 extern void SetWidth (int); 127 extern void SetStipple (int, int, Pixmap); 128 extern void UnSetStipple (); 129 extern void FlushParam (); 130 extern BitmapType CompileBitmap (int, int, RawBitmapType); 131 extern RawBitmapType CreateBitmap (int, int); 132 extern void PutBitmap (int, int, int, int, BitmapType); 133 extern void DrawRectangle (int, int, int, int, int); 134 extern void ClearScreen (); 135 extern void CopyVSToVS (VScreenType, VScreenType); 136 extern void CopyToScreen (VScreenType); 137 extern void DrawBlackMaskedText (int, int, char *); 138 extern void DrawWhiteMaskedText (int x, int y, char *); 139 extern void DrawText (int, int, char *); 140 141 /* 142 * unimplemented and unused functions: 143 */ 144 /*SetPalette(palette) #define SGetPixel(x,y) */ 145 /* 146 * unimplemented and used functions: 147 */ 148 #define WaitRetrace() dummy 149 150 /* 151 * fast interface macros: 152 */ 153 #define cpixels(color) pixels[(unsigned char)(color)] 154 #define FillRectangle(x,y,x1,y1,color) SetColor(color),XFillRectangle(dp,current.pixmap,gc,(int)(x),(int)(y),(int)(x1),(int)(y1)) 155 #define SetScreen(screen) (current=screen) 156 #define EnableClipping() Clipping=1 157 #define DisableClipping() Clipping=0 158 159 160 #ifndef MITSHM 161 #define DrawBlackMaskedText(xp,yp,text) XDrawString (dp, current.pixmap, blackgc, xp, yp + 7, text, strlen (text)) 162 #define DrawText(xp,yp,text) XDrawString (dp, current.pixmap, whitegc, xp, yp + 7, text, strlen (text)) 163 #define DrawWhiteMaskedText(xp,yp,text) XDrawString (dp, current.pixmap, whitegc, xp, yp + 7, text, strlen (text)) 164 #define BSetPixel(bitmap1,x1,y1,color) (XPutPixel ((XImage *)(bitmap1.bitmap), (int)(x1), (int)(y1), cpixels((color))),\ 165 (color?(*(bitmap1.mask+((int)(x1))/8+(y1*((bitmap1.bitmap->width+7)/8)))|=1<<(((int)(x1))%8)):0)) 166 #define SSetPixel(x1,y1,color) (SetColor(color),XDrawPoint(dp,current.pixmap,gc,(int)(x1),(int)(y1))) 167 #define HLine(x1,y1,x2,color) (SetColor(color),XDrawLine(dp,current.pixmap,gc,(int)(x1),(int)(y1),(int)(x2),(int)(y1))) 168 #define Line(x1,y1,x2,y2,color) (SetColor(color),XDrawLine(dp,current.pixmap,gc,(int)(x1),(int)(y1),(int)(x2),(int)(y2))) 169 170 #else 171 172 #define VScreenToBuffer(screen) screen.vbuff 173 #define BitmapToBuffer(bitmap) ((char *)bitmap.vbuff) 174 #define qSSetPixel(x1,y1,color) (SetColor(color),XDrawPoint(dp,current.pixmap,gc,(int)(x1),(int)(y1))) 175 #define qBSetPixel(bitmap1,x1,y1,color) (XPutPixel ((XImage *)(bitmap1.bitmap), (int)(x1), (int)(y1), cpixels((color))),\ 176 (color?(*(bitmap1.mask+((int)(x1))/8+(((int)y1)*((bitmap1.bitmap->width+7)/8)))|=1L<<(((int)(x1))%8)):0)) 177 #define qLine(x1,y1,x2,y2,color) (SetColor(color),XDrawLine(dp,current.pixmap,gc,(int)(x1),(int)(y1),(int)(x2),(int)(y2))) 178 extern void Line(int,int,int,int,int); 179 #define SMySetPixel(screen,x,y,color) *(VScreenToBuffer(screen)+(int)(x)+(((int)(y))>>8)*MAPWIDTH)=cpixels(color) 180 #define SSetPixel(x,y,color) (((int)shm)?(*(VScreenToBuffer(current)+(int)(x)+((int)(y))*MAPWIDTH)=cpixels(color)):(qSSetPixel(x,y,color))) 181 #define BSetPixel(bitmap1,x,y,color) (((int)shm)?(*(BitmapToBuffer(bitmap1)+(int)(x)+((int)(y))*(bitmap1).xsize)=color?cpixels(color):notusedc):(qBSetPixel(bitmap1,(int)x,(int)y,color))) 182 183 /*faster for font */ 184 #define SSetPixel1(x,y,color) (*(VScreenToBuffer(current)+(int)(x)+((int)(y))*MAPWIDTH)=cpixels(color)) 185 #define HLine1(x1,y1,x2,color) memset(VScreenToBuffer(current)+(int)(x1)+((int)(y1))*MAPWIDTH,cpixels(color),(int)(x2)-(int)(x1)) 186 #define HLine(x1,y1,x2,color) memset(VScreenToBuffer(current)+(int)(x1)+((int)(y1))*MAPWIDTH,cpixels(color),(int)(x2)-(int)(x1)) 187 #define FAST_WIDELINE 188 189 #endif 190 191