I_XOR.asm 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 : I_XOR.ASM
  19. ;Description : Performance XOR operation on a vga image area
  20. INCLUDE IMGFUN.inc
  21. .CODE
  22. ;--------- BEGIN OF FUNCTION IMGxor -----------
  23. ;
  24. ; Performance XOR operation on a vga image area
  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. ; int x2,y2 - the bottom right vertex of the bar
  30. ;
  31. PUBLIC IMGxor
  32. IMGxor PROC imageBuf, pitch, x1, y1, x2, y2
  33. STARTPROC
  34. MOV EAX, imageBuf ; store the address of the image buffer to a variable
  35. MOV image_buf, EAX
  36. MOV AX, DS
  37. MOV ES, AX
  38. CLD ; clear direction flag for MOVSB
  39. MOV EBX, x2 ; The width of the line
  40. SUB EBX, x1
  41. INC EBX
  42. MOV EDX, y1
  43. @@doLine:
  44. CALC_ADDR EDI, x1, EDX, pitch ; Get the offset to the video address
  45. MOV ECX, EBX
  46. @@doPixel: ; XOR BYTE PTR ES:[EDI], 0FFH
  47. NOT BYTE PTR ES:[EDI]
  48. INC EDI
  49. LOOP @@doPixel
  50. INC EDX
  51. CMP EDX, y2
  52. JLE @@doLine
  53. @@end: ENDPROC
  54. IMGxor ENDP
  55. ;---------- END OF FUNCTION IMGxor ------------
  56. END