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 / TUNNEL2.S < prev    next >
Text File  |  1996-09-12  |  7KB  |  339 lines

  1. ;
  2. ;
  3. ;
  4. ;    tunnel / c2p_converter notes
  5. ;
  6. ;    timings assume 2x2 conversions
  7. ;
  8. ;    based on 160x100 screen = 16000 pixels
  9. ;
  10. ;
  11. ;    version 1
  12. ;        move.l    x-$8000(a0),d0    ;16
  13. ;        or.l    x-$4000(a0),d0    ;20
  14. ;        or.l    x+$0000(a0),d0    ;20
  15. ;        or.l    x+$4000(a0),d0    ;20
  16. ;        or.l    x-$8000(a1),d0    ;16
  17. ;        or.l    x-$4000(a1),d0    ;20
  18. ;        or.l    x+00000(a1),d0    ;20
  19. ;        or.l    x+$4000(a1),d0    ;20
  20.  
  21. ;        move.l    d0,x(a4)    ;16
  22. ;        move.l    d0,x+160(a4)    ;16    total 60+48=208 for 8 pixels
  23. ;                        or 26*16000 cycles
  24.  
  25. ;    version 2
  26. ;        move.w    x-$4000(a0),d0    ;12
  27. ;        or.w    x-$2000(a0),d0    ;16
  28. ;        or.w    x+$0000(a0),d0    ;16
  29. ;        or.w    x+$2000(a0),d0    ;16
  30. ;        movep.w    d0,x(a1)    ;24
  31. ;        movep.w    d0,x+160(a1)    ;24    total 60+48=108 for 4 pixels
  32. ;                        or 27*16000 cycles
  33.  
  34. ; So version 1 is quicker, uses 2 more address registers though...
  35. ;                          ...and twice as much in the gfx buffers...
  36.  
  37. ;    How the textures are stored.
  38. ;    original texture is 32*32....
  39. ;
  40. ;    we make 4 copies of 64*64 (for movement)
  41. ;    size of each will be 64*64*2 bytes (each pixel data is a WORD)
  42. ;            (or 8K)
  43. ;    a0 - is non-shifted
  44. ;    a1 - same data, shifted by 2 to right
  45. ;    etc...
  46.  
  47. ;------------------------------------------------------
  48.  
  49. ;    Storage of original texture?
  50. ;
  51. ;
  52.  
  53.  
  54. ; Let's have a 320 x 160 tunnel.
  55.         section    text
  56.  
  57. max_tunnel_chunk_width    equ    20
  58. max_tunnel_height    equ    100        ;double lined!
  59.  
  60. tunnel_chunk_width    dc.w    20
  61. tunnel_height        dc.w    100        ;double lined!
  62.  
  63.  
  64. script_tunnel_start:
  65.         move.l    (a6)+,tunnel_music_end
  66.         movem.l    (a6)+,d0/d1
  67.         move.w    d0,tunnel_chunk_width
  68.         move.w    d1,tunnel_height
  69.         move.l    (a6)+,tunnel_map_offset
  70.         move.l    (a6)+,a0            ;which palette!
  71.         move.l    (a6)+,tunnel_gfx_pointer
  72.         pea    (a6)
  73.         moveq    #1,d0
  74.         bsr    install_fade
  75.  
  76.         bsr    clear_screens
  77.         bsr    tunnel_initialise
  78.         bsr    draw_tunnel
  79.         bsr    swap_screens
  80.         bsr    start_fade
  81. .loop:
  82.         bsr    tunnel_frame
  83.         move.l    music_timer,d0
  84.         cmp.l    tunnel_music_end,d0        ;find what's needed
  85.         blt.s    .loop                ;not there yet
  86.  
  87.         lea    black_palette,a0
  88.         moveq    #2,d0
  89.         bsr    install_fade
  90.         bsr    start_fade
  91. .loop2:    
  92.         clr.l    vbl_timer
  93.         bsr    tunnel_frame
  94.         tst.w    fade_done_flag
  95.         beq.s    .loop2
  96.         move.l    (a7)+,a6
  97.         rts
  98.  
  99. tunnel_frame:
  100.         bsr    draw_tunnel
  101.         bsr    wait_vbl_tunnel2
  102.         bsr    swap_screens
  103.         rts
  104.  
  105. wait_vbl_tunnel:
  106.         tst.l    vbl_timer
  107.         beq    wait_vbl_tunnel
  108.         rts
  109.  
  110. wait_vbl_tunnel2:
  111.         tst.l    vbl_timer
  112.         beq    wait_vbl_tunnel2    ;not quicker than 1 frame
  113.         rts
  114.  
  115. ;tunnel_draw:
  116. ;        bsr    tunnel_initialise
  117. ;
  118. ;        lea    tunnel_gfx_buffer+(2*64*64)*2,a0
  119. ;        move.l    $44e.w,a1
  120. ;        jsr    tunnel_instruction_buffer
  121. ;        illegal
  122. ;        rts
  123.  
  124.  
  125. draw_tunnel
  126.  
  127.         move.l    tunnel_offset,d0
  128.         add.l    #(64*2)*2,d0
  129.         and.l    #%0111110111110,d0
  130.         move.l    d0,tunnel_offset
  131.  
  132.         lea    tunnel_gfx_buffer+(2*64*64)*2,a0
  133.         add.l    d0,a0
  134.  
  135.         move.w    tunnel_sine,d1            ;add x-offset
  136.         add.w    #2,d1
  137.         and.w    #256*2-2,d1
  138.         move.w    d1,tunnel_sine
  139.  
  140.         lea    sine_table,a1            ;look up in table
  141.         move.w    (a1,d1.w),d1
  142.         mulu.w    #64*2,d1
  143.         swap    d1
  144.         add.w    #32,d1
  145.         and.w    #%11111,d1
  146.         add.w    d1,d1                ;2 bytes each
  147.         ext.l    d1
  148.         add.l    d1,a0
  149.  
  150.         move.l    logic,a1
  151.         ;lea    160*(200-160)/2(a1),a1
  152.         jsr    tunnel_instruction_buffer
  153.         rts
  154.  
  155.  
  156. tunnel_initialise:
  157.         bsr    tunnel_make_instructions
  158.         move.l    tunnel_gfx_pointer,a0
  159.         bsr    tunnel_make_gfx_buffers
  160.         rts
  161.  
  162. tunnel_make_instructions:
  163.         lea    tunnel_instruction_buffer,a0
  164.         lea    tunnel_offset_data,a1
  165.         add.l    tunnel_map_offset,a1
  166.  
  167.         moveq    #0,d7                ;x offset
  168.         move.w    tunnel_height,d0
  169.         subq.w    #1,d0
  170. .loop1:    
  171.         move.w    tunnel_chunk_width,d1
  172.         add.w    d1,d1
  173.         subq.w    #1,d1
  174.  
  175.         moveq    #1,d5                ;what to add to d7!
  176.  
  177. .loop2:        lea    tunnel_loop_start,a2
  178.         move.l    a0,a3                ;save position
  179.  
  180.         moveq    #(tunnel_loop_size)/2-1,d2
  181. .loop3:        move.w    (a2)+,(a0)+            ;Copy instructions
  182.         dbf    d2,.loop3            ; to buffer
  183.  
  184.         move.w    (a1)+,d2            ;fetch orig offset
  185.         sub.w    #64*64*4,d2
  186.         move.w    d2,tunnel_off3-tunnel_loop_start(a3)
  187.         move.w    (a1)+,d2            ;fetch orig offset
  188.         sub.w    #64*64*2,d2
  189.         move.w    d2,tunnel_off2-tunnel_loop_start(a3)
  190.         move.w    (a1)+,d2            ;fetch orig offset
  191.         ;add.w    #64*64*2,d2
  192.         move.w    d2,tunnel_off1-tunnel_loop_start(a3)
  193.         move.w    (a1)+,d2            ;fetch orig offset
  194.         add.w    #64*64*2,d2
  195.         move.w    d2,tunnel_off4-tunnel_loop_start(a3)
  196.                             ;screen offsets
  197.  
  198.         move.w    d7,tunnel_off5-tunnel_loop_start(a3)
  199.         move.w    d7,d6
  200.         add.w    #160,d6
  201.         move.w    d6,tunnel_off6-tunnel_loop_start(a3)
  202.  
  203.         add.w    d5,d7                ;next scrn chunk
  204.         eor.w    #%110,d5            ;1 or 7...
  205.         dbf    d1,.loop2
  206.  
  207.         move.w    tunnel_chunk_width,d1
  208.         asl.w    #3,d1                ;multiply by 8
  209.         neg.w    d1
  210.         move.w    d1,d2
  211.         add.w    #320,d1
  212.         ext.l    d1
  213.         add.l    d1,d7
  214.         add.w    #200,d2
  215.         add.w    d2,d2
  216.         add.w    d2,a1
  217.         ;add.l    #320-(8*tunnel_chunk_width),d7    ;next scan line
  218.         ;add.l    #2*(200-(8*tunnel_chunk_width)),a1
  219.         dbf    d0,.loop1
  220.         move.w    #$4e75,(a0)+            ;'rts'
  221.         rts
  222.  
  223.  
  224.  
  225. ;------------------------------------------------------
  226. tunnel_loop_start:
  227. tunnel_off1    = *+2
  228.         move.w    2(a0),d0    ;16
  229. tunnel_off2    = *+2
  230.         or.w    2(a0),d0    ;20
  231. tunnel_off3    = *+2
  232.         or.w    2(a0),d0    ;20
  233. tunnel_off4    = *+2
  234.         or.w    2(a0),d0    ;20
  235. tunnel_off5    = *+2
  236.         movep.w    d0,2(a1)    ;16
  237. tunnel_off6    = *+2
  238.         movep.w    d0,2+160(a1)    ;16    total 60+48=108 for 4 pixels
  239. tunnel_loop_end:
  240.  
  241. tunnel_loop_size =    tunnel_loop_end-tunnel_loop_start
  242.  
  243. ;------------------------------------------------------
  244. tunnel_make_gfx_buffers:
  245.         lea    tunnel_gfx_buffer,a1
  246.         lea    64*64*2(a1),a2
  247.         lea    64*64*2(a2),a3
  248.         lea    64*64*2(a3),a4
  249.         move.w    #32-1,d0
  250.         moveq    #0,d1
  251. .loop1:        moveq    #2-1,d2            ;chunks
  252. .loop2:        move.w    (a0)+,d3
  253.         move.w    (a0)+,d4
  254.         moveq    #16-1,d5        ;pixels to do
  255. .loop3:
  256.         moveq    #0,d6
  257.         moveq    #0,d7
  258.         add.w    d3,d3
  259.         scs    d6
  260.         add.w    d4,d4
  261.         scs    d7
  262.         and.b    #%11000000,d6
  263.         and.b    #%11000000,d7
  264.         move.b    d6,(a1)+
  265.         move.b    d7,(a1)+
  266.  
  267.         lsr.b    #2,d6
  268.         lsr.b    #2,d7
  269.         move.b    d6,(a2)+
  270.         move.b    d7,(a2)+
  271.  
  272.         lsr.b    #2,d6
  273.         lsr.b    #2,d7
  274.         move.b    d6,(a3)+
  275.         move.b    d7,(a3)+
  276.  
  277.         lsr.b    #2,d6
  278.         lsr.b    #2,d7
  279.         move.b    d6,(a4)+
  280.         move.b    d7,(a4)+
  281.         dbf    d5,.loop3
  282.  
  283.         moveq    #16-1,d5        ;copy 32 pixels
  284. .loop4:        move.l    -64(a1),(a1)+        ;  or 64 bytes..
  285.         move.l    -64(a2),(a2)+
  286.         move.l    -64(a3),(a3)+
  287.         move.l    -64(a4),(a4)+
  288.         dbf    d5,.loop4
  289.         dbf    d2,.loop2
  290.         dbf    d0,.loop1
  291.  
  292. ; Copy overspill:
  293.         lea    tunnel_gfx_buffer+32*64*2,a1
  294.         lea    64*64*2(a1),a2
  295.         lea    64*64*2(a2),a3
  296.         lea    64*64*2(a3),a4
  297.         move.w    #32*64-1,d0        
  298. .copy
  299.         move.w    -32*64*2(a1),(a1)+
  300.         move.w    -32*64*2(a2),(a2)+
  301.         move.w    -32*64*2(a3),(a3)+
  302.         move.w    -32*64*2(a4),(a4)+
  303.         dbf    d0,.copy
  304.         rts
  305.  
  306.  
  307.  
  308.  
  309. ;------------------------------------------------------
  310.             section    data
  311. ;------------------------------------------------------
  312. tunnel_offset_data:    incbin    data\tunnel.dat
  313.  
  314. tunnel_gfx_1:        incbin    data\tunnel.gfx
  315. tunnel_gfx_2:        incbin    data\tunnel2.gfx
  316. tunnel_gfx_3:        incbin    data\tunnel3.gfx
  317. tunnel_gfx_4:        incbin    data\tunnel4.gfx
  318.  
  319. ;------------------------------------------------------
  320.             section    bss
  321. ;------------------------------------------------------
  322. tunnel_offset:        ds.l    1
  323. tunnel_sine:        ds.w    1
  324. tunnel_music_end:    ds.l    1
  325. tunnel_map_offset:    ds.l    1
  326. tunnel_gfx_pointer:    ds.l    1
  327.  
  328.  
  329. ;tunnel_gfx_buffer:
  330. ;            ds.b    4*(64*64*2)        ; = 32768 bytes
  331.  
  332. ;tunnel_instruction_buffer:
  333. ;            ds.b    max_tunnel_chunk_width*max_tunnel_height*2*(tunnel_loop_size)+10
  334.  
  335.  
  336. ;------------------------------------------------------
  337.             section    text
  338. ;------------------------------------------------------
  339.