Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

175 lines
4.6 KiB

  1. //
  2. // Fake video rom support
  3. //
  4. // This file provides interrim support for video rom bios services.
  5. // It is only intended for use until Insignia produces proper rom support
  6. // for NTVDM
  7. //
  8. // Note: portions of this code were lifted from the following source.
  9. /* x86 v1.0
  10. *
  11. * XBIOSVID.C
  12. * Guest ROM BIOS video emulation
  13. *
  14. * History
  15. * Created 20-Oct-90 by Jeff Parsons
  16. *
  17. * COPYRIGHT NOTICE
  18. * This source file may not be distributed, modified or incorporated into
  19. * another product without prior approval from the author, Jeff Parsons.
  20. * This file may be copied to designated servers and machines authorized to
  21. * access those servers, but that does not imply any form of approval.
  22. */
  23. #include <windows.h>
  24. #include <stdio.h>
  25. #include <string.h>
  26. #include <conio.h>
  27. #include "softpc.h"
  28. #include "bop.h"
  29. #include "xbios.h"
  30. #include "xbiosvid.h"
  31. #include "xwincon.h"
  32. #include "fun.h"
  33. #include "cmdsvc.h"
  34. static BYTE ServiceRoutine[] = { 0xC4, 0xC4, BOP_VIDEO, 0x50, 0x55, 0x8B,
  35. 0xEC, 0x9C, 0x58, 0x89, 0x46, 0x08, 0x5d, 0x58, 0xCF };
  36. #define SERVICE_LENGTH sizeof(ServiceRoutine)
  37. extern HANDLE OutputHandle;
  38. extern HANDLE InputHandle;
  39. /* BiosVidInit - Initialize ROM BIOS video support
  40. *
  41. * ENTRY
  42. * argc - # of command-line options
  43. * argv - pointer to first option pointer
  44. * ServicAddress - pointer to linear address to put interrupt service
  45. * routine at
  46. *
  47. * EXIT
  48. * TRUE if successful, FALSE if not
  49. */
  50. BOOL BiosVidInit(int argc, char *argv[], PVOID *ServiceAddress)
  51. {
  52. USHORT usEquip;
  53. static BYTE abVidInit[] = {VIDMODE_MONO, // VIDDATA_CRT_MODE
  54. 0x80, 0, // VIDDATA_CRT_COLS
  55. 00, 0x10, // VIDDATA_CRT_LEN
  56. 0, 0, // VIDDATA_CRT_START
  57. 0,0,0,0,0,0,0,0, // VIDDATA_CURSOR_POSN
  58. 0,0,0,0,0,0,0,0, //
  59. 7, 6, // VIDDATA_CURSOR_MODE
  60. 0, // VIDDATA_ACTIVE_PAGE
  61. 0xD4, 0x03, // VIDDATA_ADDR_6845
  62. 0, // VIDDATA_CRT_MODE_SET
  63. 0, // VIDDATA_CRT_PALETTE
  64. };
  65. PVOID Address;
  66. argv, argc;
  67. memcpy(*ServiceAddress, ServiceRoutine, SERVICE_LENGTH);
  68. Address = (PVOID)(BIOSINT_VID * 4);
  69. *((PWORD)Address) = RMOFF(*ServiceAddress);
  70. *(((PWORD)Address) + 1) = RMSEG(*ServiceAddress);
  71. (PCHAR)*ServiceAddress += SERVICE_LENGTH;
  72. usEquip = *(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, BIOSDATA_EQUIP_FLAG);
  73. usEquip |= BIOSEQUIP_MONOVIDEO;
  74. *(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, BIOSDATA_EQUIP_FLAG) = usEquip;
  75. // Initialize ROM BIOS video data to defaults
  76. Address = RMSEGOFFTOLIN(BIOSDATA_SEG, VIDDATA_CRT_MODE);
  77. memcpy(Address, abVidInit, sizeof(abVidInit));
  78. #if 0
  79. #ifdef WIN
  80. clearconsole(hwndGuest);
  81. #endif
  82. #endif
  83. return TRUE;
  84. }
  85. /* BiosVid - Emulate ROM BIOS video functions
  86. *
  87. * ENTRY
  88. * None (x86 registers contain parameters)
  89. *
  90. * EXIT
  91. * None (x86 registers/memory updated appropriately)
  92. *
  93. * This function receives control on INT 10h, routes control to the
  94. * appropriate subfunction based on the function # in AH, and
  95. * then simulates an IRET and returns back to the instruction emulator.
  96. */
  97. VOID BiosVid()
  98. {
  99. COORD coord;
  100. CHAR ch;
  101. if (fEnableInt10 == FALSE)
  102. return;
  103. switch(getAH()) {
  104. case VIDFUNC_SETCURSORPOS:
  105. coord.X = getDL();
  106. coord.Y = getDH();
  107. if(SetConsoleCursorPosition(OutputHandle, coord) == FALSE)
  108. VDprint(
  109. VDP_LEVEL_WARNING,
  110. ("SetCursorPosition Failed X=%d Y=%d\n",
  111. coord.X,coord.Y)
  112. );
  113. break;
  114. case VIDFUNC_QUERYCURSORPOS:
  115. VDprint(
  116. VDP_LEVEL_WARNING,
  117. ("Query Cursor Position Not Yet Implemented\n")
  118. );
  119. break;
  120. case VIDFUNC_SCROLLUP:
  121. VDprint(
  122. VDP_LEVEL_WARNING,
  123. ("ScrollUp Not Yet Implemented\n")
  124. );
  125. break;
  126. case VIDFUNC_WRITECHARATTR:
  127. VDprint(
  128. VDP_LEVEL_WARNING,
  129. ("WRITECHARATTR Not Yet Implemented\n")
  130. );
  131. break;
  132. case VIDFUNC_WRITETTY:
  133. ch = getAL();
  134. putch(ch);
  135. break;
  136. case VIDFUNC_QUERYMODE:
  137. setAX(*(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, VIDDATA_CRT_MODE));
  138. setBX(*(PWORD)RMSEGOFFTOLIN(BIOSDATA_SEG, VIDDATA_ACTIVE_PAGE));
  139. break;
  140. default:
  141. VDprint(
  142. VDP_LEVEL_WARNING,
  143. ("SoftPC Video Support: Unimplemented function %x\n",
  144. getAX())
  145. );
  146. }
  147. }
  148. INT tputch(INT i)
  149. {
  150. putch((CHAR)i);
  151. return i;
  152. }