IR_BAR.asm 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_BAR.ASM
  19. ;Description : Remap a rectangle bar on vga image buffer
  20. INCLUDE IMGFUN.inc
  21. .CODE
  22. ;--------- BEGIN OF FUNCTION IMGremapBar -----------
  23. ;
  24. ; Draw a bar 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 x1,y1 - the top left vertex of the bar
  31. ; int x2,y2 - the bottom right vertex of the bar
  32. ; char *colorTable - the pointer to the remap table
  33. ;
  34. PUBLIC IMGremapBar
  35. IMGremapBar PROC imageBuf, pitch, x1, y1, x2, y2, colorTable
  36. LOCAL barWidth:DWORD
  37. STARTPROC
  38. MOV EAX, imageBuf ; store the address of the image buffer to a variable
  39. MOV image_buf, EAX
  40. ;------ calc bar width and height -----;
  41. MOV AX , DS
  42. MOV ES , AX
  43. MOV EBX, x2
  44. SUB EBX, x1
  45. INC EBX
  46. MOV barWidth, EBX
  47. MOV ECX, y2
  48. SUB ECX, y1
  49. INC ECX
  50. MOV EDX, pitch ; EDX = lineDiff
  51. SUB EDX, EBX ; lineDiff = image_width - icon_width
  52. MOV EBX, colorTable
  53. CLD ; clear direction flag for MOVSB
  54. ;------- pixels copying loop --------;
  55. CALC_ADDR EDI, x1, y1, pitch ; Get the offset to the image buffer address
  56. @@startY: PUSH ECX
  57. MOV ECX, barWidth
  58. @@startX:
  59. MOV AL,[EDI]
  60. XLATB [EBX]
  61. STOSB
  62. LOOP @@startX
  63. POP ECX
  64. ADD EDI, EDX
  65. LOOP @@startY
  66. @@end: ENDPROC
  67. IMGremapBar ENDP
  68. ;---------- END OF FUNCTION IMGremapBar ------------
  69. END