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.

148 lines
4.6 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. foncache.c
  5. Abstract:
  6. This is the console fullscreen driver for the VGA card.
  7. Environment:
  8. kernel mode only
  9. Notes:
  10. Revision History:
  11. --*/
  12. #include "fsvga.h"
  13. #define ADD_IMAGE 1
  14. #define REPLACE_IMAGE 2
  15. #define CALC_BITMAP_BITS_FOR_X( FontSizeX, dwAlign ) \
  16. ( ( ( FontSizeX * BITMAP_BITS_PIXEL + (dwAlign-1) ) & ~(dwAlign-1)) >> BITMAP_ARRAY_BYTE )
  17. ULONG
  18. CalcBitmapBufferSize(
  19. IN COORD FontSize,
  20. IN ULONG dwAlign
  21. )
  22. {
  23. ULONG uiCount;
  24. uiCount = CALC_BITMAP_BITS_FOR_X(FontSize.X,
  25. (dwAlign==BYTE_ALIGN ? BITMAP_BITS_BYTE_ALIGN : BITMAP_BITS_WORD_ALIGN));
  26. uiCount = uiCount * BITMAP_PLANES * FontSize.Y;
  27. return uiCount;
  28. }
  29. VOID
  30. AlignCopyMemory(
  31. OUT PUCHAR pDestBits,
  32. IN ULONG dwDestAlign,
  33. IN PUCHAR pSrcBits,
  34. IN ULONG dwSrcAlign,
  35. IN COORD FontSize
  36. )
  37. {
  38. ULONG dwDestBufferSize;
  39. COORD coord;
  40. try
  41. {
  42. if (dwDestAlign == dwSrcAlign) {
  43. dwDestBufferSize = CalcBitmapBufferSize(FontSize, dwDestAlign);
  44. RtlCopyMemory(pDestBits, pSrcBits, dwDestBufferSize);
  45. return;
  46. }
  47. switch (dwDestAlign) {
  48. default:
  49. case WORD_ALIGN:
  50. switch (dwSrcAlign) {
  51. default:
  52. //
  53. // pDest = WORD, pSrc = WORD
  54. //
  55. case WORD_ALIGN:
  56. dwDestBufferSize = CalcBitmapBufferSize(FontSize, dwDestAlign);
  57. RtlCopyMemory(pDestBits, pSrcBits, dwDestBufferSize);
  58. break;
  59. //
  60. // pDest = WORD, pSrc = BYTE
  61. //
  62. case BYTE_ALIGN:
  63. dwDestBufferSize = CalcBitmapBufferSize(FontSize, dwDestAlign);
  64. if (((FontSize.X % BITMAP_BITS_BYTE_ALIGN) == 0) &&
  65. ((FontSize.X % BITMAP_BITS_WORD_ALIGN) == 0) ) {
  66. RtlCopyMemory(pDestBits, pSrcBits, dwDestBufferSize);
  67. }
  68. else {
  69. RtlZeroMemory(pDestBits, dwDestBufferSize);
  70. for (coord.Y=0; coord.Y < FontSize.Y; coord.Y++) {
  71. for (coord.X=0;
  72. coord.X < CALC_BITMAP_BITS_FOR_X(FontSize.X, BITMAP_BITS_BYTE_ALIGN);
  73. coord.X++) {
  74. *pDestBits++ = *pSrcBits++;
  75. }
  76. if (CALC_BITMAP_BITS_FOR_X(FontSize.X, BITMAP_BITS_BYTE_ALIGN) & 1)
  77. pDestBits++;
  78. }
  79. }
  80. break;
  81. }
  82. break;
  83. case BYTE_ALIGN:
  84. switch (dwSrcAlign) {
  85. //
  86. // pDest = BYTE, pSrc = BYTE
  87. //
  88. case BYTE_ALIGN:
  89. dwDestBufferSize = CalcBitmapBufferSize(FontSize, dwDestAlign);
  90. RtlCopyMemory(pDestBits, pSrcBits, dwDestBufferSize);
  91. break;
  92. default:
  93. //
  94. // pDest = BYTE, pSrc = WORD
  95. //
  96. case WORD_ALIGN:
  97. dwDestBufferSize = CalcBitmapBufferSize(FontSize, dwDestAlign);
  98. if (((FontSize.X % BITMAP_BITS_BYTE_ALIGN) == 0) &&
  99. ((FontSize.X % BITMAP_BITS_WORD_ALIGN) == 0) ) {
  100. RtlCopyMemory(pDestBits, pSrcBits, dwDestBufferSize);
  101. }
  102. else {
  103. RtlZeroMemory(pDestBits, dwDestBufferSize);
  104. for (coord.Y=0; coord.Y < FontSize.Y; coord.Y++) {
  105. for (coord.X=0;
  106. coord.X < CALC_BITMAP_BITS_FOR_X(FontSize.X, BITMAP_BITS_BYTE_ALIGN);
  107. coord.X++) {
  108. *pDestBits++ = *pSrcBits++;
  109. }
  110. if (CALC_BITMAP_BITS_FOR_X(FontSize.X, BITMAP_BITS_BYTE_ALIGN) & 1)
  111. pSrcBits++;
  112. }
  113. }
  114. break;
  115. }
  116. break;
  117. }
  118. }
  119. except (EXCEPTION_EXECUTE_HANDLER)
  120. {
  121. }
  122. }