IR_A.asm 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 : IR_A.ASM
  19. ;Description : Remap a bitmap on vga image buffer with clipping
  20. INCLUDE IMGFUN.inc
  21. .CODE
  22. ;--------- BEGIN OF FUNCTION IMGremapArea -----------
  23. ;
  24. ; Remap on the VGA screen
  25. ;
  26. ; char *imageBuf - the pointer to the display surface buffer
  27. ; int pitch - the pitch of the display surface buffer
  28. ; int x1,y1 - the top left vertex of the bar
  29. ; char *bitmapPtr - the pointer to the bitmap array
  30. ; char **colorTableArray - the pointer to the scale 0 of remap table array
  31. ; int srcX1, srcY1 srcX2, srcY2 - where to get on the source buffer
  32. ;
  33. PUBLIC IMGremapArea
  34. IMGremapArea PROC imageBuf, pitch, x1, y1, bitmapPtr, colorTableArray, srcX1, srcY1, srcX2, srcY2
  35. LOCAL mapWidth:DWORD, srcLineDiff:DWORD, destLineDiff:DWORD
  36. STARTPROC
  37. MOV EAX, imageBuf ; store the address of the image buffer to a variable
  38. MOV image_buf, EAX
  39. ;------ calc bar width and height -----;
  40. MOV AX , DS
  41. MOV ES , AX
  42. XOR EAX, EAX
  43. MOV ESI, bitmapPtr
  44. LODSW
  45. MOV EBX, EAX
  46. ADD ESI, 2 ; by pass height
  47. MUL srcY1 ; calculate the source starting address
  48. ADD EAX, srcX1 ; bitmap width * srcY1 + srcX1
  49. ADD ESI, EAX
  50. MOV EAX, srcX2 ; srcLineDiff = bitmap width - (srcX2-srcX1+1)
  51. SUB EAX, srcX1
  52. INC EAX
  53. MOV mapWidth, EAX
  54. MOV srcLineDiff, EBX
  55. SUB srcLineDiff, EAX
  56. MOV EDX, pitch ; EDX = lineDiff
  57. SUB EDX, EAX ; lineDiff = image_width - (srcX2-srcX1+1)
  58. MOV destLineDiff, EDX
  59. MOV ECX, srcY2 ; blt lines = srcY2-srcY1+1
  60. SUB ECX, srcY1
  61. INC ECX
  62. MOV EDX, colorTableArray
  63. CLD ; clear direction flag for MOVSB
  64. ;------- pixels copying loop --------;
  65. CALC_ADDR_2 EDI, x1, y1, srcX1, srcY1, pitch ; Get the address to the destination buffer
  66. @@startY: PUSH ECX
  67. MOV ECX, mapWidth
  68. @@startX:
  69. LODSB
  70. MOVSX EAX, AL
  71. MOV EBX, [EDX + 4*EAX]
  72. MOV AL,[EDI]
  73. XLATB [EBX]
  74. STOSB
  75. LOOP @@startX
  76. ADD ESI, srcLineDiff
  77. POP ECX
  78. ADD EDI, destLineDiff
  79. LOOP @@startY
  80. @@end: ENDPROC
  81. IMGremapArea ENDP
  82. ;---------- END OF FUNCTION IMGremapArea ------------
  83. END