home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / programming / misc_programming / flames.asm < prev    next >
Assembly Source File  |  1993-09-27  |  7KB  |  269 lines

  1. .286
  2. JUMPS
  3. ASSUME CS:_Code,DS:_DATA,SS:_Stack
  4. ─────────────────────────────────────────────────────────────────────────────
  5. EXTRN _X_set_mode: FAR
  6. ─────────────────────────────────────────────────────────────────────────────
  7. _Stack Segment Para Stack 'Stack'
  8.     db 2048 dup (?)
  9. _Stack EndS
  10. ─────────────────────────────────────────────────────────────────────────────
  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.  
  17.  
  18. _Data  EndS
  19.  
  20. _Code  Segment Para Public 'Code'
  21.  
  22. SetBorder Macro color
  23.        mov  dx,03dah            ; Used for speed test
  24.        in   al,dx
  25.        nop
  26.        nop
  27.        nop
  28.        mov  dx,03c0h
  29.        mov  al,11h+32
  30.        out  dx,al
  31.        mov  al,color
  32.        out  dx,al
  33.        EndM
  34.  
  35. Intro  Proc   Far
  36.        push ds
  37.        xor  ax,ax
  38.        push ax
  39.        ASSUME ds:_DATA
  40.        mov  ax,_DATA
  41.        mov  ds,ax
  42.  
  43.        mov  ax,0013h
  44.        int  10h
  45.  
  46.        mov  dx,03c8h        ; Set up palette,  black -> red
  47.        xor  al,al
  48.        out  dx,al
  49.        inc  dx
  50.        mov  cx,8
  51. @set_red:
  52.        mov  al,16        ; Some stupid comments
  53.        sub  al,cl
  54.        shl  al,3        ; Multiply al with 4
  55.        out  dx,al        
  56.        xor  al,al        ; Xor al with al
  57.        out  dx,al
  58.        out  dx,al
  59.        loop @set_red        ; Loop this 16 times  (nah...no more stupid comments)
  60.  
  61.        mov  cx,16        ; Set red -> yellow 
  62. @set_yellow:
  63.        mov  al,60
  64.        out  dx,al
  65.        mov  al,16
  66.        sub  al,cl
  67.        shl  al,2
  68.        out  dx,al
  69.        xor  al,al
  70.        out  dx,al
  71.        loop @set_yellow
  72.  
  73.        mov  cx,16        ; set yellow -> white
  74. @set_white:
  75.        mov  al,60
  76.        out  dx,al
  77.        out  dx,al
  78.        mov  al,16
  79.        sub  al,cl
  80.        shl  al,2
  81.        out  dx,al
  82.        loop @set_white
  83.  
  84.        mov  cx,208        ; Set remaing colors to white
  85.        mov  al,63
  86. @whithey:
  87.        out  dx,al
  88.        out  dx,al
  89.        out  dx,al
  90.        loop @whithey
  91.  
  92. @WaitESC:
  93.  
  94.        SetBorder 200            ; Delete the speed test when used in a proggie
  95.  
  96.        push ds
  97.        pop  es
  98.        cld
  99.  
  100.        lea  di,flames
  101.        mov  si,di
  102.        add  di,64
  103.        add  si,96
  104.        mov  cx,61*16
  105.        rep  movsw            ; Scroll the array 1 step up
  106.  
  107.        inc  di
  108.        add  di,5
  109.        mov  cx,4
  110. @put_hot_spots:
  111.        push di
  112.        push cx
  113.        push di
  114.        mov  ax,20            ; Get a random x value for hotspot
  115.        call random
  116.        pop  di
  117.        add  di,ax
  118.        push di
  119.        mov  ax,190
  120.        call random
  121.        pop  di
  122.        pop  cx
  123.        mov  ah,al
  124.        mov  [di],ax            ; Set the hotspot
  125.        pop  di
  126.        loop @put_hot_spots        ; Set 4 new hotspots
  127.  
  128.        mov  word ptr x,1
  129.        mov  word ptr y,1
  130. @scanning_flames:            ; Loop for calculate the new flame array
  131.        mov  di,y            ; Interpolate the 8 pixels around the location we wanna calculte a new value for
  132.        shl  di,5
  133.        add  di,x
  134.        xor  ax,ax
  135.        xor  bx,bx
  136.        mov  bl,flames[di-33]
  137.        mov  al,flames[di-32]
  138.        add  bx,ax
  139.        mov  al,flames[di-31]
  140.        add  bx,ax
  141.        mov  al,flames[di-1]
  142.        add  bx,ax
  143.        mov  al,flames[di+1]
  144.        add  bx,ax
  145.        mov  al,flames[di+31]
  146.        add  bx,ax
  147.        mov  al,flames[di+33]
  148.        add  bx,ax
  149.        mov  al,flames[di+33]
  150.        add  bx,ax
  151.        shr  bx,3
  152.        mov  new_flames[di],bl        ; Save this in the new array
  153.        inc  x
  154.        cmp  word ptr x,32
  155.        jb   @scanning_flames
  156.        mov  word ptr x,1
  157.        inc  y
  158.        cmp  word ptr y,64
  159.        jb   @scanning_flames        ; Do it for the whole "map"
  160.  
  161.        lea  di,flames
  162.        lea  si,new_flames
  163.        mov  cx,64*16
  164.        rep  movsw            ; Move new "map" to old "map" array
  165.  
  166.        mov  ax,0a000h
  167.        mov  es,ax
  168.        lea  si,flames
  169.        mov  di,320*100+100
  170.        mov  bx,60
  171. @plot_it:
  172.        mov  cx,16
  173.        rep  movsw
  174.        add  di,320-32
  175.        dec  bx
  176.        jnz  @plot_it            ; Plot the flames
  177.  
  178.        SetBorder 0            ; Delete this speed test
  179.  
  180.  
  181.        mov  dx,03dah
  182. @bettan:
  183.        in   al,dx
  184.        test al,8
  185.        je   @bettan
  186. @bettan2:
  187.        in   al,dx
  188.        test al,8
  189.        jne  @bettan2            ; Wait for vertical retrace
  190.  
  191.  
  192.        in   al,60h
  193.        cmp  al,1
  194.        jne  @WaitESC            ; Wait until the user have pressed ESC
  195.  
  196.        mov  ax,0003h            ; Text mode and Leave the program.
  197.        int  10h
  198.        mov  ax,4c00h
  199.        int  21h
  200. Intro  EndP
  201.  
  202. ;--------------------------------------------------------------------------------
  203. ; The above program is made by Errand and is released to the public domain.
  204. ; Thanks to Jare of Iguana for the information of the "simple" formula for
  205. ; flames.
  206. ;
  207. ; If you find this file interesting then PLEASE send me a postcard 8)
  208. ;
  209. ; Daniel Sjoberg
  210. ; Mogatan 11
  211. ; S-566 34 HABO
  212. ; SWEDEN
  213. ; Phone: (+46) 36 - 46309 CET  (Dont call me at nights 8) )
  214. ;
  215. ; Greetings goes to:      Jare (Iguana), Leinad (*Avalanche*), Zax (*Avalanche*), 
  216. ;            wReam (CB!), ZigZag (CB!), Patch (*Avalanche*)
  217. ;            and the rest nice IRC-folks I know...
  218. ;
  219. ;
  220. ;--------------------------------------------------------------------------------
  221.  
  222. ;-------------------------------------------------------------------------------
  223. ; Author:  Unknown.  The author is the author of the HYPERCUBE Tumble program.
  224. ;-------------------------------------------------------------------------------
  225. RandSeed        dd       0
  226.  
  227. Randomize       Proc
  228.                 mov      ah,2Ch
  229.                 int      21h
  230.                 mov      Word ptr cs:[RandSeed],cx
  231.                 mov      Word ptr cs:[RandSeed+2],dx
  232.                 ret
  233. Randomize       endP
  234.  
  235. ;-------------------------------------------------------------------------------
  236. ; In:  AX - Range
  237. ; Out: AX - Value within 0 through AX-1
  238. ; Destroys: All ?X and ?I registers
  239. Random          proc
  240.                 mov      cx,ax          ; save limit
  241.                 mov      ax,Word ptr cs:[RandSeed+2]
  242.                 mov      bx,Word ptr cs:[RandSeed]
  243.                 mov      si,ax
  244.                 mov      di,bx
  245.                 mov      dl,ah
  246.                 mov      ah,al
  247.                 mov      al,bh
  248.                 mov      bh,bl
  249.                 xor      bl,bl
  250.                 rcr      dl,1
  251.                 rcr      ax,1
  252.                 rcr      bx,1
  253.                 add      bx,di
  254.                 adc      ax,si
  255.                 add      bx,62e9h
  256.                 adc      ax,3619h
  257.                 mov      word ptr cs:[RandSeed],bx
  258.                 mov      word ptr cs:[RandSeed+2],ax
  259.                 xor      dx,dx
  260.                 div      cx
  261.                 mov      ax,dx                  ; return modulus
  262.                 ret
  263. Random          EndP
  264.  
  265. _Code  EndS
  266. ─────────────────────────────────────────────────────────────────────────────
  267.  
  268. END Intro