IB_A.asm 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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_A.ASM
  19. ;Description : Blt a bitmap to the display surface buffer without color key transparency handling
  20. INCLUDE IMGFUN.inc
  21. .CODE
  22. ;----------- BEGIN OF FUNCTION IMGbltArea ------------
  23. ;
  24. ; Put an non-compressed bitmap on image buffer.
  25. ; It does not handle color key transparency.
  26. ; It can blt a specific area of the source image to the
  27. ; destination buffer instead of the whole source image.
  28. ;
  29. ; Syntax : IMGbltArea( imageBuf, pitch, desX, desY, bitmapBuf, srcX1, srcY1, srcX2, srcY2 )
  30. ;
  31. ; char *imageBuf - the pointer to the display surface buffer
  32. ; int pitch - pitch of the display surface buffer
  33. ; int desX, desY - where to put the area on the surface buffer
  34. ; char *bitmapPtr - the pointer to the bitmap buffer
  35. ; int srcX1, srcY1 - where to get the area on the source buffer
  36. ; srcX2, srcY2
  37. ;
  38. ;-------------------------------------------------
  39. ;
  40. ; Format of the bitmap data :
  41. ;
  42. ; <short> width
  43. ; <short> height
  44. ; <char..> bitmap image
  45. ;
  46. ;-------------------------------------------------
  47. PUBLIC IMGbltArea
  48. IMGbltArea PROC imageBuf, pitch, desX, desY, bitmapPtr, srcX1, srcY1, srcX2, srcY2
  49. LOCAL srcLineDiff
  50. STARTPROC
  51. MOV EAX, imageBuf ; store the address of the image buffer to a variable
  52. MOV image_buf, EAX
  53. ;------ get the bitmap width and height -----;
  54. MOV AX , DS
  55. MOV ES , AX
  56. MOV ESI, bitmapPtr
  57. XOR EAX, EAX
  58. LODSW ; get bitmap width
  59. MOV EBX, EAX
  60. ADD ESI, 2 ; by pass the bitmap height, we don't need it. srcY2 and srcY1 will give us the data we need
  61. MUL srcY1 ; calculate the source starting address
  62. ADD EAX, srcX1 ; bitmap width * srcY1 + srcX1
  63. ADD ESI, EAX
  64. MOV EAX, srcX2 ; srcLineDiff = bitmap width - (srcX2-srcX1+1)
  65. SUB EAX, srcX1
  66. INC EAX
  67. MOV srcLineDiff, EBX
  68. SUB srcLineDiff, EAX
  69. MOV EDX, pitch ; EDX = lineDiff
  70. SUB EDX, EAX ; lineDiff = image_width - (srcX2-srcX1+1)
  71. MOV EBX, EAX ; EBX - line pixel copy count
  72. MOV ECX, srcY2 ; blt lines = srcY2-srcY1+1
  73. SUB ECX, srcY1
  74. INC ECX
  75. CLD ; clear direction flag for MOVSB
  76. ;---------- pixels copying loop ----------;
  77. CALC_ADDR_2 EDI, desX, desY, srcX1, srcY1, pitch ; Get the address to the destination buffer
  78. @@putLine:
  79. PUSH ECX
  80. MOV ECX, EBX
  81. REP MOVSB
  82. ADD EDI, EDX ; EDX = lineDiff
  83. ADD ESI, srcLineDiff
  84. POP ECX
  85. LOOP @@putLine ; decrease the remain height and loop
  86. @@end: ENDPROC
  87. IMGbltArea ENDP
  88. ;----------- END OF FUNCTION IMGbltArea ----------
  89. END