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.

198 lines
4.2 KiB

  1. /******************************************************************************\
  2. * *
  3. * MONOVXD.C - _________________________________________. *
  4. * *
  5. * Copyright (c) C-Cube Microsystems 1996 *
  6. * All Rights Reserved. *
  7. * *
  8. * Use of C-Cube Microsystems code is governed by terms and conditions *
  9. * stated in the accompanying licensing statement. *
  10. * *
  11. \******************************************************************************/
  12. #ifdef VTOOLSD
  13. #include <vtoolsc.h>
  14. #include "monovxd.h"
  15. #else
  16. #include "Headers.h"
  17. #pragma hdrstop
  18. #endif
  19. #ifdef USE_MONOCHROMEMONITOR
  20. #include "xtoa.c"
  21. /******************************************************************************\
  22. * *
  23. * MONOCHROME MONITOR OUTPUT *
  24. * *
  25. \******************************************************************************/
  26. #define MONO_LINES 25
  27. #define MONO_COLUMNS 80
  28. #define MONO_ROW ( MONO_COLUMNS * 2 )
  29. #define MONO_ATTR_NORMAL 0x07
  30. #define MONO_ATTR_HIGHLIGHT 0x08
  31. #define MONO_ATTR_BLINK 0x80
  32. static int wOffset;
  33. static char bAttr;
  34. static char* mono_addr = NULL;
  35. NTHALAPI
  36. BOOLEAN
  37. HalTranslateBusAddress(
  38. IN INTERFACE_TYPE InterfaceType,
  39. IN ULONG BusNumber,
  40. IN PHYSICAL_ADDRESS BusAddress,
  41. IN OUT PULONG AddressSpace,
  42. OUT PPHYSICAL_ADDRESS TranslatedAddress
  43. );
  44. void MonoOutInit()
  45. {
  46. int i;
  47. #ifdef VTOOLSD
  48. mono_addr = (char*)MapPhysToLinear( (PVOID)0xB0000, 4096, 0 );
  49. #else
  50. // Oh, man! Wind95 times are gone!
  51. //mono_addr = (char*)0xB0000;
  52. {
  53. PHYSICAL_ADDRESS paIn, paOut;
  54. ULONG ulMemory;
  55. paIn.LowPart = 0xB0000;
  56. paIn.HighPart = 0;
  57. HalTranslateBusAddress( Isa, 0, paIn, &ulMemory, &paOut );
  58. mono_addr = (char*)MmMapIoSpace( paOut, 4096, MmNonCached );
  59. if( mono_addr == (char*)0xFFFFFFFF )
  60. mono_addr = NULL;
  61. }
  62. #endif
  63. if( mono_addr )
  64. {
  65. for ( i = 0 ; i < MONO_LINES * MONO_ROW; *(char*)(mono_addr + i++) = ' ' )
  66. ;
  67. wOffset = 0;
  68. bAttr = MONO_ATTR_NORMAL;
  69. }
  70. }
  71. void MonoOutChar( char c )
  72. {
  73. int i;
  74. if( mono_addr )
  75. {
  76. if ( c == '\n' )
  77. {
  78. // Fill the rest of the line with spaces
  79. for ( i = 0 ; i < ( MONO_ROW - wOffset % MONO_ROW ) ;
  80. *( char * )( mono_addr + wOffset + i++ ) = ' ' );
  81. wOffset += MONO_ROW - wOffset % MONO_ROW;
  82. }
  83. else
  84. {
  85. *( char * )( mono_addr + wOffset++ ) = c;
  86. *( char * )( mono_addr + wOffset++ ) = bAttr;
  87. }
  88. if ( wOffset >= MONO_LINES * MONO_ROW )
  89. {
  90. wOffset = 0;
  91. bAttr ^= MONO_ATTR_HIGHLIGHT;
  92. }
  93. }
  94. }
  95. void MonoOutStr( char * szStr )
  96. {
  97. if ( ! szStr )
  98. return;
  99. while ( *szStr )
  100. MonoOutChar( *szStr++ );
  101. }
  102. void MonoOutInt( int val )
  103. {
  104. char buff[ 12 ];
  105. #if 1//def VTOOLSD
  106. _itoa( val, buff, 10 );
  107. #else
  108. buff[0] = '?';
  109. buff[1] = 0;
  110. #endif
  111. MonoOutStr( buff );
  112. }
  113. void MonoOutHex( int val )
  114. {
  115. char buff[ 12 ];
  116. #if 1//def VTOOLSD
  117. _itoa( val, buff, 16 );
  118. #else
  119. buff[0] = '?';
  120. buff[1] = 0;
  121. #endif
  122. MonoOutStr( buff );
  123. }
  124. void MonoOutULong( DWORD val )
  125. {
  126. char buff[ 12 ];
  127. #if 1//def VTOOLSD
  128. _ltoa( val, buff, 10 );
  129. #else
  130. buff[0] = '?';
  131. buff[1] = 0;
  132. #endif
  133. MonoOutStr( buff );
  134. }
  135. void MonoOutULongHex( DWORD val )
  136. {
  137. char buff[ 12 ];
  138. #if 1//def VTOOLSD
  139. _ltoa( val, buff, 16 );
  140. #else
  141. buff[0] = '?';
  142. buff[1] = 0;
  143. #endif
  144. MonoOutStr( buff );
  145. }
  146. BOOL MonoOutSetBlink( BOOL bNewValue )
  147. {
  148. BOOL bOldValue = (bAttr & MONO_ATTR_BLINK)?TRUE:FALSE;
  149. if ( bNewValue )
  150. bAttr |= MONO_ATTR_BLINK;
  151. else
  152. bAttr &= ~MONO_ATTR_BLINK;
  153. return bOldValue;
  154. }
  155. BOOL MonoOutSetUnderscore( BOOL bNewValue )
  156. {
  157. BOOL bOldValue = ((bAttr & MONO_ATTR_NORMAL) == 1)?TRUE:FALSE;
  158. bAttr &= 0xf9; // only blink and highlight remain
  159. if ( bNewValue )
  160. bAttr |= 1;
  161. else
  162. bAttr |= 2;
  163. return bOldValue;
  164. }
  165. #endif // #ifdef USE_MONOCHROMEMONITOR