IR.asm 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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.ASM
  19. ;Description : Remap a bitmap on vga image buffer
  20. INCLUDE IMGFUN.inc
  21. .CODE
  22. ;--------- BEGIN OF FUNCTION IMGremap -----------
  23. ;
  24. ; Remap on the VGA screen
  25. ;
  26. ; Note : No border checking is made in this function.
  27. ; Placing an icon outside image buffer will cause serious BUG.
  28. ;
  29. ; char *imageBuf - the pointer to the display surface buffer
  30. ; int pitch - the pitch of the display surface buffer
  31. ; int x1,y1 - the top left vertex of the bar
  32. ; char *bitmapPtr - the pointer to the bitmap array
  33. ; char **colorTableArray - the pointer to the scale 0 of remap table array
  34. ;
  35. PUBLIC IMGremap
  36. IMGremap PROC imageBuf, pitch, x1, y1, bitmapPtr, colorTableArray
  37. LOCAL mapWidth:DWORD, destLineDiff:DWORD
  38. STARTPROC
  39. MOV EAX, imageBuf ; store the address of the image buffer to a variable
  40. MOV image_buf, EAX
  41. ;------ calc bar width and height -----;
  42. MOV AX , DS
  43. MOV ES , AX
  44. XOR EAX, EAX
  45. MOV ESI, bitmapPtr
  46. LODSW
  47. MOV mapWidth, EAX
  48. LODSW
  49. MOV ECX, EAX
  50. MOV EDX, pitch
  51. SUB EDX, mapWidth
  52. MOV destLineDiff, EDX
  53. MOV EDX, colorTableArray
  54. CLD ; clear direction flag for MOVSB
  55. ;------- pixels copying loop --------;
  56. CALC_ADDR EDI, x1, y1, pitch ; Get the offset to the image buffer address
  57. @@startY: PUSH ECX
  58. MOV ECX, mapWidth
  59. @@startX:
  60. LODSB
  61. MOVSX EAX, AL
  62. MOV EBX, [EDX + 4*EAX]
  63. MOV AL,[EDI]
  64. XLATB [EBX]
  65. STOSB
  66. LOOP @@startX
  67. POP ECX
  68. ADD EDI, destLineDiff
  69. LOOP @@startY
  70. @@end: ENDPROC
  71. IMGremap ENDP
  72. ;---------- END OF FUNCTION IMGremap ------------
  73. END