3 Copyright (c) 1998-2001 Klaus P. Gerlicher
11 HW dependent draw routines
24 15-Nov-2000: general cleanup of source files
28 This file may be distributed under the terms of the GNU Public License.
32 ////////////////////////////////////////////////////
41 ////////////////////////////////////////////////////
45 ////////////////////////////////////////////////////
49 ////////////////////////////////////////////////////
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};
60 // END of HERCULES graphics adapter stuff
62 // used for HERCULES graphics mode
63 WINDOW wWindowHercGraph[4]=
70 // used for HERCUELS text and VGA text mode
71 WINDOW wWindowHerc[4]=
79 PUCHAR pScreenBufferHercules;
96 //*************************************************************************
97 // SetForegroundColorVga()
99 //*************************************************************************
100 void SetForegroundColorHercules(ECOLORS col)
102 attr.u.bits.fgcol = col;
103 attr.u.bits.blink = 0;
106 //*************************************************************************
107 // SetBackgroundColorVga()
109 //*************************************************************************
110 void SetBackgroundColorHercules(ECOLORS col)
112 attr.u.bits.bkcol = col;
113 attr.u.bits.blink = 0;
116 //*************************************************************************
117 // PrintGrafHercules()
119 //*************************************************************************
120 void PrintGrafHercules(ULONG x,ULONG y,UCHAR c)
126 if(!pScreenBufferHercules)
129 p=&cGraphTable[(ULONG)c<<3];
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++)
135 *(PUCHAR)(pVgaOffset[_line & 0x3] + ( 90* (_line >> 2) ) + x) = ~*p++;
138 for(i=0 ;i<8 ;i++,_line++)
140 *(PUCHAR)(pVgaOffset[_line & 0x3] + ( 90* (_line >> 2) ) + x) = *p++;
145 //*************************************************************************
148 //*************************************************************************
149 void FlushHercules(void)
153 //*************************************************************************
156 // show hardware cursor
157 //*************************************************************************
158 void ShowCursorHercules(void)
167 //*************************************************************************
168 // HideCursorHercules()
170 // hide hardware cursor
171 //*************************************************************************
172 void HideCursorHercules(void)
176 bCursorEnabled=FALSE;
181 //*************************************************************************
184 // copy a line from src to dest
185 //*************************************************************************
186 void CopyLineToHercules(USHORT dest,USHORT src)
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++)
208 //*************************************************************************
209 // InvertLineHercules()
211 // invert a line on the screen
212 //*************************************************************************
213 void InvertLineHercules(ULONG line)
216 ULONG _line = line<<3;
223 p=(PUSHORT)( pVgaOffset[_line&3] + (90*(_line>>2)) );
224 for(i=0;i<(GLOBAL_SCREEN_WIDTH>>1);i++)
234 //*************************************************************************
235 // HatchLineHercules()
237 // hatches a line on the screen
238 //*************************************************************************
239 void HatchLineHercules(ULONG line)
243 ULONG _line = (line<<3) ;
245 USHORT mask_odd[]={0x8888,0x2222};
246 USHORT mask_even[]={0xaaaa,0x5555};
251 pmask = (line&1)?mask_odd:mask_even;
253 for(j=0;j<8;j++,_line++)
255 p=(PUSHORT)( pVgaOffset[_line&3] + (90*(_line>>2)) );
256 for(i=0;i<(GLOBAL_SCREEN_WIDTH/sizeof(USHORT));i++)
260 p[i]=(p[i]^pmask[j&1])|cc;
267 //*************************************************************************
270 // clear a line on the screen
271 //*************************************************************************
272 void ClrLineHercules(ULONG line)
275 BOOLEAN bTemplateLine=( (USHORT)line==wWindow[DATA_WINDOW].y-1 ||
276 (USHORT)line==wWindow[SOURCE_WINDOW].y-1 ||
277 (USHORT)line==wWindow[OUTPUT_WINDOW].y-1 ||
279 ULONG _line = line<<3;
285 if(line > GLOBAL_SCREEN_HEIGHT )
287 DPRINT((0,"ClrLineHercules(): line %u is out of screen\n",line));
292 if(attr.u.bits.bkcol == COLOR_CAPTION && attr.u.bits.fgcol == COLOR_TEXT )
297 for(j=0;j<8;j++,_line++)
299 p = (PUCHAR)(pVgaOffset[_line&3] + (90*(_line>>2)) );
302 if(j==2 || j==5)cc=0xFF;
303 else if(j==3)cc=0xaa;
304 else if(j==4)cc=0x55;
306 if(j==2 || j==5)cc=0xFF;
309 PICE_memset(p,(UCHAR)cc,GLOBAL_SCREEN_WIDTH);
314 for(j=0;j<8;j++,_line++)
316 p = (PUCHAR)(pVgaOffset[_line&3] + (90*(_line>>2)) );
318 PICE_memset(p,(UCHAR)cc,GLOBAL_SCREEN_WIDTH);
324 //*************************************************************************
325 // PrintLogoHercules()
327 //*************************************************************************
328 void PrintLogoHercules(BOOLEAN bShow)
333 p=(PUCHAR)pScreenBufferHercules;
338 p[ ( 0x2000* (( y + 8 ) & 0x3) )+
339 ( 90* ( (y + 8 ) >> 2) )+
340 (81+x)] = cLogo[y*8+x];
345 //*************************************************************************
346 // PrintCursorHercules()
348 // emulate a blinking cursor block
349 //*************************************************************************
350 void PrintCursorHercules(BOOLEAN bForce)
352 static ULONG count=0;
354 if( (bForce) || ((count++>100) && bCursorEnabled) )
360 x=wWindow[OUTPUT_WINDOW].usCurX;
361 y=wWindow[OUTPUT_WINDOW].y+wWindow[OUTPUT_WINDOW].usCurY;
364 for(i=0;i<8;i++,_line++)
366 *(PUCHAR)(pVgaOffset[_line & 0x3] + ( 90* (_line >> 2) ) + x) ^= 0xFF ;
372 KeStallExecutionProcessor(2500);
375 //*************************************************************************
376 // SaveGraphicsHercules()
378 //*************************************************************************
379 void SaveGraphicsStateHercules(void)
384 //*************************************************************************
385 // RestoreGraphicsStateHercules()
387 //*************************************************************************
388 void RestoreGraphicsStateHercules(void)
393 //*************************************************************************
394 // ConsoleInitHercules()
396 // init terminal screen
397 //*************************************************************************
398 BOOLEAN ConsoleInitHercules(void)
400 BOOLEAN bResult = FALSE;
401 PUCHAR pMGATable = MGATable43;
403 PHYSICAL_ADDRESS FrameBuffer;
407 ohandlers.CopyLineTo = CopyLineToHercules;
408 ohandlers.PrintGraf = PrintGrafHercules;
409 ohandlers.Flush = FlushHercules;
410 ohandlers.ClrLine = ClrLineHercules;
411 ohandlers.InvertLine = InvertLineHercules;
412 ohandlers.HatchLine = HatchLineHercules;
413 ohandlers.PrintLogo = PrintLogoHercules;
414 ohandlers.PrintCursor = PrintCursorHercules;
415 ohandlers.SaveGraphicsState = SaveGraphicsStateHercules;
416 ohandlers.RestoreGraphicsState = RestoreGraphicsStateHercules;
417 ohandlers.ShowCursor = ShowCursorHercules;
418 ohandlers.HideCursor = HideCursorHercules;
419 ohandlers.SetForegroundColor = SetForegroundColorHercules;
420 ohandlers.SetBackgroundColor = SetBackgroundColorHercules;
422 ihandlers.GetKeyPolled = KeyboardGetKeyPolled;
423 ihandlers.FlushKeyboardQueue = KeyboardFlushKeyboardQueue;
425 // init HERCULES adapter
428 for(i=0;i<sizeof(MGATable43);i++)
437 SetWindowGeometry(wWindowHercGraph);
439 GLOBAL_SCREEN_WIDTH = 90;
440 GLOBAL_SCREEN_HEIGHT = 45;
442 attr.u.Asuchar = 0x07;
443 FrameBuffer.u.LowPart = 0xb0000;
444 pScreenBufferHercules=MmMapIoSpace(FrameBuffer,FRAMEBUFFER_SIZE,FALSE);
446 DPRINT((0,"VGA memory phys. 0xb0000 mapped to virt. 0x%x\n",pScreenBufferHercules));
448 if(pScreenBufferHercules)
452 pVgaOffset[i] = (PUCHAR)pScreenBufferHercules+0x2000*i;
453 DPRINT((0,"VGA offset %u = 0x%.8X\n",i,pVgaOffset[i]));
457 PICE_memset(pScreenBufferHercules,0x0,FRAMEBUFFER_SIZE);
461 DPRINT((0,"ConsoleInitHercules() SUCCESS!\n"));
469 //*************************************************************************
470 // ConsoleShutdownHercules()
472 // exit terminal screen
473 //*************************************************************************
474 void ConsoleShutdownHercules(void)
482 if(pScreenBufferHercules)
483 MmUnmapIoSpace(pScreenBufferHercules,FRAMEBUFFER_SIZE);