home *** CD-ROM | disk | FTP | other *** search
/ CD/PC Actual 13 / CDA13.ISO / cdactual / demobin / share / program / Asm / ANIM.ZIP / AN0.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-04-27  |  9.1 KB  |  307 lines

  1. MASM51
  2. DOSSEG
  3.  
  4. MODEL SMALL
  5.  
  6. .STACK  256
  7.  
  8.  
  9. ;SLOWDOWN        equ     0
  10.  
  11. RED             equ     01h
  12. GREEN           equ     02h
  13. BLUE            equ     04h
  14. WHITE           equ     08h
  15.  
  16. VGA_SEGMENT     equ     0a000h
  17. SC_INDEX        equ     3c4h
  18. MAP_MASK        equ     2
  19. SCREEN_WIDTH    equ     80
  20. SCREEN_HEIGHT   equ     350
  21. WORDS_OUT_OK    equ     1
  22.  
  23. ObjectStructure struc
  24. Delay           dw      ?
  25. BaseDelay       dw      ?
  26. Image           dw      ?
  27. XCoord          dw      ?
  28. XInc            dw      ?
  29. XLeftLimit      dw      ?
  30. XRightLimit     dw      ?
  31. YCoord          dw      ?
  32. YInc            dw      ?
  33. YTopLimit       dw      ?
  34. YBottomLimit    dw      ?
  35. PlaneSelect     db      ?
  36.                 db      ?
  37. ObjectStructure ends
  38.  
  39. .DATA
  40.  
  41. Colors  db      001h
  42.         db      02ch
  43.         db      02ah
  44.         db      01fh
  45.         db      029h
  46.         db      01ch
  47.         db      02ah
  48.         db      00ch
  49.         db      01fh
  50.         db      02ch
  51.         db      027h
  52.         db      02ch
  53.         db      019h
  54.         db      04ch
  55.         db      02ah
  56.         db      025h
  57.         db      000h
  58.  
  59. Square  label   byte
  60.         dw      48,6
  61.         rept    8
  62.         db      0,0,0,0,0,0
  63.         endm
  64.         .radix  2
  65.         db      0,11111111,11111111,11111111,11111111,0
  66.         db      0,11111111,11111111,11111111,11111111,0
  67.         db      0,11111111,11111111,11111111,11111111,0
  68.         db      0,11111111,11111111,11111111,11111111,0
  69.         db      0,11111111,11111111,11111111,11111111,0
  70.         db      0,11111111,11111111,11111111,11111111,0
  71.         db      0,11111111,11111111,11111111,11111111,0
  72.         db      0,11111111,11111111,11111111,11111111,0
  73.         db      0,11111111,00000000,00000000,11111111,0
  74.         db      0,11111111,00000000,00000000,11111111,0
  75.         db      0,11111111,00000000,00000000,11111111,0
  76.         db      0,11111111,00000000,00000000,11111111,0
  77.         db      0,11111111,00000000,00000000,11111111,0
  78.         db      0,11111111,00000000,00000000,11111111,0
  79.         db      0,11111111,00000000,00000000,11111111,0
  80.         db      0,11111111,00000000,00000000,11111111,0
  81.         db      0,11111111,00000000,00000000,11111111,0
  82.         db      0,11111111,00000000,00000000,11111111,0
  83.         db      0,11111111,00000000,00000000,11111111,0
  84.         db      0,11111111,00000000,00000000,11111111,0
  85.         db      0,11111111,00000000,00000000,11111111,0
  86.         db      0,11111111,00000000,00000000,11111111,0
  87.         db      0,11111111,00000000,00000000,11111111,0
  88.         db      0,11111111,00000000,00000000,11111111,0
  89.         db      0,11111111,11111111,11111111,11111111,0
  90.         db      0,11111111,11111111,11111111,11111111,0
  91.         db      0,11111111,11111111,11111111,11111111,0
  92.         db      0,11111111,11111111,11111111,11111111,0
  93.         db      0,11111111,11111111,11111111,11111111,0
  94.         db      0,11111111,11111111,11111111,11111111,0
  95.         db      0,11111111,11111111,11111111,11111111,0
  96.         db      0,11111111,11111111,11111111,11111111,0
  97.         .radix  10
  98.         rept    8
  99.         db      0,0,0,0,0,0
  100.         endm
  101.  
  102. Diamond label   byte
  103.         dw      48,6
  104.         rept    8
  105.         db      0,0,0,0,0,0
  106.         endm
  107.         .radix  2
  108.         db      0,00000000,00000001,10000000,00000000,0
  109.         db      0,00000000,00000011,11000000,00000000,0
  110.         db      0,00000000,00000111,11100000,00000000,0
  111.         db      0,00000000,00001111,11110000,00000000,0
  112.         db      0,00000000,00011111,11111000,00000000,0
  113.         db      0,00000000,00111110,01111100,00000000,0
  114.         db      0,00000000,01111100,00111110,00000000,0
  115.         db      0,00000000,11111000,00011111,00000000,0
  116.         db      0,00000001,11110000,00001111,10000000,0
  117.         db      0,00000011,11100000,00000111,11000000,0
  118.         db      0,00000111,11000000,00000011,11100000,0
  119.         db      0,00001111,10000001,10000001,11110000,0
  120.         db      0,00011111,00000011,11000000,11111000,0
  121.         db      0,00111110,00000111,11100000,01111100,0
  122.         db      0,01111100,00001111,11110000,00111110,0
  123.         db      0,11111000,00011111,11111000,00011111,0
  124.         db      0,11111000,00011111,11111000,00011111,0
  125.         db      0,01111100,00001111,11110000,00111110,0
  126.         db      0,00111110,00000111,11100000,01111100,0
  127.         db      0,00011111,00000011,11000000,11111000,0
  128.         db      0,00001111,10000001,10000001,11110000,0
  129.         db      0,00000111,11000000,00000011,11100000,0
  130.         db      0,00000011,11100000,00000111,11000000,0
  131.         db      0,00000001,11110000,00001111,10000000,0
  132.         db      0,00000000,11111000,00011111,00000000,0
  133.         db      0,00000000,01111100,00111110,00000000,0
  134.         db      0,00000000,00111110,01111100,00000000,0
  135.         db      0,00000000,00011111,11111000,00000000,0
  136.         db      0,00000000,00001111,11110000,00000000,0
  137.         db      0,00000000,00000111,11100000,00000000,0
  138.         db      0,00000000,00000011,11000000,00000000,0
  139.         db      0,00000000,00000001,10000000,00000000,0
  140.         .radix  10
  141.         rept    8
  142.         db      0,0,0,0,0,0
  143.         endm
  144.  
  145.         even
  146.  
  147. ObjectList      label   ObjectStructure
  148. ObjectStructure <1,21,Diamond,88,8,80,512,16,0,0,350,RED>
  149. ObjectStructure <1,15,Square,296,8,112,480,144,0,0,350,RED>
  150. ObjectStructure <1,23,Diamond,88,8,80,512,256,0,0,350,RED>
  151. ObjectStructure <1,13,Square,120,0,0,640,144,4,0,280,BLUE>
  152. ObjectStructure <1,11,Diamond,208,0,0,640,144,4,0,280,BLUE>
  153. ObjectStructure <1,8,Square,296,0,0,640,144,4,0,288,BLUE>
  154. ObjectStructure <1,9,Diamond,384,0,0,640,144,4,0,288,BLUE>
  155. ObjectStructure <1,14,Square,472,0,0,640,144,4,0,280,BLUE>
  156. ObjectStructure <1,8,Diamond,200,8,0,576,48,6,0,280,GREEN>
  157. ObjectStructure <1,8,Square,248,8,0,576,96,6,0,280,GREEN>
  158. ObjectStructure <1,8,Diamond,296,8,0,576,144,6,0,280,GREEN>
  159. ObjectStructure <1,8,Square,344,8,0,576,192,6,0,280,GREEN>
  160. ObjectStructure <1,8,Diamond,392,8,0,576,240,6,0,280,GREEN>
  161. ObjectListEnd   label   ObjectStructure
  162.  
  163. OUT_WORD        macro
  164. if WORDS_OUT_OK
  165.         out     dx,ax
  166. else
  167.         out     dx,al
  168.         inc     dx
  169.         xchg    ah,al
  170.         out     dx,al
  171.         dec     dx
  172.         xchg    ah,al
  173. endif
  174.         endm
  175.  
  176. CONSTANT_TO_INDEXED_REGISTER    macro   ADDRESS, INDEX, VALUE
  177.         mov     dx,ADDRESS
  178.         mov     ax,(VALUE shl 8) + INDEX
  179.         OUT_WORD
  180.         endm
  181.  
  182. .CODE
  183.  
  184. Start   proc    near
  185.         cld
  186.         mov     ax,@Data
  187.         mov     ds,ax
  188.         mov     ax,0010h
  189.         int     10h
  190.         mov     ax,VGA_SEGMENT
  191.         mov     es,ax
  192.         sub     di,di
  193.         mov     bp,SCREEN_HEIGHT/16
  194. BackdropBlockLoop:
  195.         call    DrawGridCross
  196.         call    DrawGridVert
  197.         dec     bp
  198.         jnz     BackdropBlockLoop
  199.         call    DrawGridCross
  200. AnimationLoop:
  201.         mov     bx,offset ObjectList
  202. ObjectLoop:
  203.         dec     [bx+Delay]
  204.         jnz     DoNextObject
  205.         mov     ax,[bx+BaseDelay]
  206.         mov     [bx+Delay],ax
  207.         mov     dx,SC_INDEX
  208.         mov     ah,[bx+PlaneSelect]
  209.         mov     al,MAP_MASK
  210.         OUT_WORD
  211.         mov     cx,[bx+XCoord]
  212.         cmp     cx,[bx+XLeftLimit]
  213.         ja      CheckXRightLimit
  214.         neg     [bx+XInc]
  215. CheckXRightLimit:
  216.         cmp     cx,[bx+XRightLimit]
  217.         jb      SetNewX
  218.         neg     [bx+XInc]
  219. SetNewX:
  220.         add     cx,[bx+XInc]
  221.         mov     [bx+XCoord],cx
  222.  
  223.         mov     dx,[bx+YCoord]
  224.         cmp     dx,[bx+YTopLimit]
  225.         ja      CheckYBottomLimit
  226.         neg     [bx+YInc]
  227. CheckYBottomLimit:
  228.         cmp     dx,[bx+YBottomLimit]
  229.         jb      SetNewY
  230.         neg     [bx+YInc]
  231. SetNewY:
  232.         add     dx,[bx+YInc]
  233.         mov     [bx+YCoord],dx
  234.  
  235.         mov     si,[bx+Image]
  236.         call    DrawObject
  237.  
  238. DoNextObject:
  239.         add     bx,size ObjectStructure
  240.         cmp     bx,offset ObjectListEnd
  241.         jb      ObjectLoop
  242.  
  243. if SLOWDOWN
  244.         mov     cx,SLOWDOWN
  245. DelayLoop:
  246.         loop    DelayLoop
  247. endif
  248.  
  249. CheckKey:
  250.         mov     ah,1
  251.         int     16h
  252.         jz      AnimationLoop
  253.         sub     ah,ah
  254.         int     16h
  255.         mov     ax,0003h
  256.         int     10h
  257.         mov     ah,4ch
  258.         int     21h
  259. Start   endp
  260.  
  261. DrawGridCross   proc    near
  262.         mov     ax,0ffffh
  263.         mov     cx,SCREEN_WIDTH/2-1
  264.         rep     stosw
  265.         mov     ax,0080h
  266.         stosw
  267.         ret
  268. DrawGridCross   endp
  269.  
  270. DrawGridVert    proc    near
  271.         mov     ax,0080h
  272.         mov     dx,15
  273. BackdropRowLoop:
  274.         mov     cx,SCREEN_WIDTH/2
  275.         rep     stosw
  276.         dec     dx
  277.         jnz     BackdropRowLoop
  278.         ret
  279. DrawGridVert    endp
  280.  
  281. DrawObject      proc    near
  282.         mov     ax,SCREEN_WIDTH
  283.         mul     dx
  284.         shr     cx,1
  285.         shr     cx,1
  286.         shr     cx,1
  287.         add     ax,cx
  288.         mov     di,ax
  289.         lodsw
  290.         mov     dx,ax
  291.         lodsw
  292.         mov     bp,SCREEN_WIDTH
  293.         sub     bp,ax
  294. DrawLoop:
  295.         mov     cx,ax
  296.         rep     movsb
  297.         add     di,bp
  298.         dec     dx
  299.         jnz     DrawLoop
  300.         ret
  301. DrawObject      endp
  302.  
  303.         END
  304.  
  305.  
  306.  
  307.