home *** CD-ROM | disk | FTP | other *** search
/ The Equalizer BBS / equalizer-bbs-collection_2004.zip / equalizer-bbs-collection / DEMOSCENE-STUFF / TUNNEL.ZIP / TUNNEL.ASM < prev    next >
Assembly Source File  |  1994-11-26  |  9KB  |  278 lines

  1. ;***************************************************************************
  2. ;
  3. ;                                   TUNNEL
  4. ;
  5. ;***************************************************************************
  6. ;
  7. ;                       Par jean-christophe Harivel
  8. ;
  9. ;***************************************************************************
  10. ;
  11. ;                  Prévu pour etre compilé avec TASM 3.1
  12. ;
  13. ;***************************************************************************
  14. ;
  15. ;      C'est mon premiere essai avec l'ASM, alors un peu d'indulgence ;)
  16. ;      Moi j'ai beaucoups apris,j'espere qu'il vous apprendra aussi...
  17. ;
  18. ;***************************************************************************
  19.  
  20.  
  21. DOSSEG
  22. .MODEL small
  23. .STACK 10h
  24. .DATA
  25.  
  26. px   dw 2048d dup (7fffh)
  27. py   dw 2048d dup (7fffh)
  28. pz   dw 2048d dup (?)
  29.  
  30. old  dw 2048d dup (0fffh)
  31. tps  dw 0
  32. tps2 dw 0
  33. tps3 dw 0
  34. costable dw    18d,   44d,   69d,   94d,  119d,  144d,  169d,  194d,  219d,  243d
  35.          dw   268d,  292d,  316d,  340d,  364d,  387d,  410d,  433d,  456d,  478d
  36.          dw   501d,  522d,  544d,  565d,  586d,  606d,  627d,  646d,  666d,  685d
  37.          dw   703d,  721d,  739d,  756d,  773d,  789d,  805d,  820d,  835d,  850d
  38.          dw   863d,  877d,  889d,  902d,  913d,  924d,  935d,  945d,  954d,  963d
  39.          dw   971d,  979d,  986d,  993d,  998d, 1004d, 1008d, 1012d, 1016d, 1019d
  40.          dw  1021d, 1022d, 1023d
  41. sintable dw  1024d, 1023d, 1022d, 1021d, 1019d, 1016d, 1012d, 1008d, 1004d,  998d
  42.          dw   993d,  986d,  979d,  971d,  963d,  954d,  945d,  935d,  924d,  913d
  43.          dw   902d,  889d,  877d,  863d,  850d,  835d,  820d,  805d,  789d,  773d
  44.          dw   756d,  739d,  721d,  703d,  685d,  666d,  646d,  627d,  606d,  586d
  45.          dw   565d,  544d,  522d,  501d,  478d,  478d,  456d,  433d,  410d,  387d
  46.          dw   364d,  340d,  316d,  292d,  268d,  243d,  219d,  194d,  169d,  144d
  47.          dw   119d,   94d,   69d,   44d,   18d,   -6d,  -31d,  -56d,  -81d, -107d
  48.          dw  -132d, -157d, -181d, -206d, -231d, -255d, -280d, -304d, -328d, -352d
  49.          dw  -375d, -399d, -422d, -445d, -467d, -489d, -511d, -533d, -555d, -576d
  50.          dw  -596d, -617d, -637d, -656d, -675d, -694d, -712d, -730d, -748d, -765d
  51.          dw  -781d, -797d, -813d, -828d, -843d, -857d, -870d, -883d, -896d, -908d
  52.          dw  -919d, -930d, -940d, -950d, -959d, -967d, -975d, -983d, -989d, -996d
  53.          dw -1001d,-1006d,-1010d,-1014d,-1017d,-1020d,-1022d,-1023d,-1024d,-1024d
  54.          dw -1023d,-1022d,-1020d,-1017d,-1014d,-1010d,-1006d,-1001d, -996d, -989d
  55.          dw  -983d, -975d, -967d, -959d, -950d, -940d, -930d, -919d, -908d, -896d
  56.          dw  -883d, -870d, -857d, -843d, -828d, -813d, -797d, -781d, -765d, -748d
  57.          dw  -730d, -712d, -694d, -675d, -656d, -637d, -617d, -596d, -576d, -555d
  58.          dw  -533d, -511d, -489d, -467d, -445d, -422d, -399d, -375d, -352d, -328d
  59.          dw  -304d, -280d, -255d, -231d, -206d, -181d, -157d, -132d, -107d,  -81d
  60.          dw   -56d,  -31d,   -6d,   18d,   44d,   69d,   94d,  119d,  144d,  169d
  61.          dw   194d,  219d,  243d,  268d,  292d,  316d,  340d,  364d,  387d,  410d
  62.          dw   433d,  456d,  478d,  501d,  522d,  544d,  565d,  586d,  606d,  627d
  63.          dw   646d,  666d,  685d,  703d,  721d,  739d,  756d,  773d,  789d,  805d
  64.          dw   820d,  835d,  850d,  863d,  877d,  889d,  902d,  913d,  924d,  935d
  65.          dw   945d,  954d,  963d,  971d,  979d,  986d,  993d,  998d, 1004d, 1008d
  66.          dw  1012d, 1016d, 1019d, 1021d, 1022d, 1023d
  67.  
  68. palette db  0, 3, 5, 6, 7, 8, 9,10,11,12,13,13,14,15,16,17
  69.         db 17,18,19,20,21,22,23,24,24,25,26,27,28,29,30,31
  70.         db 32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47
  71.         db 48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63
  72.         db 63,63,63,63,63,62,62,62,62,61,61,61,60,60,59,58
  73.         db 58,58,57,57,57,56,56,56,55,55,55,54,54,54,53,53
  74.         db 53,52,52,52,51,51,51,50,50,50,49,49,49,48,48,48
  75.         db 47,47,47,46,46,46,45,45,45,44,44,44,43,43,43,43
  76.         db 41,41,41,40,40,40,40,39,39,39,38,38,38,37,37,37
  77.         db 37,36,36,36,35,35,35,34,34,34,33,33,33,32,32,32
  78.         db 31,31,31,30,30,30,31,31,31,31,30,30,30,38,28,28
  79.         db 27,27,27,26,26,26,25,25,25,24,24,24,23,23,23,22
  80.         db 22,22,21,21,21,20,20,20,19,19,19,18,18,17,17,17
  81.         db 16,16,15,15,15,14,14,14,13,13,12,12,12,11,11,11
  82.         db 10,10,10, 9, 9, 9, 8, 8, 8, 8, 7, 7, 7, 6, 6, 6
  83.         db  5, 5, 5, 5, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2
  84.  
  85. .CODE
  86.  
  87.     mov ax,@data                 ;on positionne les pointeurs de segment
  88.     mov ds,ax
  89.     mov ax,0a000h
  90.     mov es,ax
  91.  
  92.     mov ax,0013h                 ;vga please !
  93.     int 10h
  94.  
  95. ;***************************************************************************
  96.  
  97.     mov cx,0ffh                  ;on initialise la palette
  98.     xor ax,ax
  99.     mov si,offset palette
  100. palette_loop:
  101.     mov dx,3c8h
  102.     mov al,ah
  103.     out dx,al
  104.     mov dx,3c9h
  105.     mov al,[si]
  106.     out dx,al
  107.     out dx,al
  108.     out dx,al
  109.     inc si
  110.     inc ah
  111.     loop palette_loop
  112.  
  113. ;***************************************************************************
  114.  
  115.     mov cx,2046d                 ;on initialise pz
  116.     mov si,offset pz
  117. init_pz:
  118.     mov ax,cx
  119.     cwd
  120.     mov bx,128d
  121.     div bx
  122.     sal dx,1
  123.     mov [si],dx
  124.     inc si
  125.     inc si
  126.     loop init_pz
  127.  
  128. ;***************************************************************************
  129.  
  130. Main_loop_begin:
  131.  
  132.     mov cx,2048d                 ;decalage des points du tunnel
  133.     xor si,si
  134. anim_loop:
  135.  
  136.     mov di,old[si]               ;d'abords on efface
  137.     mov byte ptr es:[di],0000h   ;un point tout noir! un!
  138.  
  139.     mov ax,pz[si]
  140.     cmp ax,3d                    ;si pz < 3 saut  a "remettre a 0"
  141.     jb  reset_px_py_pz
  142.  
  143.     sub ax,2d                    ;sinon reduit pz de 2
  144.     mov pz[si],ax
  145.  
  146. anim_end:
  147.  
  148.     push ax                      ;ax est toujours sur pz
  149.     add ax,32d                   ;et on y ajoute 32 pour pas faire merder
  150.     push ax                      ;la division
  151.     push ax
  152.                                     
  153.     mov ax,px[si]                ;coordonnees en x
  154.     cwd
  155.     pop bx
  156.     idiv bx
  157.     add ax,160d                  ;+160 pour recentrer
  158.     mov bx,ax
  159.  
  160.     cmp ax,319d                  ;si x hors de l'ecran
  161.     ja calcul_out_1              ;pas la peine d'aller plus loin
  162.  
  163.     mov ax,py[si]                ;coordonnees en y
  164.     cwd
  165.     pop di
  166.     idiv di
  167.     add ax,100d                  ;+100 pour recentrer
  168.  
  169.     cmp ax,199d                  ;si y hors de l'ecran
  170.     ja calcul_out_2              ;pas la peine d'aller plus loin
  171.  
  172.     mov di,320d
  173.     mul di                       ;calcul l'offset du pixel
  174.     add ax,bx
  175.  
  176.     mov old[si],ax               ;on le sauve dans old
  177.  
  178.     mov di,ax                    ;on l'affiche
  179.     pop ax
  180.     mov es:[di],ax
  181.  
  182.     jmp calcul_end
  183.  
  184.  
  185. calcul_out_1:
  186.     pop ax
  187. calcul_out_2:
  188.     pop ax
  189.                                   ;on entre une valeure hors de l'ecran
  190.     mov word ptr old[si],64001d   ;pour ne rien afficher
  191.  
  192. ;***************************************************************************
  193. calcul_end:
  194.  
  195.     inc si
  196.     inc si
  197.     loop anim_loop
  198.     jmp reset_end
  199.  
  200.  
  201. ;---------------------------------------------------------------------------
  202.  
  203. reset_px_py_pz:
  204.  
  205.     push si                      ;on calcul x
  206.     mov si,tps
  207.     mov ax,sintable[si]          ;on recupere sin(tps)
  208.     mov dx,12d
  209.     imul dx
  210.     mov di,ax                    ;on sauve tous ca dans di
  211.     mov si,tps2
  212.     mov ax,sintable[si]          ;on récupere sin(tps2)
  213.     mov bx,3d
  214.     imul bx
  215.     add ax,di                    ;on additionne les deux sinus
  216.  
  217.     pop si
  218.     mov px[si],ax                ;et on le stock
  219.     push si                      ;on calcul y
  220.  
  221.     mov si,tps
  222.     mov ax,costable[si]          ;on récupere cos(tps)
  223.     mov dx,7d
  224.     imul dx
  225.     mov di,ax
  226.     sal si,1                    ;on sauve dans di
  227.     mov si,tps3
  228.     mov ax,costable[si]          ;on récupere cos(tps3)
  229.     mov dx,2d
  230.     imul dx
  231.     add ax,di
  232.  
  233.     pop si
  234.     mov py[si],ax                ;et on le stock
  235.  
  236.     mov ax,tps
  237.  
  238.     add tps,18d
  239.     and tps,0111111111b
  240.  
  241.     mov ax,254d
  242.     mov word ptr pz[si],ax       ;on remet pz a 254
  243.  
  244.     jmp anim_end
  245.  
  246. reset_end:
  247.  
  248.  
  249. ;***************************************************************************
  250.  
  251.     add tps2,4                   ;on incrémente tps2 et tps3
  252.     and tps2,0111111111b
  253.     add tps3,2
  254.     and tps3,0111111111b
  255.  
  256.     mov dx,3dah                  ;on attends sagement le retour du signal
  257. VBL_loop:
  258.     in al,dx
  259.     test al,8
  260.     jz VBL_loop
  261.  
  262.     
  263. ;***************************************************************************
  264.  
  265.     mov dx,0060h                 ;on a appuyé sur une touche ?
  266.     in al,dx
  267.     cmp al,80
  268.     jb main_loop_end
  269.     jmp Main_loop_begin
  270.  
  271. main_loop_end:                   ;oui... alors kassos!
  272.     mov ax,0003h
  273.     int 10h
  274.     mov ah,4ch
  275.     int 21h
  276.  
  277. END
  278.