I_BAR.asm 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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_BAR.ASM
  19. ;Description : Draw a rectangle bar on vga image buffer
  20. INCLUDE IMGFUN.inc
  21. .CODE
  22. ;--------- BEGIN OF FUNCTION IMGbar -----------
  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 pitch - the pitch of the display surface buffer
  31. ; int x1,y1 - the top left vertex of the bar
  32. ; int x2,y2 - the bottom right vertex of the bar
  33. ; int color - the color of the line
  34. ;
  35. PUBLIC IMGbar
  36. IMGbar PROC imageBuf, pitch, x1, y1, x2, y2, color
  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 ECX, y2
  47. SUB ECX, y1
  48. INC ECX
  49. MOV EDX, pitch ; EDX = lineDiff
  50. SUB EDX, EBX ; lineDiff = image_width - icon_width
  51. MOV EAX, color
  52. ; replicate colour to 4 bytes in EAX
  53. PUSH ECX
  54. MOV AH,AL
  55. MOV CX,AX
  56. SHL EAX,16
  57. MOV AX,CX
  58. POP ECX
  59. CLD ; clear direction flag for MOVSB
  60. ;------- pixels copying loop --------;
  61. CALC_ADDR EDI, x1, y1, pitch ; Get the offset to the image buffer address
  62. ; ########## begin Gilbert #############;
  63. TEST BL,3 ; test if width a multiple of 4
  64. JZ @@putLineDWord
  65. ; width is not a multiple of four
  66. ROR BX, 2 ; BL = width / 4
  67. SHR BH, 6 ; BH = width mod 4, so width must be < 1024
  68. @@putLine:
  69. PUSH ECX
  70. MOVZX ECX, BL
  71. REP STOSD
  72. MOVZX ECX, BH
  73. REP STOSB
  74. ADD EDI, EDX ; EDX = lineDiff
  75. POP ECX
  76. LOOP @@putLine ; decrease the remain height and loop
  77. @@end: ENDPROC
  78. @@putLineDWord:
  79. SHR EBX,2
  80. @@putLineDWord1:
  81. PUSH ECX
  82. MOV ECX,EBX
  83. REP STOSD
  84. ADD EDI,EDX
  85. POP ECX
  86. LOOP @@putLineDWord1
  87. @@end2: ENDPROC
  88. ;############# end Gilbert ############## ;
  89. IMGbar ENDP
  90. ;---------- END OF FUNCTION IMGbar ------------
  91. END