gdevevga.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /* Copyright (C) 1993, 1994 Aladdin Enterprises. All rights reserved.
  2. This software is provided AS-IS with no warranty, either express or
  3. implied.
  4. This software is distributed under license and may not be copied,
  5. modified or distributed except as expressly authorized under the terms
  6. of the license contained in the file LICENSE in this distribution.
  7. For more information about licensing, please refer to
  8. http://www.ghostscript.com/licensing/. For information on
  9. commercial licensing, go to http://www.artifex.com/licensing/ or
  10. contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. San Rafael, CA 94903, U.S.A., +1(415)492-9861.
  12. */
  13. /* $Id: gdevevga.c,v 1.4 2002/02/21 22:24:51 giles Exp $ */
  14. /* IBM PC EGA and VGA display drivers */
  15. /* All of the real code is in gdevpcfb.c. */
  16. #include "memory_.h"
  17. #include "gx.h"
  18. #include "gserrors.h"
  19. #include "gxdevice.h"
  20. #include "gdevpcfb.h"
  21. /* ------ Internal routines ------ */
  22. /* We can't catch signals.... */
  23. void
  24. pcfb_set_signals(gx_device * dev)
  25. {
  26. }
  27. /* Read the device state */
  28. void
  29. pcfb_get_state(pcfb_bios_state * pbs)
  30. {
  31. registers regs;
  32. regs.h.ah = 0xf;
  33. int86(0x10, &regs, &regs);
  34. pbs->display_mode = regs.h.al;
  35. pbs->text_page = regs.h.bh;
  36. regs.h.ah = 0x3;
  37. int86(0x10, &regs, &regs);
  38. pbs->text_cursor_mode = regs.rshort.cx;
  39. regs.rshort.ax = 0x1130;
  40. regs.h.bh = 0;
  41. int86(0x10, &regs, &regs);
  42. switch (regs.rshort.cx) {
  43. case 0x08:
  44. pbs->text_font = 0x1112;
  45. break; /* 8 x 8 */
  46. case 0x10:
  47. pbs->text_font = 0x1114;
  48. break; /* 8 x 16 */
  49. default:
  50. pbs->text_font = 0x1111; /* 8 x 14 */
  51. }
  52. regs.h.ah = 0x8;
  53. regs.h.bh = pbs->text_page;
  54. int86(0x10, &regs, &regs);
  55. pbs->text_attribute = regs.h.ah;
  56. pbs->border_color = (regs.h.ah >> 4);
  57. regs.rshort.ax = 0x1a00;
  58. int86(0x10, &regs, &regs);
  59. if (regs.h.al == 0x1a && regs.h.bl == 0x8) {
  60. regs.rshort.ax = 0x1008;
  61. int86(0x10, &regs, &regs);
  62. pbs->border_color = regs.h.bh;
  63. }
  64. if (pbs->display_mode != 3) {
  65. pbs->display_mode = 3;
  66. pbs->text_font = 0x1112;
  67. pbs->text_cursor_mode = 0x0607;
  68. pbs->text_attribute = 7;
  69. pbs->text_page = 0;
  70. }
  71. }
  72. /* Set the device mode */
  73. void
  74. pcfb_set_mode(int mode)
  75. {
  76. registers regs;
  77. regs.h.ah = 0;
  78. regs.h.al = mode;
  79. int86(0x10, &regs, &regs);
  80. }
  81. /* Restore the device state */
  82. void
  83. pcfb_set_state(const pcfb_bios_state * pbs)
  84. {
  85. registers regs;
  86. pcfb_set_mode(pbs->display_mode);
  87. regs.rshort.ax = 0x500; /* force display of page 0 */
  88. int86(0x10, &regs, &regs);
  89. regs.rshort.ax = pbs->text_font;
  90. regs.h.bl = 0;
  91. int86(0x10, &regs, &regs);
  92. regs.h.ah = 0x3;
  93. regs.h.bh = 0;
  94. int86(0x10, &regs, &regs); /* Get cursor to reset MCGA */
  95. regs.h.al = pbs->text_page;
  96. regs.h.ah = 0x5;
  97. int86(0x10, &regs, &regs);
  98. regs.rshort.cx = pbs->text_cursor_mode;
  99. regs.h.ah = 0x1;
  100. int86(0x10, &regs, &regs);
  101. regs.rshort.ax = 0x1001;
  102. regs.h.bh = pbs->border_color;
  103. int86(0x10, &regs, &regs);
  104. }