home *** CD-ROM | disk | FTP | other *** search
/ Fujiology Archive / fujiology_archive_v1_0.iso / !FALCON / !BONUS / WHIPPLUG / RIPPLES.ZIP / ripples / src / ripples.s < prev    next >
Text File  |  1999-10-16  |  13KB  |  671 lines

  1. ;
  2. ; VLM EXAMPLE MODULE                                             NO/Escape'98
  3. ;
  4.  
  5. numb_cols:    equ    256
  6. baseriple:    equ    64
  7. basedeep:    equ    64
  8.  
  9.  
  10.         section    text
  11.  
  12. *** VLM STRUCTURE **************************************************************
  13.  
  14.         dc.b    "VLM2"        ;vlm module type
  15.         dc.l    infotext    ;pointer to infotext
  16.         dc.l    settings    ;pointer to settings-structure
  17.         dc.l    init        ;pointer to init routine
  18.         dc.l    deinit        ;pointer to deinit routine
  19.         dc.l    main        ;pointer to mainloop routine
  20.  
  21. ;SERVICE ROUTINES PROVIDED BY THE CALLING PROGRAM
  22.  
  23. set_vblrout:
  24. ;a0: new vbl subroutine
  25.         movea.l service_struct,a1
  26.         movea.l (a1),a1
  27.         jsr     (a1)
  28.         rts
  29.  
  30. wait_vbl:    movea.l    service_struct,a1
  31.         movea.l    4(a1),a1
  32.         jsr    (a1)
  33.         rts
  34.  
  35. set_scradr:
  36. ;a0: new screen adress
  37.         movea.l    service_struct,a1
  38.         movea.l    8(a1),a1
  39.         jsr    (a1)
  40.         rts
  41.  
  42. set_resolution:
  43. ;d0: number of the wanted resolution
  44.         movea.l    service_struct,a1
  45.         movea.l    12(a1),a1
  46.         jsr    (a1)
  47.         rts
  48.  
  49. get_left_spec:    movea.l    service_struct,a1
  50.         movea.l    16(a1),a1
  51.         jsr    (a1)        ;returns in a0 the adress of left spec
  52.                 rts
  53.  
  54. get_right_spec:    movea.l    service_struct,a1
  55.         movea.l    20(a1),a1
  56.         jsr    (a1)            ;returns in a0 the adress of right spec
  57.         rts
  58.  
  59. get_left_volume:movea.l    service_struct,a1
  60.         movea.l 24(A1),A1
  61.         jsr    (A1)        ;returns in d0 the left volume value
  62.         rts
  63.  
  64. get_right_volume:
  65.         movea.l service_struct,a1
  66.         movea.l 28(a1),a1
  67.         jsr    (a1)        ;returns in d0 the right volume value
  68.         rts
  69.  
  70. get_left_osci:    movea.l service_struct,a1
  71.         movea.l    32(A1),a1
  72.         jsr    (a1)        ;returns in a0 the adress of osci data
  73.         rts
  74.  
  75. get_right_osci:    movea.l    service_struct,a1
  76.         movea.l    36(a1),a1
  77.         jsr    (a1)        ;returns in a0 the adress of osci data
  78.         rts
  79.  
  80. service_struct:    dc.l    0        ;must be set in 'init'
  81.  
  82. ********************************************************************************
  83. infotext:       
  84.         dc.b    ' plugin: ripples',0
  85.         dc.b    ' author: evil ',0
  86.         dc.b    'version: 1.0',0
  87.         dc.b    '   date: october 16, 1999',0
  88.         dc.b    0
  89.         even
  90.  
  91. settings:       dc.l    6
  92.  
  93.         dc.l    layername
  94.         dc.l    2
  95. layermode:    dc.l    0
  96.         dc.l    layerstruct
  97.  
  98.         dc.l    typename
  99.         dc.l    2
  100. type:        dc.l    0
  101.         dc.l    typestruct
  102.  
  103.  
  104.         dc.l    ripplename
  105.         dc.l    2
  106. ripplesize:    dc.l    1
  107.         dc.l    ripplestruct
  108.  
  109.  
  110.         dc.l    deepname
  111.         dc.l    2
  112. rippledepth:    dc.l    1
  113.         dc.l    deepstruct
  114.  
  115.         dc.l    brightname
  116.         dc.l    3
  117. brightness:    dc.l    6
  118.         dc.l    brightstruct
  119.  
  120.         dc.l    brmusicname
  121.         dc.l    2
  122. brmusic:    dc.l    1
  123.         dc.l    brmusicstruct
  124.  
  125.  
  126.  
  127. layername:    dc.b    "LAYER SELECTION:",0
  128.         even
  129. layerstruct:    dc.l    2
  130.         dc.b    "SINGLE LAYER",0
  131.         dc.b    "MULTIPLE LAYERS",0
  132.         even
  133.  
  134. ripplename:    dc.b    "NUMBER OF RIPPLES",0
  135.         even
  136. ripplestruct:    dc.l    3
  137.         dc.b    "SJOBRIS (FEW)",0
  138.         dc.b    "SURFING (SOME)",0
  139.         dc.b    "ESTONIA (ALOT!)",0
  140.         even
  141.  
  142. deepname:    dc.b    "RIPPLE DEPTH",0
  143.         even
  144. deepstruct:    dc.l    3
  145.         dc.b    "RED SEA (BORING)",0
  146.         dc.b    "BALTIC SEA (OK)",0
  147.         dc.b    "NORTH SEA (SEASICK!)",0
  148.         even
  149.  
  150. brightname:    dc.b    "BRIGHTNESS (M-LAYER)",0
  151.         even
  152. brightstruct:    dc.l    0,63
  153.         even
  154.  
  155. brmusicname:    dc.b    "FLASHING (M-LAYER)",0
  156.         even
  157. brmusicstruct:    dc.l    2
  158.         dc.b    "NO",0
  159.         dc.b    "YES",0
  160.         even
  161.  
  162. typename:    dc.b    "RIPPLE SOURCE",0
  163.         even
  164. typestruct:    dc.l    2
  165.         dc.b    "DEEP BASS",0
  166.         dc.b    "VOLUME",0
  167.         even
  168.  
  169.  
  170.  
  171.  
  172.  
  173. init:           move.l    a0,service_struct
  174.         bsr.w    whip_init
  175.         bsr.w    clear_screens
  176.         movea.l    scradr2,a0
  177.         bsr.w    set_scradr
  178.         move.l    #2,d0
  179.         bsr.w    set_resolution
  180.         lea.l    vbl,a0
  181.         jsr    set_vblrout
  182.                 rts
  183.  
  184. deinit:        rts
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192. main:        jsr    switch_screens
  193.         clr.l    d1
  194.         clr.l    d0
  195.         tst.l    type
  196.         bne.s    .vol
  197. .bass:        bsr.w    get_right_spec
  198.         move.w    (a0)+,d0
  199.         lsr.w    #1,d0
  200.         move.w    (a0)+,d1
  201.         lsr.w    #1,d1
  202.         add.w    d1,d0
  203.         bsr.w    get_left_spec
  204.         lsr.w    #1,d0
  205.         move.w    (a0)+,d1
  206.         lsr.w    #1,d1
  207.         add.w    d1,d0
  208.         lsr.w    #1,d0
  209.         move.w    (a0)+,d1
  210.         lsr.w    #1,d1
  211.         add.w    d1,d0
  212.         move.w    d0,d1
  213.         move.w    d0,d2
  214.         lsr.w    #8,d1
  215.         lsr.w    #1,d1
  216.         bra.s    .rippledo
  217. .vol:        bsr.w    get_left_volume
  218.         move.w    d0,d1
  219.         lsr.w    #1,d1
  220.         bsr.w    get_right_volume        
  221.         lsr.w    #1,d0
  222.         add.w    d0,d1
  223.         move.w    d1,d2
  224.         lsr.w    #7,d1
  225. .rippledo:    move.w    deepshift,d3
  226.         lsr.w    d3,d2
  227.         move.w    mulsval,d3
  228.         cmp.w    d3,d1
  229.         blt.s    .no
  230.         move.w    d1,mulsval
  231.         move.w    d2,deepmul
  232. .no:        cmp.l    #2,ripplesize
  233.         bne.s    .next1
  234.         move.l    #60*3,rippleadd
  235.         bra.s    .rippledone
  236. .next1:        cmp.l    #1,ripplesize
  237.         bne.s    .next2
  238.         move.l    #60*2,rippleadd
  239.         bra.s    .rippledone
  240. .next2:        move.l    #60*1,rippleadd
  241. .rippledone:    cmp.l    #2,rippledepth
  242.         bne.s    .next3
  243.         move.w    #6,deepshift
  244.         bra.s    .deepdone
  245. .next3:        cmp.l    #1,rippledepth
  246.         bne.s    .next4
  247.         move.w    #7,deepshift
  248.         bra.s    .deepdone
  249. .next4:        move.w    #8,deepshift
  250. .deepdone:    tst.l    layermode
  251.         bne.s    .multi
  252.         bsr.w    whip_main2
  253.         bra.s    .done
  254. .multi:        move.l    brightness,d0
  255.         lsl.w    #8,d0
  256.         lsl.w    #2,d0
  257.         move.l    d0,brightnessadd
  258.         tst.l    brmusic
  259.         beq.s    .nobrmusic
  260.         clr.l    d1
  261.         bsr.w    get_left_volume
  262.         lsr.w    #1,d0
  263.         move.w    d0,d1
  264.         bsr.w    get_right_volume
  265.         add.w    d0,d1
  266.         and.w    #$fc00,d1
  267.         move.l    d1,brightnessvol
  268.         bra.s    .brmusicdone
  269. .nobrmusic:    clr.l    brightnessvol
  270. .brmusicdone:    bsr.w    whip_main
  271. .done:        rts        
  272.  
  273.  
  274. vbl:        bsr.w    whip_vbl
  275.         rts
  276.  
  277. ; ------------------------------------------------------
  278. ; EFX MAINLOOP
  279. ; ------------------------------------------------------
  280.  
  281. whip_main:    move.l    scradr1,a0
  282.         lea.l    spiral,a1
  283.         lea.l    palette,a2
  284.         lea.l    texture,a4
  285.         lea.l    light,a5
  286.         add.l    brightnessvol,a2
  287.         add.l    brightnessadd,a2
  288.         add.l    texture_pos,a4
  289.         lea.l    ringlist,a6
  290.         clr.l    d0
  291.         clr.l    d1
  292.         clr.l    d2
  293.         clr.l    d3
  294.         move.w    #280/2-1,d7
  295. .varv:        move.w    (a6)+,d6
  296.         move.l    rippleadd,d5
  297.         add.l    d5,sin
  298.         and.l    #$1fff,sin
  299.         lea.l    sinus,a3
  300.                 move.l    sin,d5
  301.                 move.l    (a3,d5.w),d5
  302.         move.w    mulsval,d4
  303.         muls.w    d4,d5
  304.         asr.l    #8,d5
  305.                 asr.l    #7,d5
  306.         lsl.l    #2,d5
  307.         lea.l    4096(a3),a3
  308.                 move.l    (a3,d5.w),d5
  309.         move.w    deepmul,d4
  310.                 muls.w    d4,d5
  311.                 asr.l    #8,d5
  312.                 asr.l    #7,d5
  313.         add.l    d5,d5
  314.         move.l    d5,sinpos
  315.         lea.l    ringtexture,a3
  316.         add.l    sinpos,a3
  317.         move.l    a6,d5
  318.         lea.l    logo,a6
  319. .ring:        move.w    (a1)+,d0
  320.         move.w    (a5,d0.w),d1
  321.         move.w    (a4,d1.l*2),d1
  322.         add.w    (a3,d0.w),d1
  323.         add.w    (a6,d0.w),d1
  324.         move.l    (a2,d1.l*4),(a0,d0.w*2)
  325.         dbra    d6,.ring
  326.         move.l    d5,a6
  327.         dbra    d7,.varv
  328.         bsr.w    bugfix
  329.         rts
  330.  
  331. whip_main2:    move.l    scradr1,a0
  332.         lea.l    spiral,a1
  333.         lea.l    ringlist,a6
  334.         clr.l    d0
  335.         clr.l    d1
  336.         move.w    #280/2-1,d7
  337. .varv:        move.w    (a6)+,d6
  338.         move.l    rippleadd,d5
  339.         add.l    d5,sin
  340.         and.l    #$1fff,sin
  341.         lea.l    sinus,a3
  342.                 move.l    sin,d5
  343.                 move.l    (a3,d5.w),d5
  344.         move.w    mulsval,d4
  345.         muls.w    d4,d5
  346.         asr.l    #8,d5
  347.                 asr.l    #7,d5
  348.         lsl.l    #2,d5
  349.         lea.l    4096(a3),a3
  350.                 move.l    (a3,d5.w),d5
  351.         move.w    deepmul,d4
  352.                 muls.w    d4,d5
  353.                 asr.l    #8,d5
  354.                 asr.l    #7,d5
  355.         add.l    d5,d5
  356.         move.l    d5,sinpos
  357.         lea.l    ringtexture2,a3
  358.         add.l    sinpos,a3
  359. .ring:        move.w    (a1)+,d0
  360.         move.l    (a3,d0.l*2),(a0,d0.l*2)
  361.         dbra    d6,.ring
  362.         dbra    d7,.varv
  363.         bsr.w    bugfix
  364.         rts
  365.  
  366. ; lame offsetbug workarounds...
  367. bugfix:        move.l    scradr1,a0
  368.         move.l    640*48+312(a0),640*48+316(a0)
  369.         move.l    640*50+312(a0),640*49+316(a0)
  370.         move.l    640*49+308(a0),640*49+312(a0)
  371.         move.l    640*48+320(a0),640*49+320(a0)
  372.         move.l    640*50+320(a0),640*50+316(a0)
  373.         move.l    scradr1,a0
  374.         lea.l    60(a0),a0
  375.         move.l    a0,a1
  376.         add.l    #640*99,a1
  377.         move.w    #520/4-1,d7
  378. .lineclr:    clr.l    (a0)+
  379.         clr.l    (a1)+
  380.         dbra    d7,.lineclr
  381.         move.l    scradr1,a0
  382.         lea.l    640+64(a0),a0
  383.         lea.l    512-4(a0),a1
  384.         move.w    #100-3,d7
  385. .colclr:    clr.l    (a0)
  386.         clr.l    (a1)
  387.         lea.l    640(a0),a0
  388.         lea.l    640(a1),a1
  389.         dbra    d7,.colclr
  390.         rts
  391.  
  392.  
  393.  
  394.  
  395. ; ------------------------------------------------------
  396. ; EFX VBL
  397. ; ------------------------------------------------------
  398.  
  399. whip_vbl:    add.l    #24,sin
  400.         and.l    #$1fff,sin
  401.         sub.l    #512,texture_pos
  402.         and.l    #$1ffff,texture_pos
  403.         tst.w    deepmul
  404.         beq.s    .next
  405.         cmp.w    #7,deepmul
  406.         blt.s    .deepclr
  407.         sub.w    #8,deepmul
  408.         bra.s    .next
  409. .deepclr:    clr.w    deepmul
  410. .next:        tst.w    mulsval
  411.         beq.s    .ok
  412.         cmp.w    #3,mulsval
  413.         blt.s    .mulsclr
  414.         subq.w    #4,mulsval
  415.         bra.s    .ok
  416. .mulsclr:    clr.w    mulsval
  417. .ok:        rts
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424. ; ------------------------------------------------------
  425. ; EFX INIT
  426. ; ------------------------------------------------------
  427.  
  428. whip_init:    tst.l    layermode
  429.         beq.w    .singleinit
  430.         lea.l    rawpal+20+512,a0
  431.         lea.l    palette+1024*63,a1
  432.         move.w    #256-1,d7
  433. .loop:        move.w    (a0),(a1)+
  434.         move.w    (a0)+,(a1)+
  435.         dbra    d7,.loop
  436.         lea.l    palette,a0
  437.         lea.l    palette+1024*63,a1
  438.         bsr.w    make_palette
  439.         lea.l    rawpal+20+512*2,a0
  440.         lea.l    palette+1024*127,a1
  441.         move.w    #256-1,d7
  442. .loop2:        move.w    (a0),(a1)+
  443.         move.w    (a0)+,(a1)+
  444.         dbra    d7,.loop2
  445.         lea.l    palette+1024*63,a0
  446.         lea.l    palette+1024*127,a1
  447.         bsr.w    make_palette
  448.         lea.l    palette+1024*128,a0
  449.         moveq.l    #-1,d0    
  450.         move.w    #1024*128/4-1,d7
  451. .whiteloop:    move.l    d0,(a0)+
  452.         dbra    d7,.whiteloop
  453.         lea.l    rawtexture+788,a0
  454.         lea.l    texture,a1
  455.         lea.l    texture+512,a2
  456.         clr.l    d0
  457.         move.w    #128-1,d7
  458. .txtloop:    move.w    #128-1,d6
  459. .txtloop2:    move.b    (a0)+,d0
  460.         move.w    d0,(a1)+
  461.         move.w    d0,-(a2)
  462.         dbra    d6,.txtloop2
  463.         lea.l    256(a1),a1
  464.         lea.l    512+256(a2),a2
  465.         dbra    d7,.txtloop
  466.         lea.l    texture,a0
  467.         lea.l    texture+512*255,a1
  468.         move.w    #128-1,d7
  469. .mirror:    move.w    #256/2-1,d6
  470. .mirror2:    move.l    (a0)+,(a1)+
  471.         dbra    d6,.mirror2
  472.         lea.l    -1024(a1),a1
  473.         dbra    d7,.mirror
  474.         lea.l    texture,a0
  475.         lea.l    texture+256*256*2,a1
  476.         move.w    #256*256-1,d7
  477. .gfxcopy:    clr.l    d0
  478.         move.w    (a0),d0
  479.         lsl.w    #8,d0
  480.         lsl.w    #1,d0
  481.         move.w    d0,(a0)+
  482.         move.w    d0,(a1)+
  483.         dbra    d7,.gfxcopy
  484.         lea.l    rawlogo+788,a0
  485.         lea.l    logo,a1
  486.         move.w    #160*100-1,d7
  487. .logoreduce:    clr.l    d0
  488.         move.b    (a0)+,d0
  489.         lsl.w    #8,d0
  490.         move.w    d0,(a1)+
  491.         dbra    d7,.logoreduce
  492.         lea.l    rawring+788,a0
  493.         lea.l    ringtexture,a1
  494.         clr.l    d0
  495.         move.w    #160*100-1,d7
  496. .ring:        move.b    (a0)+,d0
  497.         move.w    d0,(a1)+
  498.         dbra    d7,.ring
  499.         rts
  500.  
  501. .singleinit:    lea.l    rawring2+20,a0
  502.         lea.l    ringtexture2,a1
  503.         clr.l    d0
  504.         move.w    #160*100-1,d7
  505. .ring2:        move.w    (a0)+,d0
  506.         move.w    d0,(a1)+
  507.         move.w    d0,(a1)+
  508.         dbra    d7,.ring2
  509.         rts
  510.  
  511.  
  512.  
  513. ; ------------------------------------------------------
  514. ; EFX COLOURS
  515. ; ------------------------------------------------------
  516.  
  517. make_palette:
  518.         moveq.l    #0,d2
  519.         moveq.l    #0,d3
  520.         move.w    #numb_cols-1,d7
  521. .colour:    move.l    a0,a2
  522.         move.l    a1,a3
  523.         addq.l    #4,a0
  524.         addq.l    #4,a1
  525.         swap    d7
  526.         move.w    #64-2,d7
  527. .step:        move.w    (a2),d0
  528.         lea.l    numb_cols*4(a2),a2
  529.         move.w    (a3),d1
  530. .red:        move.w    d0,d2
  531.         and.w    #%1111100000000000,d2
  532.         rol.w    #5,d2
  533.         move.w    d1,d3
  534.         and.w    #%1111100000000000,d3
  535.         rol.w    #5,d3
  536.         tst.w    .var
  537.         beq.s    .redok
  538.         cmp.b    d2,d3
  539.         beq.s    .redok
  540.         bge.s    .redup
  541.         subq.b    #1,d2
  542.         bra.s    .redok
  543. .redup:        addq.b    #1,d2
  544. .redok:        ror.w    #5,d2
  545.         move.w    d2,d4
  546. .blue:        move.w    d0,d2
  547.         and.w    #%0000000000011111,d2
  548.         move.w    d1,d3
  549.         and.w    #%0000000000011111,d3
  550.         tst.w    .var
  551.         beq.s    .blueok
  552.         cmp.b    d2,d3
  553.         beq.s    .blueok
  554.         bge.s    .blueup
  555.         subq.b    #1,d2
  556.         bra.s    .blueok
  557. .blueup:    addq.b    #1,d2
  558. .blueok:    or.w    d2,d4
  559. .green:        move.w    d0,d2
  560.         and.w    #%0000011111100000,d2
  561.         lsr.w    #5,d2
  562.         move.w    d1,d3
  563.         and.w    #%0000011111100000,d3
  564.         lsr.w    #5,d3
  565.         cmp.b    d2,d3
  566.         beq.s    .greenok
  567.         bge.s    .greenup
  568.         subq.b    #1,d2
  569.         bra.s    .greenok
  570. .greenup:    addq.b    #1,d2
  571. .greenok:    lsl.w    #5,d2
  572.         or.w    d2,d4
  573.         move.w    d4,(a2)
  574.         move.w    d4,2(a2)
  575.         not.w    .var
  576.         dbra    d7,.step
  577.         swap    d7
  578.         dbra    d7,.colour
  579.         rts
  580. .var:        ds.w    1
  581.  
  582.  
  583.  
  584. clear_screens:    move.l    scradr1,a0
  585.         move.l    scradr2,a1
  586.         move.l    scradr3,a2
  587.         move.w    #320*100*2/64-1,d7
  588. .loop:        rept    16
  589.         clr.l    (a0)+
  590.         clr.l    (a1)+
  591.         clr.l    (a2)+
  592.         endr
  593.         dbra    d7,.loop
  594.         rts
  595.  
  596.  
  597. switch_screens:    move.l    scradr3,d0
  598.         move.l    scradr2,scradr3
  599.         move.l    scradr1,scradr2
  600.         move.l    d0,scradr1
  601.         movea.l    scradr2,a0
  602.         jsr    set_scradr
  603.         rts
  604.  
  605.         section    data
  606.  
  607.         even
  608. startdata:
  609.  
  610.  
  611.  
  612. deepmul:    dc.w    basedeep
  613. mulsval:    dc.w    baseriple
  614.  
  615. sinus:        incbin    'sinus.dat
  616.         even
  617.  
  618. ringlist:    incbin    'circles4.dat'
  619.         even
  620.  
  621. spiral:        incbin    'sprial4.dat'
  622.         even
  623.  
  624. rawring:    incbin    'back.apx'
  625.         even
  626.  
  627. rawring2:    incbin    'back16b.apx'
  628.         even
  629.  
  630. rawlogo:    incbin    'logo.apx'  
  631.         even
  632.  
  633. rawtexture:    incbin    'texture.apx'
  634.         even
  635.  
  636. light:        incbin    'sun.dat'
  637.         even
  638.  
  639. rawpal:        incbin    'realpal.apx'
  640.         even
  641.  
  642. scradr1:    dc.l    scr1+256
  643. scradr2:    dc.l    scr2+256
  644. scradr3:    dc.l    scr3+256
  645.  
  646.  
  647.  
  648.         section    bss
  649.  
  650.         even
  651.  
  652. brightnessvol:    ds.l    1
  653. brightnessadd:    ds.l    1
  654. deepshift:    ds.w    1
  655. rippleadd:    ds.l    1
  656. texture_pos:    ds.l    1
  657. sin:        ds.l    1
  658. sinpos:        ds.l    1
  659. sinpos2:    ds.l    1
  660.  
  661. ringtexture:    ds.w    160*100
  662. ringtexture2:    ds.l    160*100
  663. texture:    ds.w    256*256*2
  664. logo:        ds.w    160*100
  665. palette:    ds.b    1024*256
  666. scr1:        ds.w    320*100+256
  667. scr2:        ds.w    320*100+256
  668. scr3:        ds.w    320*100+256
  669.  
  670.         end
  671.