home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 4: The Falcon Archive / nf_archive_four_v1.0.iso / ARCHIVE / DEMOS / LAZER / LAZEROS.ZIP / LAZEROS / ROTATOR / ROT_02.S < prev    next >
Text File  |  1995-10-03  |  17KB  |  614 lines

  1.      OUTPUT    h:\dba\rot.PRG
  2.  
  3.     jmp    main
  4.     bra    init_rout
  5.     bra    exit_rout
  6.     bra    do_once
  7.  
  8. ;-----------------------------------------------------------
  9.     include startup.s
  10.     include    demo.s
  11. ;-----------------------------------------------------------
  12. BLITTER = $ffff8a00
  13.  
  14. HALFTONE    = 0
  15. SRC_XINC    = 32
  16. SRC_YINC    = 34
  17. SRC_ADDR    = 36
  18. ENDMASK1    = 40
  19. ENDMASK2    = 42
  20. ENDMASK3    = 44
  21. DST_XINC    = 46
  22. DST_YINC    = 48
  23. DST_ADDR    = 50
  24. X_COUNT        = 54
  25. Y_COUNT        = 56
  26. HOP        = 58
  27. OP        = 59
  28. LINE_NUM    = 60
  29. SKEW        = 61
  30.  
  31. FHOP_SOURCE    = 1
  32. FHOP_HALFTONE    = 0
  33. FSKEWFXSR    = 7
  34. FSKEWNFSR    = 6
  35. FLINEBUSY    = 7
  36. FLINEHOG    = 6
  37. FLINESMUDGE    = 5
  38.  
  39. MHOP_SOURCE    = $02
  40. MHOP_HALFTONE    = $01
  41. MSKEWFXSR    = $80
  42. MSKEWNFSR     = $40
  43. MLINEBUSY    = $80
  44. MLINEHOG    = $40
  45. MLINESMUDGE    = $20
  46.  
  47.  
  48. ;-----------------------------------------------------------
  49. ;-----------------------------------------------------------
  50. main
  51.     shrink_memory
  52.  
  53.     bsr    init
  54.     save_stack
  55.     bsr    phoenix_init
  56.  
  57.     save_interrupts
  58.     set_interrupts
  59.  
  60.         addi.w  #20,$FFFF8284.w
  61.     move.w    #0,$ffff820e
  62.     bsr    setup_logo
  63.     bsr    singen
  64.     bsr    setup_rotator
  65.  
  66. .main_loop
  67.     move.l    scr1,d0
  68.     move.l    scr2,scr1
  69.     move.l    d0,scr2
  70.     setscreen
  71.     vsync
  72.     
  73.     bset    #0,$ffff82c3.w        ;doublescan
  74.  
  75.     *move.l    #$4f0000,$ffff9800.w
  76.     bsr    rotator
  77.     *move.l    #$6f0000,$ffff9800.w
  78.  
  79.     move.l    #$0,$ffff9800.w
  80.  
  81.     tst.w    exit_flag
  82.     beq.s    .exit
  83.  
  84.     move.b    key,old_key
  85.     move.b    $fffffc02.w,key
  86.     cmp.b    #$39,key
  87.     bne    .main_loop
  88.  
  89. .exit
  90.  
  91.     restore_interrupts
  92.     bsr    phoenix_exit
  93.     restore_stack
  94.     bsr    exit
  95.     terminate
  96. ;-----------------------------------------------------------
  97. init_rout
  98.     move.l    a0,parameters
  99.  
  100.     move.l    parameters,a0
  101.     move.l    WORK_SCREEN(a0),scr1
  102.     move.l    SHOW_SCREEN(a0),scr2
  103.     move.l    EXTRA_SCREEN(a0),scr3
  104.  
  105.     rts
  106. ;-----------------------------------------------------------
  107. exit_rout
  108.     rts
  109. ;-----------------------------------------------------------
  110. do_once
  111.     move.l    parameters,a0
  112.     lea    rgb_320x200xtrue,a1
  113.     move.l    a1,SCRMODE(a0)
  114.     move.w    #TRUE,SCRMODE_UPDATE(a0)
  115.  
  116.     move.l    parameters,a0
  117.     move.w    #2,SCREEN_COUNT(a0)
  118.     move.w    #TRUE,SCREEN_SWAP(a0)
  119.  
  120.     move.l    parameters,a0
  121.     move.w    #TRUE,PALETTE_UPDATE(a0)
  122.     move.l    #coltab3,PALETTE(a0)
  123.     move.l    parameters,a0
  124.     move.l    WORK_SCREEN(a0),scr1
  125.     move.l    SHOW_SCREEN(a0),scr2
  126.     bsr    clrscr
  127.  
  128.         addi.w  #20,$FFFF8284.w
  129.     move.w    #0,$ffff820e
  130.     bsr    setup_logo
  131.     bsr    singen
  132.     bsr    setup_rotator
  133.  
  134.  
  135. taskloop
  136.     move.l    parameters,a0
  137.     move.l    WORK_SCREEN(a0),scr1
  138.     move.l    SHOW_SCREEN(a0),scr2
  139.  
  140.     bset    #0,$ffff82c3.w        ;doublescan
  141.     bsr    rotator
  142.  
  143.     demo_swapscreens
  144.  
  145.     bra    taskloop
  146. ;-----------------------------------------------------------
  147. ;-> a0...palette
  148. set_palette
  149.  
  150.     lea    coltab3,a1
  151.     move.w    #155,d0
  152. .1    move.l    (a1)+,(a0)+
  153.     dbf    d0,.1
  154.  
  155.     rts
  156. ;-----------------------------------------------------------
  157. setup_logo
  158.  
  159.         lea     maglogo+8(PC),A0
  160.         lea     orig_gfx,A1
  161.         move.w  #128-1,D0
  162. mag_l0  move.w  #128-1,D1
  163. mag_l1
  164. *        move.w  #-1,512(A1)
  165. *        move.w  #-1,256(A1)
  166. *        move.w  #-1,512+256(A1)
  167. *        move.w  #-1,(A1)+
  168.         move.w  (A0),512(A1)
  169.         move.w  (A0),256(A1)
  170.         move.w  (A0),512+256(A1)
  171.         move.w  (A0)+,(A1)+
  172.         dbra    D1,mag_l1
  173.     lea     256+512(A1),A1
  174.     dbra    D0,mag_l0
  175.  
  176.     rts
  177. ;-----------------------------------------------------------
  178. ;512 Werte im Padded-24-Format (für den DSP geeignet !)
  179. ;d.h. 0 ... $007fffff ... 0 ... $00800001 ...
  180. singen:
  181. size                    EQU 512 ;nicht ändern !
  182.  
  183. sin_gen:                lea     sin,A0
  184.                         moveq   #0,D6
  185.                         lea     size*2+4(A0),A1
  186.                         movea.l A0,A2
  187.                         moveq   #size/4-1,D7
  188. sin_gen1:               lea     sin_fakdiv+16,A3
  189.                         move.l  D6,D5
  190.                         moveq   #7,D2
  191. sin_gen2:               move.w  D2,D1
  192.                         move.l  D6,D3
  193. sin_gen3:               mulu.l  D6,D4:D3
  194.                         rol.l   #8,D3
  195.                         rol.l   #8,D4
  196.                         move.b  D3,D4
  197.                         move.l  D4,D3
  198.                         dbra    D1,sin_gen3
  199.                         divs.l  -(A3),D3
  200.                         add.l   D3,D5
  201.                         subq.w  #2,D2
  202.                         bcc.s   sin_gen2
  203. sin_gen4:               asr.l   #1,D5
  204.                         move.l  D5,(A0)+
  205.                         move.l  D5,-(A1)
  206.                         add.l   #$06487ED5/size,D6 ;2*pi*(2^24)
  207.                         dbra    D7,sin_gen1
  208.                         move.l  #$007FFFFF,-(A1)
  209.                         lea     size(A1),A1
  210.                         move.w  #size/2+size/4-1,D1
  211. sin_gen6:               move.l  (A2)+,(A1)
  212.                         neg.l   (A1)+
  213.                         dbra    D1,sin_gen6
  214.                         rts
  215. ;-----------------------------------------------------------
  216. setup_rotator
  217.                             ; Grafik doppeln
  218.                         lea     orig_gfx+2*65536,A0
  219.                         lea     gfx+4*65536,A1
  220.                         lea     helltab,A2
  221.                         moveq   #0,D1
  222.                         move.w  #$00010000>>1-1,D0
  223. rotator_gengfx_l0:      move.w  -(A0),D1
  224.                         move.w  D1,-(A1)
  225.                         move.w  0(A2,D1.l*2),-(A1)
  226.                         move.w  -(A0),D1
  227.                         move.w  0(A2,D1.l*2),-(A1)
  228.                         move.w  D1,-(A1)
  229.                         dbra    D0,rotator_gengfx_l0
  230.                         ; Inverse Grafik generieren
  231.                         lea     gfx,A0
  232.                         lea     inverse_gfx,A1
  233.                         moveq   #-1,D0
  234. rotator_genigfx_l0:     REPT 2
  235.                         move.w  (A0)+,D1
  236.                         move.w  D1,D2
  237.                         move.w  D2,D3
  238.                         and.w   #%0000000000011111,D1
  239.                         and.w   #%0000011111100000,D2
  240.                         and.w   #%1111100000000000,D3
  241.                         ror.w   #5,D1
  242.                         rol.w   #5,D3
  243.                         or.w    D2,D1
  244.                         or.w    D3,D1
  245.                         move.w  D1,(A1)+
  246.                         ENDR
  247.                         dbra    D0,rotator_genigfx_l0
  248.                         ; Doubletab generieren...
  249. abdunkelwert            EQU 4
  250.                         lea     doubletab,A0
  251.                         move.l  #$0000FFFF,D0
  252. rota_gendouble_l0:      move.w  D0,D1
  253.                         and.w   #%0000000000011111,D1
  254.                         subq.w  #abdunkelwert,D1
  255.                         bpl.s   rota_gendouble_w0
  256.                         moveq   #0,D1
  257. rota_gendouble_w0:      move.w  D0,D2
  258.                         and.w   #%0000011111100000,D2
  259.                         sub.w   #abdunkelwert<<6,D2
  260.                         bmi.s   rota_gendouble_w2
  261.                         or.w    D2,D1
  262. rota_gendouble_w2:      move.w  D0,D2
  263.                         and.w   #%1111100000000000,D2
  264.                         sub.w   #abdunkelwert<<11,D2
  265.                         bcs.s   rota_gendouble_w3
  266.                         or.w    D2,D1
  267. rota_gendouble_w3:      move.w  D1,0(A0,D0.l*4)
  268.                         move.w  D1,2(A0,D0.l*4)
  269.                         dbra    D0,rota_gendouble_l0
  270.                         ;»w%=30
  271.                         move.w  #0,w
  272.                         ;»si%=SINQ(w%)*65536
  273.  
  274.             rts
  275. ;-----------------------------------------------------------
  276. rotator
  277.                         bsr     gen_rotdist
  278.  
  279.                         lea     sin,A0
  280.                         move.w  w,D0
  281.                         move.l  0(A0,D0.w*4),si
  282.  
  283.                         moveq   #8,D3
  284.                         move.l  si,D6
  285.                         asr.l   D3,D6
  286.                         move.l  D6,si
  287.                         ;»co%=COSQ(w%)*65536
  288.                         lea     cos,A0
  289.                         move.l  0(A0,D0.w*4),co
  290.  
  291.                         move.l  co,D6
  292.                         asr.l   D3,D6
  293.                         move.l  D6,co
  294.  
  295.                         lea     gfx+128*1024,A0
  296.                         tst.b   inverse
  297.                         beq.s   rotator_w2
  298.                         *adda.l  #256*256*4,A0
  299.                         subq.b  #1,inverse
  300. rotator_w2:             move.l     scr1,A1
  301.             add.l    #640*200/2,a1
  302.  
  303.                         lea     rotdist+100*4,A4
  304.                             ;»FOR y%=-50 TO 49
  305.                         move.l  #-50,y
  306. rotator_next_y:         move.l  -(A4),D6
  307.                         cmp.l   #$00000A00,D6
  308.                         ble.s   dorot
  309.                         move.w  #640/4-1,D7
  310. norot_l0:
  311.                         move.l  #0,-(A1)
  312.                         dbra    D7,norot_l0
  313.                         bra     norot
  314. dorot:                    ;»xstart%=(-50*faktor%) DIV 256
  315.                         move.l  #-80,D3
  316.                         muls    D6,D3
  317.                         asr.l   #8,D3
  318.                     ;»ystart%=(y%*faktor%) DIV 256
  319.                         move.l  y,D4
  320.                         add.l   #70-20,D4
  321.                         muls    D6,D4
  322.                         asr.l   #8,D4
  323.                     ;»xpos%=xstart%*si%+ystart%*co%
  324.                     ;»ypos%=ystart%*si%-xstart%*co%
  325.                         move.l  D3,D0
  326.                         move.l  D4,D1
  327.                         muls.l  si,D0
  328.                         muls.l  co,D4
  329.                         add.l   D4,D0
  330.                         muls.l  si,D1
  331.                         muls.l  co,D3
  332.                         sub.l   D3,D1
  333.                     ;»xofs%=(si%*faktor%) DIV 256
  334.                         move.l  si,D2
  335.                         muls.l  D6,D2
  336.                         clr.w   D2
  337.                         swap    D2
  338.                     ;»yofs%=-(co%*faktor%) DIV 256
  339.                         move.l  co,D3
  340.                         muls.l  D6,D3
  341.                         asr.l   #8,D3
  342.                     ;»FOR x%=0 TO 99
  343.                         neg.l   D3
  344.                         lsr.l   #8,D0
  345.                         swap    D1
  346.                         swap    D3
  347.                         move.l  D1,D7
  348.                         clr.w   D7
  349.                         add.l   D7,D0
  350.                         move.l  D3,D7
  351.                         clr.w   D7
  352.                         add.l   D7,D2
  353.                         move.w  #160/10-1,D7
  354. rotator_next_x:
  355. ;»WORD{scrcntr%+(ypos% DIV 65536)*640+(xpos% DIV 65536)*2}=-1
  356. ; d0 xpos  yn|00|xv|xn
  357. ; d1 ypos  00|00|00|yv
  358. ; d2 xofs  yn|00|xv|xn
  359. ; d3 yofs  00|00|00|yv
  360.                         REPT 10
  361.                         move.w  D0,D4
  362.                         move.b  D1,D4
  363.                         move.l  0(A0,D4.w*4),-(A1)
  364.                         *move.l  #-1,-(A1)
  365.                         add.l   D2,D0
  366.                         addx.b  D3,D1
  367.                         ENDR
  368.                         ;»NEXT x%
  369.                         dbra    D7,rotator_next_x
  370.                         ;»ADD faktor%,3
  371.                         ;»NEXT y%
  372. norot:
  373.                         addq.l  #1,y
  374.                         cmpi.l  #50,y
  375.                         bne     rotator_next_y
  376.  
  377. *                        addi.w  #3+2,w
  378.                         cmpi.w  #512,w
  379.                         blt.s   rotator_winkel_w0
  380.                         subi.w  #512,w
  381. rotator_winkel_w0:
  382. rotator_w0:
  383.                         rts
  384.  
  385. inverse:    dc.w    0
  386. ;-----------------------------------------------------------
  387. ;> a = 60                      d0   <<20
  388. ;> b = 20
  389. ;> aofs = b/100                d1   <<20
  390. ;> h = 50                      d2   <<20
  391. ;» FOR c=0 TO 99               d3
  392. ;»   d=h/(TAN(RAD(a))/16)      d4
  393. ;»   PRINT #1,MKL$(d);
  394. ;»   ADD a,aofs
  395. ;» NEXT c
  396. gen_rotdist:
  397.                         lea     splinewerte,A0
  398.                         lea     splines,A1
  399.                         move.w  splinecnt,D0
  400.                         moveq   #3-1,D6
  401.                         bsr     spline
  402.  
  403.             cmp.w    #$150*3,splinecnt
  404. *            beq.s    .1
  405.                         add.w   #$0150,splinecnt
  406.                         andi.w  #$7FFF,splinecnt
  407. .1
  408.                         lea     splinewerte,A0
  409.                         moveq   #0,D0
  410.                         move.w  (A0)+,D0
  411.                         lsl.l   #8,D0
  412.  
  413.                         moveq   #0,D1
  414.                         move.w  (A0)+,D1
  415.                         lsl.l   #8,D1
  416.  
  417.                         moveq   #0,D2
  418.                         move.w  (A0)+,D2
  419.                         lsl.l   #8,D2
  420.  
  421.                         lea     rotdist,A0
  422.                         lea     tan,A1
  423.                         moveq   #128-1,D3
  424. gen_rotdist_l0:         move.l  D2,D4
  425.                         move.l  D0,D5
  426.                         swap    D5
  427.                         ext.l   D5
  428.                         divs.l  0(A1,D5.w*4),D4
  429.                         move.l  D4,(A0)+
  430.                         add.l   D1,D0
  431.                         dbra    D3,gen_rotdist_l0
  432.  
  433.                         rts
  434. ;-----------------------------------------------------------
  435. spline:
  436.                         moveq   #15,D7
  437. .l0:                    lea     tbuff,A2
  438.                         move.l  D0,D1
  439.                         eori.w  #$7FFF,D0 ; t2%   d1
  440.                         move.w  D0,D2
  441.                         move.w  D1,D3
  442.                         mulu    D0,D2
  443.                         lsr.l   D7,D2   ; t_2
  444.                         move.w  D2,D4
  445.                         mulu    D0,D4
  446.                         lsr.l   D7,D4   ; t_3  >>1
  447.                         move.w  D4,(A2)+
  448.                         move.w  D1,D4
  449.                         mulu    D2,D4
  450.                         lsr.l   D7,D4   ; 3*t_2_m_t2 >>2
  451.                         move.w  D4,(A2)+
  452.                         mulu    D1,D3
  453.                         lsr.l   D7,D3
  454.                         move.w  D3,D4
  455.                         mulu    D0,D4
  456.                         lsr.l   D7,D4   ; 3*t_m_t2_2 >>3
  457.                         move.w  D4,(A2)+
  458.                         mulu    D1,D3
  459.                         lsr.l   D7,D3   ; t2_3 >>4
  460.                         move.w  D3,(A2)+
  461. .l1:                    lea     tbuff,A2
  462.                         move.w  (A2)+,D1
  463.                         muls    (A1)+,D1
  464.                         REPT 2
  465.                         move.w  (A2)+,D2
  466.                         muls    (A1)+,D2
  467.                         muls.l  #3,D2
  468.                         add.l   D2,D1
  469.                         ENDR
  470.                         move.w  (A2)+,D2
  471.                         muls    (A1)+,D2
  472.                         add.l   D2,D1
  473.                         add.l   D1,D1
  474.                         swap    D1
  475.                         move.w  D1,(A0)+
  476.                         dbra    D6,.l1
  477.  
  478.                         rts
  479. ;-----------------------------------------------------------
  480. splinewerte:            DS.W 10
  481. splines:                DC.W $A000,$A000,$A000,$0000
  482.                         DC.W $0000,$0000,$0000,$0D00
  483.                         DC.W $0000,$3000,-$1000,$3000+$2000
  484. splinecnt:              DC.W 0
  485. sin_fakdiv:             DC.L -6,120,-5040,362880 ;-3!, 5!, -7!, 9!
  486. ;-----------------------------------------------------------
  487.  
  488.  
  489.  
  490. ;-----------------------------------------------------------
  491. clrscr
  492.     move.l    scr1,a5
  493.     move.l    scr2,a6
  494.     moveq    #0,d0
  495.     moveq    #0,d1
  496.     moveq    #0,d2
  497.     moveq    #0,d3
  498.     moveq    #0,d4
  499.     moveq    #0,d5
  500.     moveq    #0,d6
  501.     move.l    d0,a0
  502.     move.l    d0,a1
  503.     move.l    d0,a2
  504.  
  505.     move.w    #489,d7
  506. .1    
  507.     rept    10
  508.     movem.l    d0-d6/a0-a2,(a5)
  509.     movem.l    d0-d6/a0-a2,(a6)
  510.     lea    40(a5),a5
  511.     lea    40(a6),a6
  512.     endr
  513.     dbf    d7,.1
  514.     rts
  515. ;-----------------------------------------------------------
  516. vbl
  517.  
  518. old_vbl    jmp    $12345678
  519.     rte
  520. ;-----------------------------------------------------------
  521. init
  522.     clr_bss
  523.  
  524.     super_on
  525.     mouse_off
  526.  
  527.     cache_on
  528.  
  529.         move.l  $44e.w,old_screen
  530.     save_resolution
  531.  
  532.     move.l    #screens+256,d0
  533.     clr.b    d0
  534.     move.l    d0,scr1
  535.     add.l    #384*240*2,d0
  536.     move.l    d0,scr2
  537.     add.l    #384*240*2,d0
  538.     move.l    d0,scr3
  539.  
  540.     move.l    scr1,d0
  541.     setscreen
  542.  
  543.     lea    rgb_320x200xtrue,a0
  544.     set_resolution
  545.  
  546.     move.l    #0,$ffff9800.w
  547.         rts
  548. ;-----------------------------------------------------------
  549. exit
  550.     
  551.     move.l    old_screen,d0
  552.     setscreen
  553.     restore_resolution
  554.  
  555.     mouse_on
  556.     super_off
  557.     rts
  558. ;-----------------------------------------------------------
  559.  
  560.  
  561.  
  562. ;-----------------------------------------------------------
  563. scr1        dc.l    0
  564. scr2        dc.l    0
  565. scr3        dc.l    0
  566.  
  567. exit_flag    dc.w    -1
  568.  
  569. ;-----------------------------------------------------------
  570. coltab3    REPT 256
  571.     dc.l    0
  572.     ENDR
  573.  
  574. maglogo        incbin yy.tru
  575. magnetic
  576.  
  577. tan        incbin tan.bin
  578. ;-----------------------------------------------------------
  579.  
  580.     even
  581.  
  582.     section bss
  583.  
  584.     ds.l    1000
  585. mystack        ds.l    0
  586.  
  587. start_bss
  588.  
  589. rotdist:                DS.L 128
  590. schrift_scroll:         DS.L 1
  591. schrift_sub:            DS.L 1
  592. schrift_pos:            DS.L 1
  593. schrift_block:          DS.L 1
  594. sin:                    DS.L 512/4
  595. cos:                    DS.L 512
  596. w:                      DS.W 1
  597. si:                     DS.L 1
  598. co:                     DS.L 1
  599. y:                      DS.L 1
  600. doubletab:              REPT 4
  601.                         DS.L 65536/2
  602.                         ENDR
  603. brightness:             DS.L 1
  604. helltab:                DS.L 65536/2
  605. gfx:                    DS.L 256*256
  606. inverse_gfx:            DS.L 256*256
  607. tbuff:                  DS.L 6
  608.  
  609. orig_gfx    ds.w    128*128*4
  610.  
  611. screens        ds.w    3*384*240+256
  612.  
  613. end_bss
  614.