ReactOS  0.4.13-dev-698-g77671f0
hercules.c
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) 1998-2001 Klaus P. Gerlicher
4 
5 Module Name:
6 
7  hercules.c
8 
9 Abstract:
10 
11  HW dependent draw routines
12 
13 Environment:
14 
15  Kernel mode only
16 
17 Author:
18 
19  Klaus P. Gerlicher
20 
21 Revision History:
22 
23  04-Aug-1998: created
24  15-Nov-2000: general cleanup of source files
25 
26 Copyright notice:
27 
28  This file may be distributed under the terms of the GNU Public License.
29 
30 --*/
31 
33 // INCLUDES
35 #include "remods.h"
36 #include "precomp.h"
37 
38 #include "charset.h"
39 #include "logo.h"
40 
42 // PROTOTYPES
44 
46 // DEFINES
48 
50 // GLOBALS
52 // cursor state
54 
55 // HERCULES graphics adapter stuff
56 // 43 line graphics mode
57 UCHAR MGATable43[]={53,45,46, 7,96, 2,91,91, 2, 3, 0, 0, 0, 0, 0, 0};
58 
60 // END of HERCULES graphics adapter stuff
61 
62 // used for HERCULES graphics mode
64 {
65  {1,3,1,0,FALSE},
66  {5,6,1,0,FALSE},
67  {12,19,1,0,FALSE},
68  {32,12,1,0,FALSE}
69 };
70 // used for HERCUELS text and VGA text mode
72 {
73  {1,3,1,0,FALSE},
74  {5,4,1,0,FALSE},
75  {10,9,1,0,FALSE},
76  {20,4,1,0,FALSE}
77 };
78 
80 
81 struct _attr
82 {
83  union
84  {
85  struct
86  {
87 
88  UCHAR fgcol : 4;
89  UCHAR bkcol : 3;
90  UCHAR blink : 1;
91  }bits;
93  }u;
94 }attr;
95 
96 //*************************************************************************
97 // SetForegroundColorVga()
98 //
99 //*************************************************************************
101 {
102  attr.u.bits.fgcol = col;
103  attr.u.bits.blink = 0;
104 }
105 
106 //*************************************************************************
107 // SetBackgroundColorVga()
108 //
109 //*************************************************************************
111 {
112  attr.u.bits.bkcol = col;
113  attr.u.bits.blink = 0;
114 }
115 
116 //*************************************************************************
117 // PrintGrafHercules()
118 //
119 //*************************************************************************
121 {
122  ULONG i;
123  PUCHAR p;
124  ULONG _line = y<<3;
125 
127  return;
128 
129  p=&cGraphTable[(ULONG)c<<3];
130 
131  if((attr.u.bits.bkcol == COLOR_FOREGROUND && attr.u.bits.fgcol == COLOR_BACKGROUND) ||
132  (attr.u.bits.bkcol == COLOR_CAPTION && attr.u.bits.fgcol == COLOR_TEXT) )
133  for(i=0 ;i<8 ;i++,_line++)
134  {
135  *(PUCHAR)(pVgaOffset[_line & 0x3] + ( 90* (_line >> 2) ) + x) = ~*p++;
136  }
137  else
138  for(i=0 ;i<8 ;i++,_line++)
139  {
140  *(PUCHAR)(pVgaOffset[_line & 0x3] + ( 90* (_line >> 2) ) + x) = *p++;
141  }
142 }
143 
144 
145 //*************************************************************************
146 // FlushHercules()
147 //
148 //*************************************************************************
149 void FlushHercules(void)
150 {
151 }
152 
153 //*************************************************************************
154 // ShowCursor()
155 //
156 // show hardware cursor
157 //*************************************************************************
159 {
160  ENTER_FUNC();
161 
163 
164  LEAVE_FUNC();
165 }
166 
167 //*************************************************************************
168 // HideCursorHercules()
169 //
170 // hide hardware cursor
171 //*************************************************************************
173 {
174  ENTER_FUNC();
175 
177 
178  LEAVE_FUNC();
179 }
180 
181 //*************************************************************************
182 // CopyLineTo()
183 //
184 // copy a line from src to dest
185 //*************************************************************************
187 {
188  USHORT i,j;
189  PULONG pDest,pSrc;
190 
191  ENTER_FUNC();
192 
193  dest <<= 3;
194  src <<= 3;
195  for(i=0;i<8;i++)
196  {
197  (PUCHAR)pDest = (PUCHAR)pScreenBufferHercules + ( ( ( dest+i )&3) <<13 )+ 90 * ((dest+i) >> 2);
198  (PUCHAR)pSrc = (PUCHAR)pScreenBufferHercules + ( ( ( src+i )&3) <<13 )+ 90 * ((src+i) >> 2);
199  for(j=0;j<(GLOBAL_SCREEN_WIDTH>>2);j++)
200  {
201  *pDest++=*pSrc++;
202  }
203  }
204 
205  LEAVE_FUNC();
206 }
207 
208 //*************************************************************************
209 // InvertLineHercules()
210 //
211 // invert a line on the screen
212 //*************************************************************************
214 {
215  ULONG i,j;
216  ULONG _line = line<<3;
217  PUSHORT p;
218 
219  //ENTER_FUNC();
220 
221  for(j=0;j<8;j++)
222  {
223  p=(PUSHORT)( pVgaOffset[_line&3] + (90*(_line>>2)) );
224  for(i=0;i<(GLOBAL_SCREEN_WIDTH>>1);i++)
225  {
226  p[i]=~p[i];
227  }
228  _line++;
229  }
230 
231  //LEAVE_FUNC();
232 }
233 
234 //*************************************************************************
235 // HatchLineHercules()
236 //
237 // hatches a line on the screen
238 //*************************************************************************
240 {
241  USHORT cc;
242  ULONG i,j;
243  ULONG _line = (line<<3) ;
244  PUSHORT p;
245  USHORT mask_odd[]={0x8888,0x2222};
246  USHORT mask_even[]={0xaaaa,0x5555};
247  PUSHORT pmask;
248 
249  ENTER_FUNC();
250 
251  pmask = (line&1)?mask_odd:mask_even;
252 
253  for(j=0;j<8;j++,_line++)
254  {
255  p=(PUSHORT)( pVgaOffset[_line&3] + (90*(_line>>2)) );
256  for(i=0;i<(GLOBAL_SCREEN_WIDTH/sizeof(USHORT));i++)
257  {
258  cc = p[i];
259 
260  p[i]=(p[i]^pmask[j&1])|cc;
261  }
262  }
263 
264  LEAVE_FUNC();
265 }
266 
267 //*************************************************************************
268 // ClrLineHercules()
269 //
270 // clear a line on the screen
271 //*************************************************************************
273 {
274  ULONG j;
275  BOOLEAN bTemplateLine=( (USHORT)line==wWindow[DATA_WINDOW].y-1 ||
278  0);
279  ULONG _line = line<<3;
280  ULONG cc=0;
281  PUCHAR p;
282 
283 // ENTER_FUNC();
284 
286  {
287  DPRINT((0,"ClrLineHercules(): line %u is out of screen\n",line));
288  //LEAVE_FUNC();
289  return;
290  }
291 
292  if(attr.u.bits.bkcol == COLOR_CAPTION && attr.u.bits.fgcol == COLOR_TEXT )
293  cc=~cc;
294 
295  if(bTemplateLine)
296  {
297  for(j=0;j<8;j++,_line++)
298  {
299  p = (PUCHAR)(pVgaOffset[_line&3] + (90*(_line>>2)) );
300 
301 /*
302  if(j==2 || j==5)cc=0xFF;
303  else if(j==3)cc=0xaa;
304  else if(j==4)cc=0x55;
305  else cc = 0;*/
306  if(j==2 || j==5)cc=0xFF;
307  else cc = 0;
308 
310  }
311  }
312  else
313  {
314  for(j=0;j<8;j++,_line++)
315  {
316  p = (PUCHAR)(pVgaOffset[_line&3] + (90*(_line>>2)) );
317 
319  }
320  }
321  //LEAVE_FUNC();
322 }
323 
324 //*************************************************************************
325 // PrintLogoHercules()
326 //
327 //*************************************************************************
329 {
330  LONG x,y;
331  PUCHAR p;
332 
334  for(y=0;y<24;y++)
335  {
336  for(x=0;x<8;x++)
337  {
338  p[ ( 0x2000* (( y + 8 ) & 0x3) )+
339  ( 90* ( (y + 8 ) >> 2) )+
340  (81+x)] = cLogo[y*8+x];
341  }
342  }
343 }
344 
345 //*************************************************************************
346 // PrintCursorHercules()
347 //
348 // emulate a blinking cursor block
349 //*************************************************************************
351 {
352  static ULONG count=0;
353 
354  if( (bForce) || ((count++>100) && bCursorEnabled) )
355  {
356  ULONG i;
357  ULONG x,y;
358  ULONG _line;
359 
362 
363  _line = y<<3;
364  for(i=0;i<8;i++,_line++)
365  {
366  *(PUCHAR)(pVgaOffset[_line & 0x3] + ( 90* (_line >> 2) ) + x) ^= 0xFF ;
367  }
368  bRev=!bRev;
369  count=0;
370  }
371 
373 }
374 
375 //*************************************************************************
376 // SaveGraphicsHercules()
377 //
378 //*************************************************************************
380 {
381  // not implemented
382 }
383 
384 //*************************************************************************
385 // RestoreGraphicsStateHercules()
386 //
387 //*************************************************************************
389 {
390  // not implemented
391 }
392 
393 //*************************************************************************
394 // ConsoleInitHercules()
395 //
396 // init terminal screen
397 //*************************************************************************
399 {
400  BOOLEAN bResult = FALSE;
401  PUCHAR pMGATable = MGATable43;
402  UCHAR i,reg,data;
404 
405  ENTER_FUNC();
406 
421 
424 
425  // init HERCULES adapter
426  outb_p(0,0x3b8);
427  outb_p(0x03,0x3bf);
428  for(i=0;i<sizeof(MGATable43);i++)
429  {
430  reg=i;
431  outb_p(reg,0x3b4);
432  data=pMGATable[i];
433  outb_p(data,0x3b5);
434  }
435  outb_p(0x0a,0x3b8);
436 
438 
439  GLOBAL_SCREEN_WIDTH = 90;
441 
442  attr.u.Asuchar = 0x07;
443  FrameBuffer.u.LowPart = 0xb0000;
445 
446  DPRINT((0,"VGA memory phys. 0xb0000 mapped to virt. 0x%x\n",pScreenBufferHercules));
447 
449  {
450  for(i=0;i<4;i++)
451  {
453  DPRINT((0,"VGA offset %u = 0x%.8X\n",i,pVgaOffset[i]));
454  }
455  bResult = TRUE;
456 
458 
459  EmptyRingBuffer();
460 
461  DPRINT((0,"ConsoleInitHercules() SUCCESS!\n"));
462  }
463 
464  LEAVE_FUNC();
465 
466  return bResult;
467 }
468 
469 //*************************************************************************
470 // ConsoleShutdownHercules()
471 //
472 // exit terminal screen
473 //*************************************************************************
475 {
476  ENTER_FUNC();
477 
478  // HERC video off
479  outb_p(0,0x3b8);
480  outb_p(0,0x3bf);
481 
484 
485  LEAVE_FUNC();
486 }
void(* PrintLogo)(BOOLEAN bShow)
Definition: hardware.h:47
BOOLEAN bCursorEnabled
Definition: hardware.c:51
void KeyboardFlushKeyboardQueue(void)
Definition: utils.c:1455
PUCHAR pScreenBufferHercules
Definition: hercules.c:79
WINDOW wWindowHerc[4]
Definition: hercules.c:71
#define TRUE
Definition: types.h:120
void InvertLineHercules(ULONG line)
Definition: hercules.c:213
void SetWindowGeometry(PVOID pWindow)
Definition: hardware.c:915
GLint x0
Definition: linetemp.h:95
void EmptyRingBuffer(void)
Definition: hardware.c:104
void(* FlushKeyboardQueue)(void)
Definition: hardware.h:61
ULONG GLOBAL_SCREEN_WIDTH
Definition: hardware.c:62
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned char * PUCHAR
Definition: retypes.h:3
UCHAR Asuchar
Definition: hercules.c:92
ULONG GLOBAL_SCREEN_HEIGHT
Definition: hardware.c:62
void(* HideCursor)(void)
Definition: hardware.h:52
void CopyLineToHercules(USHORT dest, USHORT src)
Definition: hercules.c:186
void SetBackgroundColorHercules(ECOLORS col)
Definition: hercules.c:110
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
#define LEAVE_FUNC()
Definition: debug.h:43
BOOLEAN bRev
Definition: hercules.c:53
PVOID NTAPI MmMapIoSpace(IN PHYSICAL_ADDRESS PhysicalAddress, IN SIZE_T NumberOfBytes, IN MEMORY_CACHING_TYPE CacheType)
Definition: iosup.c:47
WINDOW wWindowHercGraph[4]
Definition: hercules.c:63
#define FRAMEBUFFER_SIZE
Definition: precomp.h:31
void(* SetBackgroundColor)(ECOLORS)
Definition: hardware.h:54
void PrintGrafHercules(ULONG x, ULONG y, UCHAR c)
Definition: hercules.c:120
void(* SetForegroundColor)(ECOLORS)
Definition: hardware.h:53
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
void outb_p(UCHAR data, PUCHAR port)
Definition: utils.c:2159
void PrintCursorHercules(BOOLEAN bForce)
Definition: hercules.c:350
void(* ClrLine)(ULONG line)
Definition: hardware.h:44
void(* RestoreGraphicsState)(void)
Definition: hardware.h:50
unsigned char BOOLEAN
UCHAR cGraphTable[8 *256]
Definition: charset.h:3
#define COLOR_TEXT
Definition: hardware.h:158
void PrintLogoHercules(BOOLEAN bShow)
Definition: hercules.c:328
Definition: parser.c:48
void DPRINT(...)
Definition: polytest.cpp:61
void ShowCursorHercules(void)
Definition: hercules.c:158
void HideCursorHercules(void)
Definition: hercules.c:172
WINDOW wWindow[4]
Definition: hardware.c:59
OUTPUT_HANDLERS ohandlers
Definition: hardware.c:65
UCHAR bkcol
Definition: hercules.c:89
UCHAR(* GetKeyPolled)(void)
Definition: hardware.h:60
#define COLOR_FOREGROUND
Definition: hardware.h:160
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
void(* PrintGraf)(ULONG x, ULONG y, UCHAR c)
Definition: hardware.h:42
INPUT_HANDLERS ihandlers
Definition: hardware.c:66
PUCHAR pVgaOffset[4]
Definition: hercules.c:59
void(* PrintCursor)(BOOLEAN bForce)
Definition: hardware.h:48
const GLubyte * c
Definition: glext.h:8905
void(* ShowCursor)(void)
Definition: hardware.h:51
enum _ECOLORS ECOLORS
Definition: cookie.c:170
void SetForegroundColorHercules(ECOLORS col)
Definition: hercules.c:100
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
unsigned char UCHAR
Definition: xmlstorage.h:181
void SaveGraphicsStateHercules(void)
Definition: hercules.c:379
USHORT y
Definition: hardware.h:33
struct _attr attr
void(* Flush)(void)
Definition: hardware.h:43
void(* SaveGraphicsState)(void)
Definition: hardware.h:49
GLenum src
Definition: glext.h:6340
void(* HatchLine)(ULONG line)
Definition: hardware.h:46
void ConsoleShutdownHercules(void)
Definition: hercules.c:474
static PVOID FrameBuffer
Definition: xboxvideo.c:27
void RestoreGraphicsStateHercules(void)
Definition: hercules.c:388
uint32_t cc
Definition: isohybrid.c:75
union _attr::@1528 u
UCHAR cLogo[96]
Definition: logo.h:3
unsigned short USHORT
Definition: pedump.c:61
USHORT usCurX
Definition: hardware.h:34
VOID NTAPI MmUnmapIoSpace(IN PVOID BaseAddress, IN SIZE_T NumberOfBytes)
Definition: iosup.c:193
unsigned int * PULONG
Definition: retypes.h:1
USHORT usCurY
Definition: hardware.h:34
void(* CopyLineTo)(USHORT dest, USHORT src)
Definition: hardware.h:41
static int reg
Definition: i386-dis.c:1275
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
void(* InvertLine)(ULONG line)
Definition: hardware.h:45
Definition: hercules.c:81
UCHAR MGATable43[]
Definition: hercules.c:57
unsigned int ULONG
Definition: retypes.h:1
#define ENTER_FUNC()
Definition: debug.h:42
static char * dest
Definition: rtl.c:135
#define COLOR_BACKGROUND
Definition: hardware.h:164
UCHAR KeyboardGetKeyPolled(void)
Definition: utils.c:1375
GLfloat GLfloat p
Definition: glext.h:8902
void ClrLineHercules(ULONG line)
Definition: hercules.c:272
void HatchLineHercules(ULONG line)
Definition: hercules.c:239
#define COLOR_CAPTION
Definition: hardware.h:156
UCHAR blink
Definition: hercules.c:90
struct _attr::@1528::@1529 bits
unsigned short * PUSHORT
Definition: retypes.h:2
VOID NTAPI KeStallExecutionProcessor(IN ULONG MicroSeconds)
Definition: ntoskrnl.c:99
void FlushHercules(void)
Definition: hercules.c:149
void PICE_memset(void *p, unsigned char c, int sz)
Definition: utils.c:228
UCHAR fgcol
Definition: hercules.c:88
BOOLEAN ConsoleInitHercules(void)
Definition: hercules.c:398