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 *        Telefon: (048-I think) (0361) 32613               *
10 *        eMail: hubicka@limax.paru.cas.cz                  *
11 *----------------------------------------------------------*
12 * Copyright(c)1995,96 by Jan Hubicka &                     *
13 *              Thomas A. K. Kjaer See README for license   *
14 *                             details.                     *
15 *----------------------------------------------------------*
16 * interface.h interface for OS/2 Warp 3.0 & DIVE           *
17 ***********************************************************/
18 #define INCL_DOS
19 #define INCL_GPI
20 #define INCL_WIN
21 #include <os2.h>
22 #define  _MEERROR_H_
23 #include <mmioos2.h>                   /* It is from MMPM toolkit           */
24 #include <dive.h>
25 #include <fourcc.h>
26 #include "input.h"
27 #include <vga.h>
28 #include <vgagl.h>
29 
30 #define WaitRetrace() vga_waitretrace()
31 #define WAIT 1
32 #define usleep(s) DosSleep((s)/1000)
33 
34 #define EYE_RADIUS (DIV==1?5:6)
35 #define MOUSE_RADIUS 4
36 
37 typedef PBYTE RawBitmapType;
38 typedef PBYTE BitmapType;
39 typedef GraphicsContext *VScreenType;
40 
41 #ifndef PLATFORM_VARIABLES_HERE
42 extern int      GAMEWIDTH;
43 extern int      GAMEHEIGHT;
44 extern int      MAPWIDTH;
45 extern int      MAPHEIGHT;
46 extern int      DIV;
47 
48 extern void    *fontblack;
49 extern void    *fontwhite;
50 extern VScreenType physicalscreen;
51 extern VScreenType backscreen;
52 extern VScreenType background;
53 extern VScreenType starbackground;
54 
55 #define VScreenToBuffer(screen) (screen)->vbuf
56 
57 #define SMySetPixel(screen,x,y,color) \
58 *(VScreenToBuffer(screen)+(int)(x)+\
59 (((((int)(y)>>8))*MAPWIDTH)))=color
60 
61 #define SetScreen(screen) gl_setcontext (screen)
62 #define SSetPixel(x,y,color) gl_setpixel(x,y,color)
63 
64 #define Line(x1,y1,x2,y2,color) gl_line((x1),(y1),(x2),(y2),(color))
65 
66 #define PutBitmap(x,y,xsize,ysize,bitmap) \
67 gl_putboxmaskcompiled((x),(y),(xsize),(ysize),(bitmap))
68 
69 #define SetPalette(palette) gl_setpalette (palette)
70 
71 #define EnableClipping() gl_enableclipping()
72 #define DisableClipping() gl_disableclipping()
73 
74 extern inline void
DrawBlackMaskedText(int x,int y,char * text)75 DrawBlackMaskedText (int x, int y, char *text)
76 {
77   gl_setwritemode (WRITEMODE_MASKED);
78   gl_setfont (8, 8, fontblack);
79   gl_write (x, y, text);
80 }
81 extern inline void
DrawWhiteMaskedText(int x,int y,char * text)82 DrawWhiteMaskedText (int x, int y, char *text)
83 {
84   gl_setwritemode (WRITEMODE_MASKED);
85   gl_setfont (8, 8, fontwhite);
86   gl_write (x, y, text);
87 }
88 extern inline void
DrawText(int x,int y,char * text)89 DrawText (int x, int y, char *text)
90 {
91   gl_setwritemode (WRITEMODE_OVERWRITE);
92   gl_setfont (8, 8, fontwhite);
93   gl_write (x, y, text);
94 }
95 
DrawRectangle(int x1,int y1,int x2,int y2,int color)96 extern inline void  DrawRectangle(int x1, int y1, int x2, int y2, int color)
97 {
98   gl_line ((int) x1, (int) y1, (int) x1, (int) y2, color);
99   gl_line ((int) x1, (int) y2, (int) x2, (int) y2, color);
100   gl_line ((int) x2, (int) y2, (int) x2, (int) y1, color);
101   gl_line ((int) x2, (int) y1, (int) x1, (int) y1, color);
102 }
103 
CompileBitmap(int x,int y,BYTE * bitmap)104 extern inline BYTE*CompileBitmap(int x, int y, BYTE *bitmap)
105 {
106     int size1;
107     BYTE *cbitmap;
108 
109     size1 = gl_compiledboxmasksize(x,y,bitmap);
110     if ((cbitmap = malloc(size1)) == NULL)
111       perror("create_bitmap"), exit(1);
112 
113     gl_compileboxmask(x,y,bitmap,cbitmap);
114     return (cbitmap);
115 }
116 
117 #define FillRectangle(x,y,x1,y1,color) gl_fillbox((x),(y),(x1),(y1),(color))
118 
119 #define ClearScreen() gl_clearscreen (0)
120 extern inline void
CopyVSToVS(VScreenType source,VScreenType destination)121 CopyVSToVS (VScreenType source, VScreenType destination)
122 {
123   SetScreen (source);
124   gl_copyscreen (destination);
125 }
126 extern inline void
CopyToScreen(VScreenType source)127 CopyToScreen (VScreenType source)
128 {
129 /*  O.K. we are cheating. It saves us for 1 screen copy. */
130 /*  SetScreen (source);
131     gl_copyscreen (physicalscreen);
132 */
133     forceBlitting();
134 }
135 
136 #define CharX 8
137 #define CharY 8
138 #define FAST_WIDELINE
139 #endif
140