flame.asm 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. ; tasm
  2. ; tlink
  3. ; as usual 8-)
  4. .286
  5. JUMPS
  6. ASSUME CS:_Code,DS:_DATA,SS:_Stack
  7. EXTRN _X_set_mode: FAR
  8. _Stack Segment Para Stack 'Stack'
  9. db 2048 dup (?)
  10. _Stack EndS
  11. _Data Segment Para Public 'Data'
  12. flames db 32*64 dup (0)
  13. new_flames db 32*64 dup (0)
  14. x dw 0
  15. y dw 0
  16. _Data EndS
  17. _Code Segment Para Public 'Code'
  18. Intro Proc Far
  19. push ds
  20. xor ax,ax
  21. push ax
  22. ASSUME ds:_DATA
  23. mov ax,_DATA
  24. mov ds,ax
  25. mov ax,0013h
  26. int 10h
  27. mov dx,03c8h ; Set up palette, black -> red
  28. xor al,al
  29. out dx,al
  30. inc dx
  31. mov cx,8
  32. @set_red:
  33. mov al,16 ; Some stupid comments
  34. sub al,cl
  35. shl al,3 ; Multiply al with 4
  36. out dx,al
  37. xor al,al ; Xor al with al
  38. out dx,al
  39. out dx,al
  40. loop @set_red ; Loop this 16 times (nah...no more stupid comments)
  41. mov cx,16 ; Set red -> yellow
  42. @set_yellow:
  43. mov al,60
  44. out dx,al
  45. mov al,16
  46. sub al,cl
  47. shl al,2
  48. out dx,al
  49. xor al,al
  50. out dx,al
  51. loop @set_yellow
  52. mov cx,16 ; set yellow -> white
  53. @set_white:
  54. mov al,60
  55. out dx,al
  56. out dx,al
  57. mov al,16
  58. sub al,cl
  59. shl al,2
  60. out dx,al
  61. loop @set_white
  62. mov cx,208 ; Set remaing colors to white
  63. mov al,63
  64. @whithey:
  65. out dx,al
  66. out dx,al
  67. out dx,al
  68. loop @whithey
  69. @WaitESC:
  70. push ds
  71. pop es
  72. cld
  73. lea di,flames
  74. mov si,di
  75. add di,64
  76. add si,96
  77. mov cx,61*16
  78. rep movsw ; Scroll the array 1 step up
  79. add di,6
  80. mov cx,4
  81. @put_hot_spots:
  82. push di
  83. push cx
  84. push di
  85. mov ax,20 ; Get a random x value for hotspot
  86. call random
  87. pop di
  88. add di,ax
  89. push di
  90. mov ax,190
  91. call random
  92. pop di
  93. pop cx
  94. mov ah,al
  95. mov [di],ax ; Set the hotspot
  96. pop di
  97. loop @put_hot_spots ; Set 4 new hotspots
  98. mov word ptr x,1
  99. mov word ptr y,1
  100. @scanning_flames: ; Loop for calculate the new flame array
  101. mov di,y ; Interpolate the 8 pixels around the location we wanna calculte a new value for
  102. shl di,5
  103. add di,x
  104. xor ax,ax
  105. xor bx,bx
  106. mov bl,flames[di-33]
  107. mov al,flames[di-32]
  108. add bx,ax
  109. mov al,flames[di-31]
  110. add bx,ax
  111. mov al,flames[di-1]
  112. add bx,ax
  113. mov al,flames[di+1]
  114. add bx,ax
  115. mov al,flames[di+31]
  116. add bx,ax
  117. mov al,flames[di+33]
  118. add bx,ax
  119. mov al,flames[di+33]
  120. add bx,ax
  121. shr bx,3
  122. mov new_flames[di],bl ; Save this in the new array
  123. inc x
  124. cmp word ptr x,32
  125. jb @scanning_flames
  126. mov word ptr x,1
  127. inc y
  128. cmp word ptr y,64
  129. jb @scanning_flames ; Do it for the whole "map"
  130. lea di,flames
  131. lea si,new_flames
  132. mov cx,64*16
  133. rep movsw ; Move new "map" to old "map" array
  134. mov ax,0a000h
  135. mov es,ax
  136. lea si,flames
  137. mov di,320*100+100
  138. mov bx,60
  139. @plot_it:
  140. mov cx,16
  141. rep movsw
  142. add di,320-32
  143. dec bx
  144. jnz @plot_it ; Plot the flames
  145. mov dx,03dah
  146. @bettan:
  147. in al,dx
  148. test al,8
  149. je @bettan
  150. @bettan2:
  151. in al,dx
  152. test al,8
  153. jne @bettan2 ; Wait for vertical retrace
  154. in al,60h
  155. cmp al,1
  156. jne @WaitESC ; Wait until the user have pressed ESC
  157. mov ax,0003h ; Text mode and Leave the program.
  158. int 10h
  159. mov ax,4c00h
  160. int 21h
  161. Intro EndP
  162. ;------------------------------------------------------------------------------
  163. RandSeed dd 0
  164. Randomize Proc
  165. mov ah,2Ch
  166. int 21h
  167. mov Word ptr cs:[RandSeed],cx
  168. mov Word ptr cs:[RandSeed+2],dx
  169. ret
  170. Randomize endP
  171. ;------------------------------------------------------------------------------
  172. ; In: AX - Range
  173. ; Out: AX - Value within 0 through AX-1
  174. ; Destroys: All ?X and ?I registers
  175. Random proc
  176. mov cx,ax ; save limit
  177. mov ax,Word ptr cs:[RandSeed+2]
  178. mov bx,Word ptr cs:[RandSeed]
  179. mov si,ax
  180. mov di,bx
  181. mov dl,ah
  182. mov ah,al
  183. mov al,bh
  184. mov bh,bl
  185. xor bl,bl
  186. rcr dl,1
  187. rcr ax,1
  188. rcr bx,1
  189. add bx,di
  190. adc ax,si
  191. add bx,62e9h
  192. adc ax,3619h
  193. mov word ptr cs:[RandSeed],bx
  194. mov word ptr cs:[RandSeed+2],ax
  195. xor dx,dx
  196. div cx
  197. mov ax,dx ; return modulus
  198. ret
  199. Random EndP
  200. _Code EndS
  201. END Intro