IR_AM.asm 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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_AM.ASM
  19. ;Description : Remap a bitmap on vga image buffer with clipping, with mirroring
  20. INCLUDE IMGFUN.inc
  21. .CODE
  22. ;--------- BEGIN OF FUNCTION IMGremapAreaHMirror -----------
  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 IMGremapAreaHMirror
  34. IMGremapAreaHMirror 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, EBX
  49. SUB EAX, srcX2 ; bitmap width * srcY1 + (bitmapWidth - srcX2 -1)
  50. DEC EAX
  51. ADD ESI, EAX
  52. MOV EAX, srcX2 ; srcLineDiff = bitmap width - (srcX2-srcX1+1)
  53. SUB EAX, srcX1
  54. INC EAX
  55. MOV mapWidth, EAX
  56. MOV srcLineDiff, EBX
  57. SUB srcLineDiff, EAX
  58. MOV EDX, pitch ; EDX = lineDiff
  59. ADD EDX, EAX ; lineDiff = image_width + (srcX2-srcX1+1)
  60. MOV destLineDiff, EDX
  61. MOV ECX, srcY2 ; blt lines = srcY2-srcY1+1
  62. SUB ECX, srcY1
  63. INC ECX
  64. MOV EDX, colorTableArray
  65. CLD ; clear direction flag for MOVSB
  66. ;------- pixels copying loop --------;
  67. CALC_ADDR_2 EDI, x1, y1, srcX2, srcY1, pitch ; Get the address to the destination buffer
  68. @@startY: PUSH ECX
  69. MOV ECX, mapWidth
  70. @@startX:
  71. LODSB
  72. MOVSX EAX, AL
  73. MOV EBX, [EDX + 4*EAX]
  74. MOV AL,[EDI]
  75. XLATB [EBX]
  76. MOV [EDI],AL
  77. DEC EDI
  78. LOOP @@startX
  79. ADD ESI, srcLineDiff
  80. POP ECX
  81. ADD EDI, destLineDiff
  82. LOOP @@startY
  83. @@end: ENDPROC
  84. IMGremapAreaHMirror ENDP
  85. ;---------- END OF FUNCTION IMGremapAreaHMirror ------------
  86. END