1 /*
2 Copyright (C) 1994-1995 Apogee Software, Ltd.
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13 See the GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 
19 */
20 //***************************************************************************
21 //
22 //    MODEXLIB.C - various utils palette funcs and modex stuff
23 //
24 //***************************************************************************
25 
26 #ifndef _modexlib_public
27 #define _modexlib_public
28 
29 #include "rt_def.h"
30 
31 #define MAXSCREENHEIGHT         200
32 #define MAXSCREENWIDTH          320
33 #define SCREENBWIDE             96
34 #define MAXVIEWWIDTH            320
35 #define SCREENWIDTH             96              // default screen width in bytes
36 
37 //***************************************************************************
38 //
39 //    Video (ModeX) Constants
40 //
41 //***************************************************************************
42 
43 #define SC_INDEX                0x3C4
44 #define SC_DATA                 0x3C5
45 #define SC_RESET                0
46 #define SC_CLOCK                1
47 #define SC_MAPMASK              2
48 #define SC_CHARMAP              3
49 #define SC_MEMMODE              4
50 
51 #define CRTC_INDEX              0x3D4
52 #define CRTC_DATA               0x3D5
53 #define CRTC_H_TOTAL            0
54 #define CRTC_H_DISPEND          1
55 #define CRTC_H_BLANK            2
56 #define CRTC_H_ENDBLANK         3
57 #define CRTC_H_RETRACE          4
58 #define CRTC_H_ENDRETRACE       5
59 #define CRTC_V_TOTAL            6
60 #define CRTC_OVERFLOW           7
61 #define CRTC_ROWSCAN            8
62 #define CRTC_MAXSCANLINE        9
63 #define CRTC_CURSORSTART        10
64 #define CRTC_CURSOREND          11
65 #define CRTC_STARTHIGH          12
66 #define CRTC_STARTLOW           13
67 #define CRTC_CURSORHIGH         14
68 #define CRTC_CURSORLOW          15
69 #define CRTC_V_RETRACE          16
70 #define CRTC_V_ENDRETRACE       17
71 #define CRTC_V_DISPEND          18
72 #define CRTC_OFFSET             19
73 #define CRTC_UNDERLINE          20
74 #define CRTC_V_BLANK            21
75 #define CRTC_V_ENDBLANK         22
76 #define CRTC_MODE               23
77 #define CRTC_LINECOMPARE        24
78 
79 #define GC_INDEX                0x3CE
80 #define GC_DATA                 0x3CF
81 #define GC_SETRESET             0
82 #define GC_ENABLESETRESET       1
83 #define GC_COLORCOMPARE         2
84 #define GC_DATAROTATE           3
85 #define GC_READMAP              4
86 #define GC_MODE                 5
87 #define GC_MISCELLANEOUS        6
88 #define GC_COLORDONTCARE        7
89 #define GC_BITMASK              8
90 
91 #define ATR_INDEX               0x3c0
92 #define ATR_MODE                16
93 #define ATR_OVERSCAN            17
94 #define ATR_COLORPLANEENABLE      18
95 #define ATR_PELPAN              19
96 #define ATR_COLORSELECT         20
97 
98 #define STATUS_REGISTER_1       0x3da
99 
100 #define PEL_WRITE_ADR           0x3c8
101 #define PEL_READ_ADR            0x3c7
102 #define PEL_DATA                0x3c9
103 
104 
105 extern  int      ylookup[MAXSCREENHEIGHT];      // Table of row offsets
106 extern  int      linewidth;
107 extern  int      page1start;
108 extern  int      page2start;
109 extern  int      page3start;
110 extern  int      screensize;
111 extern  unsigned bufferofs;
112 extern  unsigned displayofs;
113 extern  boolean  graphicsmode;
114 
115 
116 void  GraphicsMode ( void );
117 void  SetTextMode ( void );
118 void  VL_SetVGAPlaneMode ( void );
119 void  VL_ClearBuffer (unsigned buf, byte color);
120 void  VL_ClearVideo (byte color);
121 void  VL_DePlaneVGA (void);
122 void  VL_CopyDisplayToHidden ( void );
123 void  VL_CopyBufferToAll ( unsigned buffer );
124 void  VL_CopyPlanarPage ( byte * src, byte * dest );
125 void  VL_CopyPlanarPageToMemory ( byte * src, byte * dest );
126 void  XFlipPage ( void );
127 void  WaitVBL( void );
128 void  TurnOffTextCursor ( void );
129 
130 #ifdef __WATCOMC__
131 #pragma aux VGAWRITEMAP =      \
132         "mov    eax,01H"       \
133         "mov    edx,03c5h"     \
134         "shl    eax,cl"        \
135         "out    dx,al"         \
136         parm    [ecx]          \
137         modify exact [eax edx]
138 
139 #pragma aux VGAMAPMASK =       \
140         "mov    edx,03c5h"     \
141         "out    dx,al"         \
142         parm    [eax]          \
143         modify exact [edx]
144 
145 #pragma aux VGAREADMAP =      \
146         "shl    eax,08H"      \
147         "mov    edx,03ceh"    \
148         "add    eax,04H"      \
149         "out    dx,ax"        \
150         parm    [eax]         \
151         modify exact [eax edx]
152 #endif
153 
154 #ifdef DOS
155 void  VGAMAPMASK (int x);
156 void  VGAREADMAP (int x);
157 void  VGAWRITEMAP(int x);
158 #else
159 #define VGAMAPMASK(a)
160 #define VGAREADMAP(a)
161 #define VGAWRITEMAP(a)
162 #endif
163 
164 #endif
165