Old fashion design for PC-104
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.

262 lines
4.9 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: SCREEN.CPP
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of SCREEN.CPP
  13. //----------------------------------------------------------------------------
  14. #include <alloc.h>
  15. #include <math.h>
  16. #include "screen.h"
  17. #include "detector.h"
  18. #include "..\LgLib\version.h"
  19. #ifdef DEBUG_GRAPH_SCREEN
  20. CScreen g_Screen;
  21. BYTE huge* CScreen::s_pVideoMem = (BYTE huge* )0xA0000000L;
  22. CScreen::CScreen()
  23. {
  24. }
  25. CScreen::~CScreen()
  26. {
  27. Destroy();
  28. }
  29. BOOL CScreen::Create()
  30. {
  31. asm
  32. {
  33. mov ax, 0x13
  34. int 0x10
  35. }
  36. return TRUE;
  37. }
  38. void CScreen::Destroy()
  39. {
  40. asm
  41. {
  42. mov ax, 0x3
  43. int 0x10
  44. }
  45. }
  46. void CScreen::Clear()
  47. {
  48. for( LONG i = 0; i < 320L*200; i++ )
  49. s_pVideoMem[i] = 0;
  50. }
  51. static BYTE g_pNumbers[] =
  52. {
  53. // 0x00
  54. 0x00,0x0F,0x0F,0x00,
  55. 0x0F,0x00,0x00,0x0F,
  56. 0x0F,0x00,0x00,0x0F,
  57. 0x0F,0x00,0x00,0x0F,
  58. 0x0F,0x00,0x00,0x0F,
  59. 0x0F,0x00,0x00,0x0F,
  60. 0x00,0x0F,0x0F,0x00,
  61. // 0x0F
  62. 0x00,0x00,0x00,0x0F,
  63. 0x00,0x00,0x00,0x0F,
  64. 0x00,0x00,0x0F,0x0F,
  65. 0x00,0x00,0x00,0x0F,
  66. 0x00,0x00,0x00,0x0F,
  67. 0x00,0x00,0x00,0x0F,
  68. 0x00,0x00,0x00,0x0F,
  69. // 2
  70. 0x00,0x0F,0x0F,0x00,
  71. 0x0F,0x00,0x00,0x0F,
  72. 0x00,0x00,0x00,0x0F,
  73. 0x00,0x00,0x00,0x0F,
  74. 0x00,0x00,0x0F,0x00,
  75. 0x00,0x0F,0x00,0x00,
  76. 0x0F,0x0F,0x0F,0x0F,
  77. // 3
  78. 0x00,0x0F,0x0F,0x00,
  79. 0x0F,0x00,0x00,0x0F,
  80. 0x00,0x00,0x00,0x0F,
  81. 0x00,0x00,0x0F,0x00,
  82. 0x00,0x00,0x00,0x0F,
  83. 0x0F,0x00,0x00,0x0F,
  84. 0x00,0x0F,0x0F,0x00,
  85. // 4
  86. 0x0F,0x00,0x00,0x0F,
  87. 0x0F,0x00,0x00,0x0F,
  88. 0x0F,0x00,0x00,0x0F,
  89. 0x0F,0x0F,0x0F,0x0F,
  90. 0x00,0x00,0x00,0x0F,
  91. 0x00,0x00,0x00,0x0F,
  92. 0x00,0x00,0x00,0x0F,
  93. // 5
  94. 0x0F,0x0F,0x0F,0x0F,
  95. 0x0F,0x00,0x00,0x00,
  96. 0x0F,0x0F,0x0F,0x00,
  97. 0x0F,0x00,0x00,0x0F,
  98. 0x00,0x00,0x00,0x0F,
  99. 0x0F,0x00,0x00,0x0F,
  100. 0x00,0x0F,0x0F,0x00,
  101. // 6
  102. 0x00,0x0F,0x0F,0x00,
  103. 0x0F,0x00,0x00,0x0F,
  104. 0x0F,0x00,0x00,0x00,
  105. 0x0F,0x0F,0x0F,0x0F,
  106. 0x0F,0x00,0x00,0x0F,
  107. 0x0F,0x00,0x00,0x0F,
  108. 0x00,0x0F,0x0F,0x00,
  109. // 7
  110. 0x0F,0x0F,0x0F,0x0F,
  111. 0x00,0x00,0x00,0x0F,
  112. 0x00,0x00,0x00,0x0F,
  113. 0x00,0x00,0x0F,0x00,
  114. 0x00,0x0F,0x00,0x00,
  115. 0x00,0x0F,0x00,0x00,
  116. 0x00,0x0F,0x00,0x00,
  117. // 8
  118. 0x00,0x0F,0x0F,0x00,
  119. 0x0F,0x00,0x00,0x0F,
  120. 0x0F,0x00,0x00,0x0F,
  121. 0x00,0x0F,0x0F,0x00,
  122. 0x0F,0x00,0x00,0x0F,
  123. 0x0F,0x00,0x00,0x0F,
  124. 0x00,0x0F,0x0F,0x00,
  125. // 9
  126. 0x00,0x0F,0x0F,0x00,
  127. 0x0F,0x00,0x00,0x0F,
  128. 0x0F,0x00,0x00,0x0F,
  129. 0x00,0x0F,0x0F,0x0F,
  130. 0x00,0x00,0x00,0x0F,
  131. 0x0F,0x00,0x00,0x0F,
  132. 0x00,0x0F,0x0F,0x00,
  133. };
  134. void CScreen::OutInteger( LONG nShift, INT nValue )
  135. {
  136. INT nCount = 0;
  137. BYTE pSymbol[10];
  138. // convert to string
  139. do
  140. {
  141. pSymbol[ nCount++ ] = nValue % 10;
  142. nValue /= 10;
  143. }
  144. while( nValue );
  145. BYTE huge *pScreen = s_pVideoMem + nShift;
  146. for( INT i = nCount - 1; i >= 0; i-- )
  147. {
  148. INT nBit = pSymbol[i] * 28;
  149. BYTE huge * pScr = pScreen;
  150. for( INT y = 0; y < 7; y ++ )
  151. {
  152. for( INT x = 0; x < 4; x ++ )
  153. pScr[x] = g_pNumbers[ nBit++ ];
  154. pScr += 320;
  155. }
  156. pScreen += 5;
  157. }
  158. }
  159. #endif //DEBUG_GRAPH_SCREEN
  160. #ifdef DEBUG_CRT_SCREEN
  161. CCRT g_CRT;
  162. void CCRT::TextOut( INT x, INT y, LPCTSTR pText, INT nText )
  163. {
  164. BYTE huge *pVideo = m_lpVideo + (y << 7) + (y << 5) + (x << 1);
  165. for( INT i = 0 ; i < nText; i++ )
  166. {
  167. *pVideo++ = *pText++;
  168. *pVideo++ = 15; // white color on black background
  169. }
  170. }
  171. void CCRT::IntOut( INT x, INT y, INT nValue )
  172. {
  173. asm
  174. {
  175. // m_lpVideo + (y << 7) + (y << 5) + (x << 1)
  176. push 0xB800
  177. pop es
  178. mov si, x
  179. shl si, 1 // si = x << 1
  180. mov bx, y
  181. mov ax, bx
  182. shl ax, 5
  183. add si, ax // si = (x << 1) + (y << 5)
  184. mov ax, bx
  185. shl ax, 7
  186. add si, ax // si = (x << 1) + (y << 5) + (y << 7)
  187. add si, 4*2 // si = (x << 1) + (y << 5) + (y << 7) + 4*2
  188. // convertion circle
  189. mov ax, nValue // DX:AX <- nValue
  190. mov bx, 10 // divider
  191. mov cx, 5
  192. @lNextDigit:
  193. xor dx, dx
  194. div bx
  195. add dl, '0' // place character
  196. mov dh, 15 // place attribute
  197. mov [es:si], dx
  198. dec si
  199. dec si
  200. loop @lNextDigit
  201. }
  202. }
  203. void CCRT::HexOut( INT x, INT y, INT nValue )
  204. {
  205. static BYTE pHexTable[] = "0123456789ABCDEF";
  206. asm
  207. {
  208. // m_lpVideo + (y << 7) + (y << 5) + (x << 1)
  209. push 0xB800
  210. pop es
  211. mov si, x
  212. shl si, 1 // si = x << 1
  213. mov bx, y
  214. mov ax, bx
  215. shl ax, 5
  216. add si, ax // si = (x << 1) + (y << 5)
  217. mov ax, bx
  218. shl ax, 7
  219. add si, ax // si = (x << 1) + (y << 5) + (y << 7)
  220. add si, 3*2 // si = (x << 1) + (y << 5) + (y << 7) + 3*2
  221. // convertion circle
  222. mov ax, nValue // DX:AX <- nValue
  223. mov cx, 4
  224. @lNextDigit:
  225. mov bx, ax
  226. and bx, 0x000F;
  227. mov dl, pHexTable[bx] // character
  228. mov dh, 15 // attribute
  229. mov [es:si], dx
  230. dec si
  231. dec si
  232. shr ax, 4
  233. loop @lNextDigit
  234. }
  235. }
  236. #endif // DEBUG_CRT_SCREEN