home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / MAGGIE22.ARJ / magg22st.msa / GOODIES / ST_INTRO.ZIP / M21.ST / WASH2.S < prev   
Text File  |  1996-09-12  |  21KB  |  1,026 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.                         avena_5_9_96:
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20. ;---------------------------------------------------------------
  21. ;
  22. ; "Washing Machine" effect, 5th September 1996 onwards
  23. ;
  24. ; Effect very similar to the tunnel effect. Here we make the
  25. ;    effect out of several (concentric?) rings.
  26. ;
  27. ;---------------------------------------------------------------
  28. ;
  29. ;    initial coding ideas
  30. ;
  31. ;---------------------------------------------------------------
  32. ;
  33. ; Water-type effects can be easily be added by altering the ring
  34. ;    list! (Now done)
  35.  
  36. ; The effect routine will look like this:
  37. ;
  38.  
  39. ;    rept 4
  40. ;    add.w    (a0)+,a1    16    ;d0 mult of 4, relative!
  41. ;    move.w    (a0)+,d1    8    ;d1 mult of 2?
  42.  
  43. ; FOLLOWING LINE SCAN BE SELF-WRITTEN AS X(A1) TO REMOVE ABOVE
  44. ;   ADD.W STATEMENT FOR 68000
  45. ;    MOVE.L    X1(A1),A2
  46. ;    move.l    (a1),a2        12    ;ring list
  47. ; ALSO THIS LINE CAN BE SELF WRITTEN??
  48. ;    move.b    (a2,d1.w),d2    20    ....[or d3,d4,d5]
  49. ;    MOVE.W    X2(A2),D2
  50. ;                    ;Colour stored as mult of 2
  51. ;
  52. ;    move.l     d2,a3        4    ;c2p lookup on 256byte boundary
  53. ;    or.w    (a3),d6        12
  54. ;    endr
  55. ;    movep.w    d6,x(...)    24
  56. ;    movep.w    d6,160+x(...)    24
  57. ;
  58. ;                
  59. ;
  60. ; This routine is however horrendously slow on an ST...
  61. ;  ... approx 4.2 frames for 160x100
  62. ;  ....       2.6   "     "  100x100    similar to Platsch?
  63. ;
  64. ; Perhaps a 4 plane version would be a good idea too?
  65. ;
  66. ; Routine could well be improved by converting whole set of
  67. ;    lists 4 times rather than using a c2p lookup table?
  68. ;    This would involve huge amounts of memory though
  69. ;    and means you can't scroll patterns through the picture
  70. ;
  71. ; Further cunning optimisation:
  72. ;    Since the ring_number value in the table is rotationally
  73. ;    symmetrical, it needs only be fetched once. Also, the
  74. ;    ring_angle will automatically be (max_ring_angle/2)
  75. ;    greater at the opposite point...
  76. ;    Also note: this optimisation *will* also be possible
  77. ;    on the ST, as long as the self-writing routine is
  78. ;    amended to take this into account. It could well mean
  79. ;    1meg-only status, though
  80.  
  81. ; Storing 4 copies of the picture will again save processor time
  82.  
  83. ;    Another Cunning Trick: if max_ring_angle is exactly 256,
  84. ;      automatic looping could be done by placing each piece of ring data
  85. ;      on a 256-byte boundary... this doesn't help with self-written
  86. ;      routines though
  87. ;
  88. ;---------------------------------------------------------------
  89. ;
  90. ;    initial "design" ideas
  91. ;
  92. ;---------------------------------------------------------------
  93. ;    1. do a kind of bad tunnel effect with no distortion
  94. ;    2. do a platsch-effect on the bunny
  95. ;    3. do a face bender....
  96. ;    4. ....that dies out to show uncle sam
  97. ;    5. do ripples and bending on the bunny    
  98. ;    6. do several mad ripple+bends on patterns in different
  99. ;        colours. pulses to the music?
  100. ;
  101. ; for each effect we need:
  102. ;  - the graphics info (picture or pattern?)
  103. ;    LONG - gfx type (0 = picture, 1 = pattern)
  104. ;       LONG - pointer to gfx
  105. ;  - the bending data
  106. ;    LONG - multiply amount
  107. ;    LONG - swirl speed
  108. ;    LONG - swirl offset???
  109. ;  - the ripple data
  110. ;    LONG - multiply amount
  111. ;    LONG - speed through buffer (not offset - stored in circular buffer)
  112. ;    LONG - ripple speed
  113.     
  114.             section    text
  115.  
  116.  
  117.  
  118. max_ring_number        equ    60
  119. max_ring_angle        equ    256
  120. ; This means ring_buffer size of 60 * 256 * 2 bytes = 30 Kbytes
  121.  
  122. ring_dummy_value    equ    -1
  123.  
  124. wash_x            equ    100
  125. wash_y            equ    100
  126. overflow_size        equ    40
  127.  
  128. falcon            equ    1
  129.  
  130. standalone        equ    0        ;falcon debugging
  131. testing_falcon        equ    0
  132. testing_screen        equ    0
  133. testing_selfwrite    equ    1
  134.  
  135.         opt    p=68000
  136.  
  137.     ifeq standalone                ;called from INTRO.S
  138.  
  139. script_wash_start:
  140.         move.l    (a6)+,wash_gfx_type    ;gfx type
  141.         move.l    (a6)+,wash_gfx_pointer    ;
  142.         pea    (a6)
  143.  
  144.         clr.l    pattern_ring_offset
  145.         bsr    Init_Wash
  146.  
  147.         move.l    (a7)+,a6
  148.         rts
  149.  
  150.  
  151. script_wash_do:
  152.         move.l    (a6)+,wash_palette    ;colour data
  153.  
  154.         move.l    (a6)+,d0
  155.         move.w    d0,wash_sine_position
  156.  
  157.         move.l    (a6)+,wash_swirl_amount
  158.         move.l    (a6)+,wash_swirl_speed
  159.         move.l    (a6)+,wash_swirl_offset
  160.  
  161.         move.l    (a6)+,wash_ripple_amount ;
  162.         move.l    (a6)+,wash_ripple_speed  ;
  163.         move.l    (a6)+,wash_ripple_offset ;
  164.  
  165.         move.l    (a6)+,tunnel_music_end        ;
  166.  
  167.         pea    (a6)
  168.  
  169.         bsr    do_wash_script
  170.  
  171.         move.l    (a7)+,a6
  172.         rts
  173.  
  174.     else                    ;standalone version
  175.         clr.l    -(a7)
  176.         move.w    #$20,-(a7)
  177.         trap    #1
  178.         addq.l    #6,a7
  179.  
  180.         ifne testing_screen
  181.         move.l    $44e.w,old_44e
  182.  
  183.         move.l    #test+256,d0
  184.         sub.b    d0,d0
  185.         move.l    d0,logic
  186.     ifeq    falcon
  187.         add.l    #32000,d0
  188.     else
  189.         add.l    #320*100*2,d0
  190.     endc
  191.         move.l    d0,physic
  192.  
  193.         ifne testing_falcon
  194.         move.w    #$24,-(a7)        ;"true"colour
  195.         move.w    #3,-(a7)
  196.         else
  197.         move.w    #0,-(a7)        ;4 bitplane ST mode
  198.         endc
  199.         move.l    d0,-(a7)
  200.         move.l    d0,-(a7)
  201.         move.w    #5,-(a7)
  202.         trap    #14
  203.         ifne testing_falcon
  204.         lea.l    14(a7),a7
  205.         else
  206.         lea    12(a7),a7
  207.         endc
  208.  
  209.         ;moveq    #$0009,d0
  210.         ;movec    d0,cacr
  211.         ;moveq    #0,d0
  212.         ;movec    d0,caar
  213.  
  214.         ifne testing_falcon
  215.         ori.w    #1,$ffff82c2.w
  216.         endc
  217.         endc
  218.  
  219.         move.l    $70.w,-(a7)
  220.         move.l    #sod,$70.w
  221.  
  222.         movem.l    st_palette,d0-d7
  223.         movem.l    d0-d7,$ffff8240.w
  224.         
  225.         ifne testing_screen
  226.         bsr    Init_Wash
  227. wait:
  228.         bsr    Do_Wash
  229.         bsr    screen_swap
  230.         cmp.b    #$39,$fffffc02.w
  231.         bne    wait
  232.  
  233.         move.l    (a7)+,$70.w
  234.  
  235.         move.w    #2,-(a7)
  236.         move.l    old_44e,-(a7)
  237.         move.l    old_44e,-(a7)
  238.         move.w    #5,-(a7)
  239.         trap    #14
  240.         lea.l    12(a7),a7
  241.         illegal
  242.         endc
  243.  
  244. screen_swap:
  245.         move.l    logic,d0
  246.         move.l    physic,logic
  247.         move.l    d0,physic
  248.         lsr.w    #8,d0
  249.         move.l    d0,$ffff8200.w
  250.         rts
  251.     endc
  252.  
  253.  
  254. ;---------------------------------------------------------------
  255.     ifeq    standalone
  256.  
  257. do_wash_script:
  258.         bsr    clear_screens
  259.  
  260.         move.l    wash_palette,a0
  261.         moveq    #1,d0
  262.         bsr    install_fade
  263.         bsr    start_fade
  264.  
  265. .loop:
  266.         bsr    Do_Wash
  267.         bsr    swap_screens
  268.         move.l    music_timer,d0
  269.         cmp.l    tunnel_music_end,d0        ;find what's needed
  270.         blt.s    .loop                ;not there yet
  271.  
  272.         lea    black_palette,a0
  273.         moveq    #1,d0
  274.         bsr    install_fade
  275.         bsr    start_fade
  276. .loop2:
  277.         bsr    Do_Wash
  278.         bsr    swap_screens
  279.         tst.w    fade_done_flag
  280.         beq.s    .loop2
  281.  
  282.         rts
  283.     endc
  284.  
  285.  
  286. ;---------------------------------------------------------------
  287.         section    text
  288. ;---------------------------------------------------------------
  289. Init_Wash:
  290.     ifeq    standalone
  291.         bsr    convert_gfx
  292.     endc
  293.  
  294.         bsr    build_rings
  295.  
  296.         bsr    use_wash_table
  297.         bsr    init_ring_table_list
  298.  
  299.         bsr    create_c2p_table        ;not on Falcon version
  300.         rts
  301.  
  302.  
  303.  
  304.  
  305. ;---------------------------------------------------------------
  306.     ifeq standalone
  307. convert_gfx:
  308.         move.l    wash_gfx_pointer,a0
  309.         lea    160(a0),a1
  310.         lea    wash_gfx,a2
  311.         move.w    #wash_y-1,d0
  312. .loop1        move.w    #wash_x-1,d1
  313. .loop2:        move.b    (a0)+,d2
  314.         move.b    (a1)+,d3
  315.         move.b    d2,d4
  316.         and.w    #$f,d4
  317.         move.b    d2,d5
  318.         and.w    #$f,d5
  319.         add.w    d4,d5
  320.         lsr.b    #4,d2
  321.         lsr.b    #4,d3
  322.         and.w    #$f,d2
  323.         and.w    #$f,d3
  324.         add.w    d2,d5
  325.         add.w    d3,d5
  326.         asr.w    #2,d5
  327.         move.b    d5,(a2)+
  328.         dbf    d1,.loop2
  329.  
  330.         lea    320-(wash_x)(a0),a0
  331.         lea    320-(wash_x)(a1),a1
  332.         dbf    d0,.loop1
  333.         rts
  334.     endc
  335.  
  336.  
  337. ;---------------------------------------------------------------
  338. ;    build_rings(void)
  339. ;
  340. ; First we build up several ring_tables of size (ring_length)
  341. ;    by analysing the picture and the ring shape - similar to
  342. ;    the tunnel table.
  343. ;
  344. ;---------------------------------------------------------------
  345. build_rings:
  346.         tst.l    wash_gfx_type
  347.         bne    build_pattern_rings
  348.  
  349. ; Initially we fill the ring_tables with a dummy value:
  350.         bsr    fill_buffer
  351.     
  352.  
  353. ; Finally each ring_table must be *doubled* to allow wrap-around
  354. ;   get each value of wash_table (ring number,angle) and insert
  355. ;   the pic data at ring_buffer[ring_number,ring_angle]:
  356.         bsr    insert_in_rings
  357.  
  358. ; Afterwards, any values of 'dummy' will be written over by the
  359. ;   last non-dummy value to be found. Loop round twice (forwards)
  360. ;   to be sure?
  361.  
  362. ; Finally each ring_buffer must be *doubled* to allow wrap-around
  363. ;   of rotation:
  364.         bsr    remove_dummies
  365.         rts
  366.  
  367.  
  368. fill_buffer:
  369.         lea    ring_buffer,a0
  370.         move.w    #(max_ring_number*max_ring_angle*2)-1,d0
  371. .filldummy:    move.b    #ring_dummy_value,(a0)+
  372.         dbf    d0,.filldummy
  373.         rts
  374.  
  375. insert_in_rings:
  376.         lea    wash_table,a0        ;source offsets
  377.         lea    wash_gfx,a2        ;source picture
  378.         lea    ring_buffer,a1        ;destination
  379.  
  380.         move.w    #(wash_x*wash_y)-1,d0
  381. .convert:    moveq    #0,d1
  382.         moveq    #0,d2
  383.         move.b    (a0)+,d1        ;ring_number 0-95
  384.         move.b    (a0)+,d2        ;ring_angle 0-255
  385.         mulu.w    #max_ring_angle*2,d1
  386.         add.l    d2,d1
  387.         move.b    (a2)+,d3
  388.     ifeq testing_falcon                ;ie. bitplane modes...
  389.         lsl.b    #2,d3
  390.     endc
  391.         move.b    d3,(a1,d1.l)
  392.         dbf    d0,.convert
  393.         rts
  394.  
  395. remove_dummies:
  396.         lea    ring_buffer,a0
  397.         move.w    #max_ring_number-1,d0
  398. .fill_1:
  399.         move.b    #-1,d2            ;set first data
  400.         move.l    a0,a1            ;save positions
  401.         move.w    #max_ring_angle-1,d1
  402.         bsr    fill_loop
  403.         move.l    a0,a1            ;save positions
  404.         move.w    #max_ring_angle-1,d1    ;do it again
  405.         bsr    fill_loop
  406. ; Now double the buffer:
  407.         bsr    double_loop
  408.         lea    max_ring_angle*2(a0),a0
  409.         dbf    d0,.fill_1
  410.         rts
  411.  
  412. fill_loop:
  413.         move.b    (a1)+,d3
  414.         cmp.b    #ring_dummy_value,d3
  415.         bne.s    .get_new            ;position filled?
  416.  
  417.         cmp.b    #-1,d2                ;none yet found?
  418.         beq.s    .ignore
  419.         move.b    d2,-1(a1)
  420. .ignore:    dbf    d1,fill_loop
  421.         rts
  422. .get_new:
  423.         move.b    d3,d2                ;data is new d2
  424.         dbf    d1,fill_loop
  425.         rts
  426.  
  427. double_loop:
  428.         lea    max_ring_angle(a0),a1
  429.         move.l    a0,a2
  430.         move.w    #max_ring_angle-1,d1
  431. .copy        move.b    (a2)+,(a1)+
  432.         dbf    d1,.copy
  433.         rts
  434.  
  435.  
  436. ;---------------------------------------------------------------
  437. build_pattern_rings:
  438.         clr.l    pattern_ring_offset
  439.  
  440.         moveq    #max_ring_number-1,d0
  441. .buildloop:
  442.         move.l    d0,-(a7)
  443.         bsr    build_pattern_ring
  444.         move.l    (a7)+,d0
  445.         dbf    d0,.buildloop
  446.         rts
  447.  
  448.  
  449.  
  450. build_pattern_ring:
  451.         bsr    update_pattern_offset
  452.  
  453.         move.l    pattern_ring_offset,d0
  454.         mulu.w    #max_ring_angle*2,d0
  455.         add.l    #ring_buffer,d0
  456.  
  457.         move.l    d0,a0
  458.         lea    max_ring_angle(a0),a1
  459.  
  460.         lea    wash_data_1,a2            ;gfx 1
  461.         lea    wash_data_1,a3            ;gfx 1
  462.         move.w    pattern_1_offset,d0
  463.         mulu.w    #256,d0
  464.         move.w    pattern_2_offset,d1
  465.         mulu.w    #256,d1
  466.         add.l    d0,a2
  467.         add.l    d1,a3
  468.  
  469.         move.l    #$3c3c3c3c,d1
  470.         rept    max_ring_angle/4        ;longs
  471.          move.l    (a2)+,d0
  472.          add.l    (a3)+,d0
  473.          lsr.l    d0
  474.          and.l    d1,d0         
  475.          move.l    d0,(a0)+
  476.          move.l    d0,(a1)+
  477.         endr
  478.  
  479.         move.l    pattern_ring_offset,d0
  480.         subq.l    #1,d0
  481.         bpl.s    .ok
  482.         add.l    #max_ring_number,d0
  483. .ok        move.l    d0,pattern_ring_offset
  484.  
  485.         rts
  486.  
  487. update_pattern_offset:
  488.         add.l    #$018000,pattern_1_offset
  489.         and.l    #$3fffff,pattern_1_offset
  490.         add.l    #-$02c000,pattern_2_offset
  491.         and.l    #$3fffff,pattern_2_offset
  492.         rts
  493.  
  494.  
  495.  
  496. ;---------------------------------------------------------------
  497. ;    use_wash_table
  498. ;
  499. ; converts from original format of 2 bytes to two words,
  500. ; - first word relative from last (initially rel from 0)
  501. ;       and a multiple of 4
  502. ; - second word multiple of 1 (pixels here stored as bytes!)
  503. ;
  504. ; - selftwriting version doesn't use relative values...
  505. ;
  506. ;---------------------------------------------------------------
  507. use_wash_table:
  508.  
  509.     ifeq    testing_selfwrite
  510. ; Relative version:
  511.         lea    wash_table,a0
  512.         lea    wash_table_2,a1
  513.         move.w    #(wash_x*wash_y)-1,d0
  514.         moveq    #0,d3            ;last ring_number*4
  515. .cw:
  516.         moveq    #0,d1
  517.         moveq    #0,d2
  518.         move.b    (a0)+,d1        ;ring_number
  519.         move.b    (a0)+,d2        ;ring_angle
  520.         asl.l    #2,d1
  521.         sub.l    d1,d3            ;last-new
  522.         neg.l    d3            ;new-last
  523.         move.w    d3,(a1)+        ;new ring_number_relative
  524.         move.w    d2,(a1)+        ;new ring_angle
  525.         move.l    d1,d3            ;new --> old
  526.  
  527.         dbf    d0,.cw
  528.  
  529.     else
  530. ; Self-writing version:
  531.         lea    wash_table,a0
  532.         lea    wash_instruction_buffer,a1
  533.         moveq    #0,d2            ;screen offset
  534.         move.w    #(wash_y)-1,d0        ;counter 1
  535. .sw_loop_1:
  536.         move.w    #(wash_x/8)-1,d1    ;ie 12 = 96 pixels
  537. .sw_loop_2:
  538.         bsr    makechunk
  539.         addq.w    #1,d2
  540.         bsr    makechunk
  541.         addq.w    #7,d2
  542.         dbf    d1,.sw_loop_2
  543.         bsr    makechunk        ;do last 4 pixels
  544.         add.w    #320-((wash_x/8)*8),d2
  545.         dbf    d0,.sw_loop_1
  546.  
  547.         move.w    #$4e75,(a1)+            ;'rts'
  548.         rts
  549.  
  550. makechunk:
  551.         lea    wash_loop_start,a2
  552.         move.l    a1,a3                ;save current dest
  553.         move.w    #(wash_loop_length)-1,d3
  554. .makecopy:    move.b    (a2)+,(a3)+
  555.         dbf    d3,.makecopy
  556.  
  557.         bsr    .get_wash_table_data
  558.         move.w    d3,wash_off1-wash_loop_start(a1)
  559.         move.w    d4,wash_off2-wash_loop_start(a1)
  560.         bsr    .get_wash_table_data
  561.         move.w    d3,wash_off3-wash_loop_start(a1)
  562.         move.w    d4,wash_off4-wash_loop_start(a1)
  563.         bsr    .get_wash_table_data
  564.         move.w    d3,wash_off5-wash_loop_start(a1)
  565.         move.w    d4,wash_off6-wash_loop_start(a1)
  566.         bsr    .get_wash_table_data
  567.         move.w    d3,wash_off7-wash_loop_start(a1)
  568.         move.w    d4,wash_off8-wash_loop_start(a1)
  569.         move.w    d2,wash_off9-wash_loop_start(a1)  ;screenoffset
  570.         lea    wash_loop_length(a1),a1
  571.         rts
  572.  
  573.  
  574. .get_wash_table_data:
  575.         moveq    #0,d3
  576.         moveq    #0,d4
  577.         move.b    (a0)+,d3        ;ring_number
  578.         move.b    (a0)+,d4        ;ring_angle
  579.         asl.w    #2,d3
  580.     endc
  581.         rts
  582.  
  583.  
  584. ;---------------------------------------------------------------
  585. create_c2p_table:
  586.         move.l    #c2p_buffer+256,d0
  587.         sub.b    d0,d0            ;256 byte boundary
  588.         move.l    d0,c2p_buffer_address
  589.  
  590. ; Now we need 4 sets of the same data, each shifted by 2 bits
  591.         move.l    d0,a0            ;a0 dest1
  592.         lea    256(a0),a1        ;a1 dest2
  593.         lea    256(a1),a2        ;a2 dest3
  594.         lea    256(a2),a3        ;a3 dest4
  595.         lea    c2p_colour_list,a4    ;a4 source
  596.         moveq    #16-1,d0
  597. .c2p_loop:
  598.         move.l    (a4)+,d1
  599.         and.l    #$c0c0c0c0,d1
  600.         move.l    d1,(a0)+
  601.         lsr.l    #2,d1
  602.         move.l    d1,(a1)+
  603.         lsr.l    #2,d1
  604.         move.l    d1,(a2)+
  605.         lsr.l    #2,d1
  606.         move.l    d1,(a3)+
  607.         dbf    d0,.c2p_loop
  608.         rts
  609.  
  610.  
  611. ;---------------------------------------------------------------
  612. init_ring_table_list:
  613.         lea    ring_table_list,a0
  614.         lea    ring_buffer,a1
  615.         move.w    #max_ring_number-1,d0
  616. .fill:        move.l    a1,(a0)+        ;save address
  617.         add.l    #max_ring_angle*2,a1
  618.         dbf    d0,.fill
  619.         rts
  620.  
  621.  
  622.  
  623. ;---------------------------------------------------------------
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645. ;---------------------------------------------------------------
  646. ;
  647. ;
  648.  
  649.  
  650.  
  651. Do_Wash:
  652.         bsr    update_table_list
  653.         bsr    show_wash
  654.         bsr    double_wash
  655.  
  656.         tst.l    wash_gfx_type
  657.         beq.s    .no_patt
  658.         bsr    build_pattern_ring
  659. .no_patt
  660.         rts
  661.  
  662.  
  663. update_table_list:
  664.         movem.w    wash_sine_position,d0/d1
  665.         add.l    wash_swirl_speed,d0
  666.         and.w    #(256*2)-2,d0
  667.         add.l    wash_ripple_speed,d1
  668.         and.w    #(256*2)-2,d1
  669.         movem.w    d0/d1,wash_sine_position
  670.  
  671.         lea    ring_buffer,a0
  672.         lea    ring_table_list,a1
  673.         lea    sine_table,a2
  674.         lea    ring_fix_list,a3
  675.  
  676.         moveq    #0,d4            ;ring number
  677.  
  678.         move.l    wash_swirl_amount,d5
  679.         move.l    wash_ripple_amount,d6
  680.         move.l    wash_swirl_offset,a4
  681.         move.l    wash_ripple_offset,a5
  682.  
  683.         move.w    #(max_ring_number)-1,d7
  684.  
  685. .update_loop:
  686.                         ;rotation
  687.         move.w    (a2,d0.w),d2        ;sine value
  688.         muls.w    d5,d2
  689.         swap    d2
  690.         and.w    #255,d2
  691.         ext.l    d2
  692.                         ;ripple effect
  693.         move.w    (a2,d1.w),d3        ;sine value
  694.         muls.w    d6,d3
  695.         swap    d3
  696.  
  697.         add.w    d4,d3
  698.         add.w    d3,d3
  699.         move.w    (a3,d3.w),d3        ;lookup in table 0 to (max-1)
  700.  
  701.         add.w    pattern_ring_offset+2,d3
  702.         cmp.w    #max_ring_number,d3
  703.         blt.s    .ok2
  704.         sub.w    #max_ring_number,d3
  705. .ok2:
  706.         muls.w    #max_ring_angle*2,d3
  707.         add.l    d3,d2
  708.         add.l    a0,d2
  709.  
  710.         move.l    d2,(a1)+
  711.  
  712.         addq.w    #1,d4            ;normal offset
  713.  
  714.         add.w    a4,d0
  715.         and.w    #(256*2)-2,d0
  716.         add.w    a5,d1
  717.         and.w    #(256*2)-2,d1
  718.         dbf    d7,.update_loop
  719.         rts
  720.  
  721. show_wash:
  722. ;---------------------------------------------------------------
  723.     ifne testing_falcon
  724.         move.l    logic,a3        ;screen address!
  725.         moveq    #0,d2
  726.         lea    wash_table_2,a0
  727.         lea    ring_table_list,a1
  728.         lea    testing_colour_table,a4
  729.  
  730.         move.w    #(wash_y)-1,d7
  731. .test_loop_1:
  732.         move.w    #(wash_x)-1,d6
  733. .test_loop_2:
  734.          add.w    (a0)+,a1    16    ;d0 mult of 4, relative!
  735.          move.w    (a0)+,d1    8    ;d1 mult of 2?
  736.          move.l    (a1),a2        12    ;ring list
  737.          move.b    (a2,d1.w),d2    20    ....[or d3,d4,d5]
  738.          move.l    (a4,d2.l*4),(a3)+
  739.         dbf    d6,.test_loop_2
  740.  
  741.         lea    (640-(wash_x*4))(a3),a3
  742.         dbf    d7,.test_loop_1
  743.         rts
  744.     else
  745.  
  746. ;---------------------------------------------------------------
  747. ; ST bitplane versions:
  748. ;    First the one using tables (a fair bit slower)
  749. ;
  750.        ifeq testing_selfwrite
  751.  
  752.         move.l    logic,a3        ;screen address!
  753.         moveq    #0,d2
  754.         lea    wash_table_2,a0
  755.         lea    ring_table_list,a1
  756.  
  757.         move.l    c2p_buffer_address,d2
  758.         move.l    d2,d3
  759.         add.l    #$100,d3
  760.         move.l    d3,d4
  761.         add.l    #$100,d4
  762.         move.l    d4,d5
  763.         add.l    #$100,d5
  764.  
  765.         move.w    #(wash_y)-1,d7
  766.  
  767. .test_loop_1:
  768. washchunk    macro
  769.          add.w    (a0)+,a1    16    ;d0 mult of 4, relative!
  770.          move.w    (a0)+,d1    8    ;d1 mult of 2?
  771.          move.l    (a1),a2        12    ;ring list
  772.          move.b    (a2,d1.w),d2    20    ....[or d3,d4,d5]
  773.          move.l    d2,a4
  774.          move.l    (a4),d0
  775.  
  776.          add.w    (a0)+,a1    16    ;d0 mult of 4, relative!
  777.          move.w    (a0)+,d1    8    ;d1 mult of 2?
  778.          move.l    (a1),a2        12    ;ring list
  779.          move.b    (a2,d1.w),d3    20    ....[or d3,d4,d5]
  780.          move.l    d3,a4
  781.          or.l    (a4),d0
  782.  
  783.          add.w    (a0)+,a1    16    ;d0 mult of 4, relative!
  784.          move.w    (a0)+,d1    8    ;d1 mult of 2?
  785.          move.l    (a1),a2        12    ;ring list
  786.          move.b    (a2,d1.w),d4    20    ....[or d3,d4,d5]
  787.          move.l    d4,a4
  788.          or.l    (a4),d0
  789.  
  790.          add.w    (a0)+,a1    16    ;d0 mult of 4, relative!
  791.          move.w    (a0)+,d1    8    ;d1 mult of 2?
  792.          move.l    (a1),a2        12    ;ring list
  793.          move.b    (a2,d1.w),d5    20    ....[or d3,d4,d5]
  794.          move.l    d5,a4
  795.          or.l    (a4),d0
  796.     endm
  797.  
  798. o        set    0
  799.         rept    wash_x/8
  800.         washchunk
  801.         movep.l    d0,o(a3)
  802.         washchunk
  803.         movep.l    d0,o+1(a3)
  804. o        set    o+8
  805.         endr
  806.  
  807.         washchunk        ; do the last 4 bits
  808.         movep.l    d0,o(a3)
  809.  
  810.         lea    320(a3),a3
  811.  
  812.         dbf    d7,.test_loop_1
  813.         rts
  814.         else
  815. ; Self-written version:
  816.         move.l    logic,a3        ;screen address!
  817.         lea    (160-12*8)/2(a3),a3
  818.         moveq    #0,d2
  819.         lea    ring_table_list,a1
  820.         move.l    c2p_buffer_address,d2
  821.         move.l    d2,d3
  822.         add.l    #$100,d3
  823.         move.l    d3,d4
  824.         add.l    #$100,d4
  825.         move.l    d4,d5
  826.         add.l    #$100,d5
  827.         jsr    wash_instruction_buffer
  828.         rts
  829.         endc
  830.     endc
  831.  
  832. ;---------------------------------------------------------------
  833.  
  834. double_wash:
  835.     ifeq testing_falcon
  836.         move.l    logic,a6        ;screen address!
  837.         lea    (160-12*8)/2(a6),a6
  838.         rept    wash_y
  839.         movem.l    (a6)+,d0-a5
  840.         movem.l    d0-a5,160-(14*4)(a6)
  841.         movem.l    (a6)+,d0-a3
  842.         movem.l    d0-a3,160-(12*4)(a6)
  843.         lea    320-4*(14+12)(a6),a6
  844.         endr
  845.     endc
  846.         rts
  847.  
  848. sod    rte
  849.  
  850.  
  851. ;----------------------------------------------------------------
  852. ;    Self-written routine template
  853. ;    7_9_96
  854. ;
  855.  
  856.     ifne    testing_selfwrite
  857. wash_loop_start:
  858.  
  859. wash_off1    = *+2
  860.          move.l    2(a1),a2    ;16
  861. wash_off2    = *+2
  862.          move.b    2(a2),d2    ;12
  863.          move.l    d2,a4        ;4
  864.          move.l    (a4),d0        ;8
  865. wash_off3    = *+2
  866.          move.l    2(a1),a2    ;16
  867. wash_off4    = *+2
  868.          move.b    2(a2),d3    ;12
  869.          move.l    d3,a4        ;4
  870.          or.l    (a4),d0        ;12
  871. wash_off5    = *+2
  872.          move.l    2(a1),a2    ;16
  873. wash_off6    = *+2
  874.          move.b    2(a2),d4    ;12
  875.          move.l    d4,a4        ;4
  876.          or.l    (a4),d0        ;12
  877. wash_off7    = *+2
  878.          move.l    2(a1),a2    ;16
  879. wash_off8    = *+2
  880.          move.b    2(a2),d5    ;12
  881.          move.l    d5,a4        ;4
  882.          or.l    (a4),d0        ;12
  883. wash_off9    = *+2
  884.          movep.l d0,2(a3)    ;24
  885. wash_loop_end:
  886.  
  887. wash_loop_length =    (wash_loop_end-wash_loop_start)
  888.     endc
  889.  
  890. ;----------------------------------------------------------------
  891.  
  892.  
  893. ;----------------------------------------------------------------
  894.             section    data
  895. ;----------------------------------------------------------------
  896.  
  897. ; ring number (byte), angle (byte)
  898. wash_table        incbin    D:\Source2\M21.St\Data\Wash.dat
  899.             even
  900.  
  901.         ifne standalone
  902. wash_gfx        incbin    D:\Source2\m21.st\Data\Wash.Gfx
  903.             even
  904.         endc
  905.  
  906.  
  907.         ifne standalone
  908. sine_table:        incbin    f:\data\smallsin.dat
  909.             even
  910.  
  911. st_palette:
  912.             dc.w    $000,$888
  913.             dc.w    $111,$999
  914.             dc.w    $222,$aaa
  915.             dc.w    $333,$bbb
  916.             dc.w    $444,$ccc
  917.             dc.w    $555,$ddd
  918.             dc.w    $666,$eee
  919.             dc.w    $777,$fff
  920.         endc
  921.  
  922.  
  923.         ifne testing_falcon
  924. testing_colour_table:
  925. o            set    0
  926.             rept    16
  927.              dc.w    o,o        ; testing colour table
  928. o             set    o+$841*2    ; (two word values)
  929.             endr
  930.         endc
  931.  
  932.  
  933.             dcb.w    overflow_size,0        ;underflow
  934. ring_fix_list:
  935. o            set    0
  936.             rept    max_ring_number-1
  937.              dc.w    o
  938. o             set    o+1        ;(max_ring_angle*2)
  939.             endr
  940.             dcb.w    overflow_size,o        ;overflow
  941.  
  942. wash_data_1        incbin    Data\Tun1.Dat
  943. wash_data_2        incbin    Data\Tun2.Dat
  944.             even
  945.  
  946. c2p_colour_list:
  947.             dc.l    $00000000
  948.             dc.l    $ff000000
  949.             dc.l    $00ff0000
  950.             dc.l    $ffff0000
  951.             dc.l    $0000ff00
  952.             dc.l    $ff00ff00
  953.             dc.l    $00ffff00
  954.             dc.l    $ffffff00
  955.             dc.l    $000000ff
  956.             dc.l    $ff0000ff
  957.             dc.l    $00ff00ff
  958.             dc.l    $ffff00ff
  959.             dc.l    $0000ffff
  960.             dc.l    $ff00ffff
  961.             dc.l    $00ffffff
  962.             dc.l    $ffffffff
  963. ;----------------------------------------------------------------
  964.             section    bss
  965. ;----------------------------------------------------------------
  966.         ifne standalone
  967. physic            ds.l    1
  968. logic            ds.l    1
  969.         endc
  970.  
  971. wash_gfx_type        ds.l    1            ;gfx type
  972. wash_gfx_pointer    ds.l    1            ;
  973. wash_palette        ds.l    1            ;
  974. wash_swirl_amount    ds.l    1            ;
  975. wash_swirl_speed    ds.l    1            ;
  976. wash_swirl_offset    ds.l    1            ;
  977. wash_ripple_amount    ds.l    1            ;
  978. wash_ripple_speed     ds.l    1            ;
  979. wash_ripple_offset    ds.l    1            ;
  980.  
  981. pattern_1_offset    ds.l    1
  982. pattern_2_offset    ds.l    1
  983. pattern_ring_offset    ds.l    1
  984.  
  985. c2p_buffer_address    ds.l    1
  986. wash_sine_position    ds.w    1
  987.             ds.w    1
  988.  
  989. old_44e            ds.l    1
  990.  
  991. ring_table_list        ds.l    max_ring_number
  992.  
  993. c2p_buffer        ds.b    256+(4*256)
  994.  
  995.     ifeq    testing_selfwrite
  996. wash_table_2
  997.         ds.w    wash_x*wash_y*2
  998.     endc
  999.  
  1000.  
  1001. ;ring_buffer        ds.b    max_ring_number*max_ring_angle*2
  1002.  
  1003. ; All these share the same bss space:
  1004.     ifne    testing_selfwrite
  1005.  
  1006. textbuffer1    equ    *
  1007. textbuffer2    equ    *+bufferheight*40*1
  1008. textbuffer3    equ    *+bufferheight*40*2
  1009. textbuffer4    equ    *+bufferheight*40*3
  1010.  
  1011. wash_instruction_buffer:
  1012. tunnel_instruction_buffer:
  1013.             ;ds.b    max_tunnel_chunk_width*max_tunnel_height*2*(tunnel_loop_size)+10
  1014.             ds.b    (wash_loop_length)*(wash_x/4)*(wash_y)
  1015.     endc
  1016.  
  1017.     ifne    testing_screen
  1018. test            ds.b    256+(320*200*2)
  1019.     endc
  1020.  
  1021.     ifeq standalone
  1022. wash_gfx        ds.b    100*100
  1023.             even
  1024.     endc
  1025.  
  1026.