Leaked source code of windows server 2003
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.

151 lines
3.1 KiB

  1. ////////////////////////////////////////////////////
  2. // fuimg4.cpp
  3. //
  4. // September.3,1997 H.Ishida (FPL)
  5. //
  6. // COPYRIGHT(C) FUJITSU LIMITED 1997
  7. #include "fuxl.h"
  8. #include "fuimg4.h"
  9. #include "fudebug.h"
  10. #define C_BLOCK_BYTE_WIDTH 4
  11. #define CY_BLOCK 32
  12. static LPBYTE setImg4Block(LPBYTE pbDest, LPCBYTE pbSrc, int cSrcByteWidth, int cBlockByteWidth, int cyBlock)
  13. {
  14. LPCBYTE pbTmp;
  15. DWORD dwMask;
  16. DWORD dwData;
  17. int i;
  18. int j;
  19. dwData = 0xffffffff;
  20. for(i = 0; i < cyBlock; ++i){
  21. pbTmp = pbSrc;
  22. for(j = 0; j < cBlockByteWidth; ++j){
  23. dwData = (dwData << 8) | (*pbTmp++ & 0xff);
  24. if((dwData & 0x00ffffff) == 0){
  25. pbDest[-1] += 1;
  26. }
  27. else if((dwData & 0x0000ffff) == 0){
  28. *pbDest++ = 0;
  29. *pbDest++ = 2;
  30. }
  31. else{
  32. *pbDest++ = (BYTE)dwData;
  33. }
  34. }
  35. for(; j < 4; ++j){
  36. dwData <<= 8;
  37. if((dwData & 0x00ffffff) == 0){
  38. pbDest[-1] += 1;
  39. }
  40. else if((dwData & 0x0000ffff) == 0){
  41. *pbDest++ = 0;
  42. *pbDest++ = 2;
  43. }
  44. else{
  45. *pbDest++ = (BYTE)dwData;
  46. }
  47. }
  48. pbSrc += cSrcByteWidth;
  49. }
  50. for( ; i < CY_BLOCK; ++i){
  51. for(j = 0; j < C_BLOCK_BYTE_WIDTH; ++j){
  52. dwData <<= 8;
  53. if((dwData & 0x00ffffff) == 0){
  54. pbDest[-1] += 1;
  55. }
  56. else if((dwData & 0x0000ffff) == 0){
  57. *pbDest++ = 0;
  58. *pbDest++ = 2;
  59. }
  60. else{
  61. *pbDest++ = (BYTE)dwData;
  62. }
  63. }
  64. }
  65. return pbDest;
  66. }
  67. void fuxlOutputRTGIMG4(PDEVOBJ pdevobj, LPCBYTE pbSrc, int cSrcByteWidth, int y, int cy)
  68. {
  69. PFUXLPDEV pFuxlPDEV;
  70. LPCBYTE pbSrcTmp;
  71. LPBYTE pbDest;
  72. UINT uFlags;
  73. UINT uSerialCode;
  74. BOOL bCmdHeader;
  75. int iy;
  76. int ix;
  77. int cx;
  78. int xPos;
  79. int yPos;
  80. int cBlockByteWidth;
  81. int cyBlock;
  82. BYTE abBuff[256];
  83. TRACEOUT(("[fjxlRTGIMG4]\r\n"))
  84. pFuxlPDEV = (PFUXLPDEV)pdevobj->pdevOEM;
  85. cx = pFuxlPDEV->cxPage;
  86. bCmdHeader = FALSE;
  87. uFlags = 0xd0;
  88. uSerialCode = 0;
  89. cyBlock = 32;
  90. for(iy = 0; iy < cy; iy += cyBlock){
  91. if(iy + cyBlock > cy)
  92. cyBlock = cy - iy;
  93. pbSrcTmp = pbSrc;
  94. cBlockByteWidth = 4;
  95. for(ix = 0; ix < cSrcByteWidth; ix += cBlockByteWidth){
  96. if(ix + cBlockByteWidth > cSrcByteWidth)
  97. cBlockByteWidth = cSrcByteWidth - ix;
  98. pbDest = abBuff;
  99. *pbDest++ = (BYTE)(uSerialCode | uFlags);
  100. if(uFlags == 0xd0){
  101. xPos = ix * 8;
  102. yPos = iy + y;
  103. *pbDest++ = (xPos >> 8) & 0xff;
  104. *pbDest++ = (xPos & 0xe0) | 0x01;
  105. *pbDest++ = (yPos >> 8) & 0xff;
  106. *pbDest++ = (yPos & 0xe0) | 0x01;
  107. }
  108. pbDest = setImg4Block(pbDest, pbSrcTmp, cSrcByteWidth, cBlockByteWidth, cyBlock);
  109. uFlags = 0xd0;
  110. if(pbDest[-3] != 0 || pbDest[-2] != 0 || pbDest[-1] != 128){
  111. if(bCmdHeader == FALSE){
  112. bCmdHeader = TRUE;
  113. WRITESPOOLBUF(pdevobj, "\x1d\x32\x20\x61", 4);
  114. }
  115. WRITESPOOLBUF(pdevobj, abBuff, (DWORD)(pbDest - abBuff));
  116. uSerialCode = (uSerialCode + 1) & 0x0f;
  117. uFlags = 0xe0;
  118. }
  119. pbSrcTmp += cBlockByteWidth;
  120. }
  121. pbSrc += cSrcByteWidth * cyBlock;
  122. uFlags = 0xd0;
  123. }
  124. if(bCmdHeader != FALSE){
  125. abBuff[0] = uSerialCode | 0xf0;
  126. WRITESPOOLBUF(pdevobj, abBuff, 1);
  127. }
  128. }
  129. // end of fuimg4.cpp