I_SNOW.asm 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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_SNOW.ASM
  19. ;Description : Draw random white dots of 32x32 sqaure on vga image buffer
  20. INCLUDE IMGFUN.inc
  21. .CODE
  22. COLOR = 70h
  23. ;--------- BEGIN OF FUNCTION IMGsnow32x32 -----------
  24. ;
  25. ; Draw random white dots of 32x32 square on the VGA screen
  26. ;
  27. ; Note : No border checking is made in this function.
  28. ; Placing an icon outside image buffer will cause serious BUG.
  29. ;
  30. ; char *imageBuf - the pointer to the display surface buffer
  31. ; int pitch - the pitch of the display surface buffer
  32. ; int x1,y1 - the top left vertex of the bar
  33. ; int randSeed - random seed
  34. ; int seaLevel - draw white dot if height > seaLevel
  35. PUBLIC IMGsnow32x32
  36. PUTDOT MACRO
  37. LOCAL @@putdot1
  38. ROL EAX,10
  39. CMP AX,DX
  40. JB @@putdot1
  41. MOV byte ptr [EDI], COLOR
  42. @@putdot1:
  43. ADD EDI,2
  44. ENDM
  45. IMGsnow32x32 PROC imageBuf, pitch, x1, y1, randSeed, seaLevel
  46. STARTPROC
  47. MOV EAX, imageBuf ; store the address of the image buffer to a variable
  48. MOV image_buf, EAX
  49. MOV EAX, randSeed
  50. MOV EBX, 15a4e35h
  51. MOV ECX,16
  52. CLD ; clear direction flag for MOVSB
  53. ;------- pixels copying loop --------;
  54. CALC_ADDR EDI, x1, y1, pitch ; Get the offset to the image buffer address
  55. ADD EDI, pitch
  56. INC EDI
  57. @@line:
  58. MUL EBX
  59. MOV EDX, seaLevel
  60. INC EAX
  61. PUTDOT
  62. PUTDOT
  63. PUTDOT
  64. PUTDOT
  65. PUTDOT
  66. PUTDOT
  67. PUTDOT
  68. PUTDOT
  69. PUTDOT
  70. PUTDOT
  71. PUTDOT
  72. PUTDOT
  73. PUTDOT
  74. PUTDOT
  75. PUTDOT
  76. PUTDOT
  77. ADD EDI,pitch
  78. ADD EDI,pitch
  79. SUB EDI,32
  80. DEC ECX
  81. JNE @@line
  82. @@end: ENDPROC
  83. IMGsnow32x32 ENDP
  84. ;---------- END OF FUNCTION IMGsnow32x32 ------------
  85. END