IB_AR.asm 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ; Seven Kingdoms: Ancient Adversaries
  2. ;
  3. ; Copyright 1997,1998 Enlight Software Ltd.
  4. ;
  5. ; This program is free software: you can redistribute it and/or modify
  6. ; it under the terms of the GNU General Public License as published by
  7. ; the Free Software Foundation, either version 2 of the License, or
  8. ; (at your option) any later version.
  9. ;
  10. ; This program is distributed in the hope that it will be useful,
  11. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ; GNU General Public License for more details.
  14. ;
  15. ; You should have received a copy of the GNU General Public License
  16. ; along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. ;
  18. ;Filename : IB_AR.ASM
  19. ;Description : Blt a bitmap to the display surface buffer without color key transparency handling
  20. ; but with colour Remapping
  21. INCLUDE IMGFUN.inc
  22. INCLUDE COLCODE.inc
  23. .CODE
  24. ;----------- BEGIN OF FUNCTION IMGbltAreaRemap ------------
  25. ;
  26. ; Put an non-compressed bitmap on image buffer.
  27. ; It does not handle color key transparency.
  28. ; It can blt a specific area of the source image to the
  29. ; destination buffer instead of the whole source image.
  30. ; It handles colour remapping
  31. ;
  32. ; Syntax : IMGbltAreaRemap( imageBuf, pitch, desX, desY, bitmapBuf, srcX1, srcY1, srcX2, srcY2, colorTable )
  33. ;
  34. ; char *imageBuf - the pointer to the display surface buffer
  35. ; int pitch - pitch of the display surface buffer
  36. ; int desX, desY - where to put the area on the surface buffer
  37. ; char *bitmapPtr - the pointer to the bitmap buffer
  38. ; int srcX1, srcY1 - where to get the area on the source buffer
  39. ; srcX2, srcY2
  40. ; char *colorTable - a 256-entry color remapping table
  41. ;
  42. ;-------------------------------------------------
  43. ;
  44. ; Format of the bitmap data :
  45. ;
  46. ; <short> width
  47. ; <short> height
  48. ; <char..> bitmap image
  49. ;
  50. ;-------------------------------------------------
  51. PUBLIC IMGbltAreaRemap
  52. IMGbltAreaRemap PROC imageBuf, pitch, desX, desY, bitmapPtr, srcX1, srcY1, srcX2, srcY2, colorTable
  53. LOCAL srcLineDiff, drawWidth
  54. STARTPROC
  55. MOV EAX, imageBuf ; store the address of the image buffer to a variable
  56. MOV image_buf, EAX
  57. ;------ get the bitmap width and height -----;
  58. MOV AX , DS
  59. MOV ES , AX
  60. MOV ESI, bitmapPtr
  61. XOR EAX, EAX
  62. LODSW ; get bitmap width
  63. MOV EBX, EAX
  64. ADD ESI, 2 ; by pass the bitmap height, we don't need it. srcY2 and srcY1 will give us the data we need
  65. MUL srcY1 ; calculate the source starting address
  66. ADD EAX, srcX1 ; bitmap width * srcY1 + srcX1
  67. ADD ESI, EAX
  68. MOV EAX, srcX2 ; srcLineDiff = bitmap width - (srcX2-srcX1+1)
  69. SUB EAX, srcX1
  70. INC EAX
  71. MOV srcLineDiff, EBX
  72. SUB srcLineDiff, EAX
  73. MOV EDX, pitch ; EDX = lineDiff
  74. SUB EDX, EAX ; lineDiff = image_width - (srcX2-srcX1+1)
  75. MOV drawWidth, EAX ; line pixel copy count
  76. MOV ECX, srcY2 ; blt lines = srcY2-srcY1+1
  77. SUB ECX, srcY1
  78. INC ECX
  79. CLD ; clear direction flag for MOVSB
  80. ;---------- pixels copying loop ----------;
  81. CALC_ADDR_2 EDI, desX, desY, srcX1, srcY1, pitch ; Get the address to the destination buffer
  82. MOV EBX, colorTable
  83. @@putLine:
  84. PUSH ECX
  85. MOV ECX, drawWidth
  86. @@putPoint:
  87. LODSB
  88. PRE_REMAP
  89. POST_REMAP
  90. STOSB
  91. LOOP @@putPoint
  92. ADD EDI, EDX ; EDX = lineDiff
  93. ADD ESI, srcLineDiff
  94. POP ECX
  95. LOOP @@putLine ; decrease the remain height and loop
  96. @@end: ENDPROC
  97. IMGbltAreaRemap ENDP
  98. ;----------- END OF FUNCTION IMGbltAreaRemap ----------
  99. END