home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaMiscModsCD3.iso / _PROGRAMME / PLAYER / SINGLEFORMAT / ptplay.lha / ptplay.S < prev    next >
Encoding:
Text File  |  1980-12-28  |  87.5 KB  |  5,342 lines

  1. *********************
  2. * ptplay v 1.0 beta *
  3. *********************
  4. * by Otis/InfoCorner*
  5. *********************
  6.  
  7. ;<<<< Needs powerpacker.library >>>>
  8.     
  9.     incdir    df0:include/
  10.  
  11.     include    powerpacker_lib.i
  12.     include ppbase.i
  13.  
  14.     incdir    df0:
  15.  
  16. AddICRVector    =   -6
  17. RemICRVector    =  -12
  18. LVOOpenResource    = -498
  19. LVOOpenLibrary     = -552
  20. LVOCloseLibrary    = -414
  21. LVODelay    = -198
  22.  
  23. MEMF_CHIP = 1<<1
  24. MEMF_PUBLIC =1<<0
  25.  
  26. ciatalo = $400
  27. ciatahi = $500
  28. ciatblo = $600
  29. ciatbhi = $700
  30. ciacra  = $E00
  31. ciacrb  = $F00
  32.  
  33. ;********* Exec offsets ************
  34.  
  35. forbid    = -132
  36. permit    = -138
  37.  
  38. ;************ code ***************
  39.  
  40.     section    ptplay,CODE
  41.  
  42. start
  43.     movem.l    d0-d7/a0-a6,-(a7)
  44.     move.l    a0,argv
  45.     move.l    d0,argv_length
  46.  
  47.     lea    dos_name,a1
  48.     moveq    #0,d0
  49.     move.l    $4.w,a6
  50.     jsr    -552(a6)    ;open dos lib
  51.     tst.l    d0
  52.     bne.s    opened
  53.     bra.w    exit
  54.  
  55. opened
  56.     move.l    d0,dos_base
  57.  
  58.     move.l    d0,a6
  59.     jsr    -60(a6)        ;get cli stdout
  60.     move.l    d0,stdout
  61.     
  62.     move.l    argv,a0
  63.     move.b    (a0),d0
  64.     cmp.b    #"?",d0
  65.     beq.s    print_usage
  66.     move.l    argv_length,d0
  67.     cmp.b    #1,d0
  68.     bgt.s    args_passed
  69.  
  70.  
  71. print_usage
  72.     ;write: Usage: ptplay module[.pp] [text[.pp]]
  73.     move.l    #usage_text,d2
  74.     move.l    stdout,d1
  75.     move.l    #38,d3
  76.     move.l    dos_base,a6
  77.     jsr    -48(a6)
  78.     bra.w    exit
  79.  
  80.     
  81. args_passed    
  82.     bsr    get_arguments    ;first in filename1, second in filename2
  83.     ;write: PtPlay - protracker module player. (c)1993 Otis/InfoCorner
  84.     move.l    stdout,d1
  85.     move.l    dos_base,a6
  86.     move.l    #opening_text,d2
  87.     move.l    #59,d3
  88.     jsr    -48(a6)
  89.  
  90.     ;open powerpacker.library
  91.     lea    pp_name,a1
  92.     moveq    #0,d0
  93.     move.l    $4.w,a6
  94.     jsr    -552(a6)
  95.     tst.l    d0
  96.     bne.s    pp_opened
  97.  
  98.     ;write    Needs powerpacker.library!!!!!
  99.     move.l    #pp_needed,d2
  100.     move.l    stdout,d1
  101.     move.l    #31,d3
  102.     move.l    dos_base,a6
  103.     jsr    -48(a6)
  104.     bra     exit
  105.  
  106. pp_opened
  107.     move.l    d0,pp_base
  108.  
  109.     ;load module
  110.     lea    filename1,a0
  111.     moveq    #DECR_POINTER,d0
  112.     moveq    #MEMF_CHIP,d1
  113.     lea    mt_data,a1
  114.     lea    tune_length,a2
  115.     move.l    #0,a3
  116.     move.l    pp_base,a6
  117.     jsr    _LVOpploaddata(a6)
  118.  
  119.     tst.l    d0
  120.     beq.s    mod_load_succeeded
  121.  
  122.     move.l    pp_base,a6
  123.     jsr    _LVOpperrormessage(a6)
  124.  
  125.     bsr    dump_pp_error_message
  126.  
  127.     move.l    pp_base,a1
  128.     move.l    $4.w,a6
  129.     jsr    -414(a6)        ;close pp.library
  130.  
  131.     bra.w    exit
  132.  
  133. mod_load_succeeded        
  134.     bsr    kill_disk_motor
  135.  
  136.     lea    filename2,a0
  137.     move.b    (a0),d0
  138.     tst.b    d0
  139.     beq.s    no_mod_text_specified
  140.     
  141.     ;load text
  142.     moveq    #DECR_POINTER,d0
  143.     moveq    #MEMF_PUBLIC,d1
  144.     lea    mod_text,a1
  145.     lea    mod_text_length,a2
  146.     move.w    #0,a3
  147.     move.l    pp_base,a6
  148.     jsr    _LVOpploaddata(a6)
  149.  
  150.     tst.l    d0
  151.     beq.s    text_load_succeeded
  152.  
  153.     move.l    #0,mod_text_length
  154.  
  155.     move.l    pp_base,a6
  156.     jsr    _LVOpperrormessage(a6)
  157.  
  158.     bsr    dump_pp_error_message
  159.  
  160.     move.l    pp_base,a1
  161.     move.l    $4.w,a6
  162.     jsr    -414(a6)        ;close pp.library
  163.  
  164.     bsr    free_tune
  165.     bra.w    exit
  166.  
  167. no_mod_text_specified
  168.     lea    mod_text_struct,a0
  169.     move.l    #no_mod_text_text,(a0)
  170.     move.w    no_mod_text_text_length,10(a0)
  171.     bra.s    n_m_t_s_skip
  172.         
  173. text_load_succeeded
  174.     bsr    kill_disk_motor
  175.     lea    mod_text_struct,a0
  176.     move.l    mod_text,(a0)
  177.     move.l    mod_text_length,d0
  178.     move.w    d0,10(a0)        ;chop at 64K
  179.  
  180. n_m_t_s_skip
  181.     move.l    pp_base,a1
  182.     move.l    $4.w,a6
  183.     jsr    -414(a6)        ;close pp.library
  184.  
  185.     lea    about_text_struct,a0
  186.     bsr    get_number_of_lines
  187.     bsr    allocate_text_bitmap_space
  188.     tst.l    d0
  189.     bne.s    s_cont1
  190.     lea    about_text_struct,a0
  191.     bsr    insert_empty_space
  192.     bsr    get_number_of_lines
  193. s_cont1
  194.     bsr    clear_bitplane
  195.  
  196.     lea    mod_text_struct,a0
  197.     bsr    get_number_of_lines
  198.     bsr    allocate_text_bitmap_space
  199.     tst.l    d0
  200.     bne.s    s_cont2
  201.     lea    mod_text_struct,a0
  202.     bsr    insert_empty_space
  203.     bsr    get_number_of_lines
  204. s_cont2
  205.     bsr    clear_bitplane
  206.  
  207.     lea    uga_text_struct,a0
  208.     bsr    get_number_of_lines
  209.     bsr    allocate_text_bitmap_space
  210.     tst.l    d0
  211.     bne.s    s_verder1
  212.     lea    uga_text_struct,a0
  213.     bsr    insert_empty_space
  214.     bsr    get_number_of_lines
  215.  
  216. s_verder1
  217.     bsr    clear_bitplane
  218.  
  219.     ;fix AGA
  220.  
  221.     move.l    $4.w,a6
  222.     lea    graph_name,a1
  223.     moveq    #0,d0
  224.     jsr    -552(a6)    ;open gfx.lib
  225.     move.l    d0,gfx_base
  226.     beq.w    exit
  227.  
  228.     move.l    d0,a6
  229.     move.l    34(a6),old_view
  230.  
  231.     move.l    #0,a1
  232.     jsr    -222(a6)    ;loadview(0)
  233.  
  234.     move.l    gfx_base,a6
  235.     jsr    -270(a6)    ;waitTOF
  236.  
  237.     move.l    gfx_base,a6
  238.     jsr    -270(a6)    ;waitTOF
  239.  
  240.     move.l    gfx_base,a6
  241.     jsr    -456(a6)    ;get blitter
  242.  
  243.     move.l    gfx_base,a6
  244.     jsr    -228(a6)    ;wait for blitter
  245.  
  246.     move.l    $4.w,a6
  247.     move.l    gfx_base,a1
  248.     jsr    -414(a6)    ;close lib
  249.  
  250.     ;fix sprites if AGA
  251.     ;check if AGA
  252.     move.w    $dff07c,d0
  253.     cmp.b    #$f8,d0
  254.     bne.s    .not_AGA
  255.     move.w    #0,$dff1fc    
  256.  
  257. .not_AGA
  258.     lea    getvbr(pc),a5
  259.     jsr    -$1e(a6)    ; call function in supervisor mode
  260.  
  261.     move.l    $4.W,a6
  262.     jsr    forbid(a6)    ;no multitasking, coz no rastertime left....
  263.  
  264.     bsr.w    init_program    ;several tables setup, screen setup etc.
  265.     bsr.w    init_song
  266.  
  267.     bsr.w    main
  268.  
  269.     jsr    ResetCIAInt
  270.  
  271.     bsr    free_text_bitmaps
  272.     bsr    free_tune
  273.     bsr    free_mod_text
  274.  
  275.     lea    graph_name,a1
  276.     moveq    #0,d0
  277.  
  278.     move.l    $4.w,a6
  279.     jsr    -552(a6)
  280.     move.l    d0,gfx_base
  281.  
  282.     move.l    d0,a6
  283.     bsr.w    waittil00
  284.     move.l    38(a6),$dff080
  285.  
  286.     move.w    d0,$dff088
  287.  
  288.     move.l    old_view,a1
  289.     jsr    -222(a6)    ;loadview(old_view)
  290.  
  291.     move.l    gfx_base,a6
  292.     jsr    -462(a6)    ;bye blitter
  293.  
  294.     move.l    gfx_base,a1
  295.     move.l    $4.w,a6
  296.     jsr    -414(a6)    ;close lib
  297.  
  298. exit
  299.     move.l    dos_base,a1    ;close dosbase
  300.     move.l    $4.w,a6
  301.     jsr    -414(a6)
  302.  
  303.     move.l    $4.w,a6
  304.     jsr    permit(a6)
  305.  
  306.     movem.l    (a7)+,d0-d7/a0-a6
  307.     rts
  308.  
  309.  
  310. dump_pp_error_message
  311.     ;d0 is pointer to string...(0 terminated)
  312.     move.l    d0,d2
  313.     moveq    #0,d3
  314.     move.l    d0,a0
  315. .loop
  316.     move.b    (a0)+,d0
  317.     tst.b    d0
  318.     beq.s    .finished
  319.     addq    #1,d3
  320.     bra.s    .loop
  321. .finished
  322.     move.l    stdout,d1
  323.     move.l    dos_base,a6
  324.     jsr    -48(a6)
  325.     
  326.     move.l    #return,d2
  327.     moveq    #1,d3
  328.     move.l    stdout,d1
  329.     move.l    dos_base,a6
  330.     jsr    -48(a6)
  331.     rts    
  332.  
  333.  
  334. get_arguments
  335.     move.l    argv,a0
  336.     lea    filename1,a1
  337.     move.l    argv_length,d7
  338.     moveq    #1,d6
  339.     moveq    #0,d5            ;d5 =1 => quoted string d5=0 =>not
  340.  
  341.     move.b    (a0),d0
  342.     cmp.b    #34,d0
  343.     bne.s    g_a_loop1
  344.     moveq    #1,d5
  345.     addq    #1,d6
  346.     addq.l    #1,a0
  347. g_a_loop1
  348.     move.b    (a0)+,d0
  349.     tst.b    d5
  350.     beq.s    .no_quoted_string
  351.     cmp.b    #34,d0
  352.     bne.s    g_a_loop1_v
  353.     addq    #1,a0
  354.     addq    #1,d6
  355.     cmp.l    d7,d6
  356.     bge.s    g_a_finished1
  357.     bra.s    nextarg
  358. .no_quoted_string    
  359.     cmp.b    #" ",d0
  360.     beq.s    nextarg
  361. g_a_loop1_v
  362.     addq    #1,d6
  363.     cmp.l    d7,d6
  364.     bgt.s    g_a_finished1
  365.     move.b    d0,(a1)+
  366.     bra.s    g_a_loop1
  367. nextarg
  368.     moveq    #0,d5
  369.     move.b    #0,(a1)+
  370.     lea    filename2,a1
  371. .loop2
  372.     move.b    (a0)+,d0
  373.     cmp.b    #" ",d0
  374.     bne.s    .skip
  375.     addq    #1,d6
  376.     bra.s    .loop2
  377. .skip
  378.     cmp.b    #34,d0
  379.     bne.s    .not_quoted_string
  380.     moveq    #1,d5
  381.     addq    #1,d6
  382.     addq    #1,a0
  383.  
  384. .not_quoted_string
  385.     subq    #1,a0
  386. .loop3
  387.     move.b    (a0)+,d0
  388.     tst.b    d5
  389.     beq.s    .not_quoted
  390.     cmp.b    #34,d0
  391.     beq.s    g_a_finished2
  392. .not_quoted    
  393.     addq    #1,d6
  394.     cmp.l    d7,d6
  395.     bge.s    g_a_finished2
  396.     move.b    d0,(a1)+
  397.     bra.s    .loop3
  398.  
  399.  
  400. g_a_finished1
  401.     move.l    #0,filename2
  402.     bra.s    g_a_end
  403. g_a_finished2
  404.     move.b    #0,(a1)
  405. g_a_end
  406.     rts        
  407.             
  408.  
  409. ;This function gets the vbr so this thingy also works on a '030
  410. getvbr:    move.l    4.w,a6
  411.     btst    #1,$129(a6)
  412.     beq.s    .no68020
  413.     dc.l    $4e7a8801    ; movec    vbr,a0
  414.     move.l    a0,vbr
  415. .no68020
  416.     rte
  417.  
  418.  
  419. waittil00
  420.     lea    $dff000,a5
  421. wt00_l1
  422.     tst.b    5(a5)    
  423.     beq.s    wt00_l1
  424. wt00_l2
  425.     tst.b    5(a5)
  426.     bne.s    wt00_l2
  427.     rts    
  428.  
  429.  
  430. ;****************** initialisation *****************
  431.  
  432. init_song
  433.     jsr    SetCIAInt
  434.     jsr    mt_init
  435.     rts
  436.  
  437.  
  438. init_program
  439.     bsr.b    all_black    ;all colors black....
  440.     bsr.w    copy_scopes_bitplane_to_buffers
  441.  
  442.     bsr.w    fill_char_tab
  443.     bsr.w    fill_track_pos_tab
  444.     bsr.w    blit_slotnos
  445.  
  446.     bsr.w    blit_text_bitmaps
  447.  
  448.     move.l    mt_data,a0
  449.     lea    952(a0),a0
  450.     move.b    (a0),pattern_pointer
  451.  
  452.     bsr.w    init_copplist
  453.     bsr.w    blit_song_name
  454.     bsr.w    blit_song_length
  455.  
  456.     bsr.w    fill_sample_info_buffer
  457.     bsr.w    do_sample_up
  458.  
  459.     lea    about_text_struct,a0
  460.     bsr    show_text_in_window
  461.  
  462.     rts    
  463.  
  464.  
  465. all_black
  466.     moveq    #16-1,d7
  467.     lea    $dff180,a0
  468. a_b_l
  469.     clr.w    (a0)+
  470.     dbf    d7,a_b_l
  471.  
  472.     rts        
  473.  
  474.  
  475. put_colors
  476.     moveq    #16-1,d7
  477.     lea    colors,a0
  478.     lea    $dff180,a1
  479. p_c_l
  480.     move.w    (a0)+,(a1)+
  481.     dbf    d7,p_c_l
  482.  
  483.     ;colors vu meters
  484.  
  485.     lea    $dff180,a0
  486.     move.w    #$00f0,42(a0)
  487.     move.w    #$00c0,44(a0)
  488.     move.w    #$0090,46(a0)
  489.  
  490.     move.w    #$00f0,50(a0)
  491.     move.w    #$00c0,52(a0)
  492.     move.w    #$0090,54(a0)
  493.  
  494.     move.w    #$0d0f,58(a0)
  495.     move.w    #$0a0c,60(a0)
  496.     move.w    #$080a,62(a0)
  497.     
  498.     ;colors    mouse pointer
  499.  
  500.     move.w    #$0f00,34(a0)
  501.     move.w    #$0c00,36(a0)
  502.     move.w    #$0900,38(a0)
  503.  
  504.     rts    
  505.  
  506.  
  507. init_copplist
  508.     move.l    #screen_picture,d0
  509.     lea    scherm,a0
  510.     
  511.     swap    d0
  512.     move.w    d0,2(a0)
  513.     swap    d0
  514.     move.w    d0,6(a0)
  515.  
  516.     add.l    #[80*200],d0
  517.     add.l    #8,a0
  518.  
  519.     swap    d0
  520.     move.w    d0,2(a0)
  521.     swap    d0
  522.     move.w    d0,6(a0)
  523.  
  524.     add.l    #[80*200],d0
  525.     add.l    #8,a0
  526.  
  527.     swap    d0
  528.     move.w    d0,2(a0)
  529.     swap    d0
  530.     move.w    d0,6(a0)
  531.  
  532.     ;insert sprites
  533.  
  534.     lea    c_pointer,a0
  535.     move.l    #mouse_pointer,d0
  536.  
  537.     move.w    d0,6(a0)
  538.     swap    d0
  539.     move.w    d0,2(a0)
  540.  
  541.     lea    8(a0),a0
  542.     move.l    #dummy_sprite,d0
  543.  
  544.     move.w    d0,6(a0)
  545.     swap    d0
  546.     move.w    d0,2(a0)
  547.  
  548.     lea    c_vu_meters,a0
  549.     move.l    #vu_meter_1,d0
  550.  
  551.     move.w    d0,6(a0)
  552.     swap    d0
  553.     move.w    d0,2(a0)
  554.         
  555.     lea    8(a0),a0
  556.     move.l    #vu_meter_2,d0
  557.  
  558.     move.w    d0,6(a0)
  559.     swap    d0
  560.     move.w    d0,2(a0)
  561.         
  562.     lea    8(a0),a0
  563.     move.l    #vu_meter_3,d0
  564.  
  565.     move.w    d0,6(a0)
  566.     swap    d0
  567.     move.w    d0,2(a0)
  568.         
  569.     lea    8(a0),a0
  570.     move.l    #vu_meter_4,d0
  571.  
  572.     move.w    d0,6(a0)
  573.     swap    d0
  574.     move.w    d0,2(a0)
  575.         
  576.     lea    8(a0),a0
  577.     move.l    #dummy_sprite,d0
  578.  
  579.     move.w    d0,6(a0)
  580.     swap    d0
  581.     move.w    d0,2(a0)
  582.         
  583.     lea    8(a0),a0
  584.     move.l    #dummy_sprite,d0
  585.  
  586.     move.w    d0,6(a0)
  587.     swap    d0
  588.     move.w    d0,2(a0)
  589.         
  590.     move.l    #tracks_bitplane,d0
  591.     lea    track_wait,a0
  592.  
  593.     move.w    #[$2909+$1800],(a0)+
  594.     move.w    #$fffe,(a0)+
  595.  
  596.     move.w    #$00e0,(a0)+
  597.     swap    d0
  598.     move.w    d0,(a0)+
  599.     move.w    #$00e2,(a0)+
  600.     swap    d0
  601.     move.w    d0,(a0)+
  602.  
  603.     move.w    #[$2909+$6800],(a0)+
  604.     move.w    #$fffe,(a0)+
  605.  
  606.     move.l    #screen_picture+3*80*200+104*80,d0
  607.     move.w    #$00ec,(a0)+
  608.     swap    d0
  609.     move.w    d0,(a0)+
  610.     swap    d0
  611.     move.w    #$00ee,(a0)+
  612.     move.w    d0,(a0)+
  613.         
  614.     move.l    #$b909fffe,(a0)+
  615.     move.l    #$0100b200,(a0)+
  616.  
  617.     move.l    #screen_picture+[[24+120]*80],d0
  618.  
  619.     move.l    a0,scope_screen
  620.  
  621.     move.w    #$00e0,(a0)+
  622.     swap    d0
  623.     move.w    d0,(a0)+
  624.     move.w    #$00e2,(a0)+
  625.     swap    d0
  626.     move.w    d0,(a0)+
  627.  
  628.     add.l    #[80*200],d0
  629.  
  630.     move.w    #$00e4,(a0)+
  631.     swap    d0
  632.     move.w    d0,(a0)+
  633.     move.w    #$00e6,(a0)+
  634.     swap    d0
  635.     move.w    d0,(a0)+
  636.  
  637.     add.l    #[80*200],d0
  638.  
  639.     move.w    #$00e8,(a0)+
  640.     swap    d0
  641.     move.w    d0,(a0)+
  642.     move.w    #$00ea,(a0)+
  643.     swap    d0
  644.     move.w    d0,(a0)+
  645.     
  646.     ;chop sprites... (insert dummies in the vu meter pointers)
  647.  
  648.     move.l    #dummy_sprite,d0
  649.  
  650.     move.w    #$0128,(a0)+
  651.     swap    d0
  652.     move.w    d0,(a0)+
  653.     move.w    #$012a,(a0)+
  654.     swap    d0
  655.     move.w    d0,(a0)+        
  656.  
  657.     move.w    #$012c,(a0)+
  658.     swap    d0
  659.     move.w    d0,(a0)+
  660.     move.w    #$012e,(a0)+
  661.     swap    d0
  662.     move.w    d0,(a0)+        
  663.  
  664.     move.w    #$0130,(a0)+
  665.     swap    d0
  666.     move.w    d0,(a0)+
  667.     move.w    #$0132,(a0)+
  668.     swap    d0
  669.     move.w    d0,(a0)+        
  670.  
  671.     move.w    #$0134,(a0)+
  672.     swap    d0
  673.     move.w    d0,(a0)+
  674.     move.w    #$0136,(a0)+
  675.     swap    d0
  676.     move.w    d0,(a0)+        
  677.  
  678.     move.l    #$f109fffe,(a0)+
  679.     move.l    #$01000000,(a0)+
  680.     move.l    #$fffffffe,(a0)+
  681.     rts    
  682.     
  683.  
  684. init_about_text_stuff
  685.     lea    about_text_struct,a0
  686.     bsr    blit_text
  687.     bsr    calc_scrollbar_info
  688.     bsr    generate_scrollbar_sprite
  689.     move.w    #24,scrollbar+6
  690.     lea    about_text_struct,a0
  691.     move.l    12(a0),a1
  692.     move.w    4(a1),d0
  693.     add.w    #24,d0
  694.     move.w    d0,scrollbar+8
  695.     bsr    show_text_in_window
  696.     rts
  697.  
  698.  
  699. init_mod_text_stuff
  700.     lea    mod_text_struct,a0
  701.     bsr    blit_text
  702.     bsr    calc_scrollbar_info
  703.     bsr    generate_scrollbar_sprite
  704.     rts
  705.  
  706.  
  707. init_uga_text_stuff
  708.     lea    uga_text_struct,a0
  709.     bsr    blit_text
  710.     bsr    calc_scrollbar_info
  711.     bsr    generate_scrollbar_sprite
  712.     rts
  713.  
  714.  
  715. blit_text_bitmaps
  716.     bsr    init_about_text_stuff
  717.     bsr    init_mod_text_stuff
  718.     bsr    init_uga_text_stuff
  719.     rts
  720.  
  721.  
  722. free_text_bitmaps
  723.     lea    about_text_struct,a0
  724.     bsr    free_memory
  725.  
  726.     lea    mod_text_struct,a0
  727.     bsr    free_memory
  728.  
  729.     lea    uga_text_struct,a0
  730.     bsr    free_memory
  731.     rts
  732.  
  733.  
  734. free_tune
  735.     move.l    mt_data,a1
  736.     move.l    tune_length,d0
  737.     move.l    $4.w,a6
  738.     jsr    -210(a6)
  739.     rts
  740.  
  741.  
  742. free_mod_text
  743.     move.l    mod_text_length,d0
  744.     tst.l    d0
  745.     beq.s    .end            ;no mod text specified
  746.     move.l    mod_text,a1
  747.     move.l    $4.w,a6
  748.     jsr    -210(a6)
  749. .end    
  750.     rts
  751.  
  752.  
  753. main
  754.     bsr.w    waittil00
  755.     lea    $dff000,a6
  756.     move.l    #copper_list,$80(a6)
  757.     move    d0,$88(a6)        ; write dummy value
  758.  
  759.     bsr.w    put_colors
  760.  
  761.     move.w    #$b200,$100(a6)
  762.  
  763.     move.w    $1c(a6),intena_save
  764.     move.w    $02(a6),dmacon_save
  765.  
  766.     move.w    #$7fff,$9a(a6)
  767.     move.w    #$7fff,$9c(a6)
  768.  
  769.     move.l    vbr,a0
  770.     move.l    $6c(a0),vbl_save
  771.     move.l    #wait_vbl,$6c(a0)    ;st vbl.
  772.  
  773.     move.w    #$8060,$96(a6)    
  774.     move.w    #$e020,$9a(a6)
  775.  
  776.     move.w    #0,$36(a6)
  777.  
  778.     jsr    main_control    ;go to the main loop
  779.  
  780.     ;end of proggy, restore everything...
  781.  
  782.     clr.b    mt_enable
  783.  
  784.     lea    $dff000,a6
  785.     move.w    #$7fff,$9a(a6)
  786.     move.w    #$7fff,$9c(a6)
  787.  
  788.     move.l    vbr,a0
  789.     move.l    vbl_save,$6c(a0)
  790.     move.w    intena_save,d0
  791.     or.w    #$8000,d0
  792.     move.w    d0,$9a(a6)
  793.  
  794.     move.w    dmacon_save,d0
  795.     or.w    #$8000,d0
  796.     move.w    d0,$96(a6)
  797.  
  798.     jsr    mt_end
  799.     
  800.     rts
  801.  
  802.  
  803. wait_vbl
  804.      movem.l    d0-d7/a0-a6,-(a7)
  805.     ST    mt_enable
  806.     bsr.w    swap_scopes_screen
  807.     bsr.w    clear_scope_area
  808.     bsr.w    plot_scopes
  809.     bsr.w    update_playing_time
  810.     bsr.w    move_vu_meters
  811.     bsr.w    move_pointer
  812.     tst.b    scrollbar_moved
  813.     beq.s    end_vbl
  814.     move.b    #0,scrollbar_moved
  815.     bsr    move_scrollbar
  816.  
  817. end_vbl
  818.     move.w    #$0070,$dff09c
  819.     movem.l (a7)+,d0-d7/a0-a6
  820.  
  821. .end    rte
  822.  
  823.  
  824. main_control
  825.     tst.b    quit_program
  826.     bne.w    quit_main_control
  827.  
  828.     tst.b    new_pattern
  829.     beq.s    m_c_v1
  830.     
  831.     move.b    #0,new_pattern
  832.     bsr.w    blit_pattern_no
  833.     bsr.w    blit_song_pos
  834. m_c_v1
  835.     tst.b    new_bpm
  836.     beq.s    m_c_v2
  837.  
  838.     move.b    #0,new_bpm
  839.     bsr.w    blit_bpm
  840. m_c_v2
  841.     tst.b    new_vbl_tempo
  842.     beq.s    m_c_v3
  843.  
  844.     move.b    #0,new_vbl_tempo
  845.     bsr.w    blit_vbl_tempo
  846. m_c_v3
  847.     tst.b    new_time
  848.     beq.s    m_c_v4
  849.  
  850.     bsr.w    blit_play_time
  851. m_c_v4        
  852.     bsr.w    blit_pattern
  853.  
  854.     moveq    #0,d1
  855.     
  856.     btst    #6,$bfe001
  857.     bne.w    no_left_button
  858.  
  859.     move.b    #0,mouse_button_status
  860.  
  861.     tst.b    mouse_button_status
  862.     bne.s    no_button_last_time
  863.  
  864.     ;button was pressed last time.
  865.  
  866.     cmp.w    #10,button_id
  867.     bne.s    .no_scrollbar1
  868.     move.b    #1,scrollbar_moved
  869.     bra.w    main_control    
  870.  
  871. .no_scrollbar1
  872.     bsr.w    check_which_button    ;d0 is button id, a0 is pointr to strct
  873.     move.w    button_id,d1
  874.     move.l    button_struct_address,a1
  875.     
  876.     move.w    d0,button_id
  877.     move.l    a0,button_struct_address
  878.  
  879.     cmp.w    #10,d0
  880.     bne.s    .no_scrollbar2
  881.     move.b    #1,scrollbar_moved
  882.     bra.w    main_control    
  883.  
  884. .no_scrollbar2
  885.     cmp.w    d1,d0
  886.     beq.w    main_control
  887.  
  888.     tst.w    d1
  889.     beq.s    .nothing_to_restore
  890.  
  891.     ;new futton pressed so restore old.
  892.     bsr.w    restore_button        ;button that has to be restored
  893.                     ;is in d1, address of structure in
  894.                     ;a1
  895. .nothing_to_restore
  896.     move.l    button_struct_address,a0
  897.     move.w    button_id,d0
  898.     tst.w    d0
  899.     beq.w    main_control    ;no button pressed anymore
  900.  
  901.     ;new button pressed
  902.  
  903.     bsr.w    blit_new_button
  904.     bra.w    main_control
  905.  
  906. no_button_last_time
  907.     bsr.w    check_which_button
  908.     move.w    d0,button_id
  909.     move.l    a0,button_struct_address
  910.  
  911.     tst.w    d0
  912.     beq.w    main_control
  913.  
  914.     cmp.w    #10,d0
  915.     bne.s    .no_scrollbar
  916.     move.b    #1,scrollbar_moved
  917.     bra.w    main_control
  918.  
  919. .no_scrollbar
  920.     bsr.b    blit_new_button
  921.     bra.w    main_control
  922.  
  923. no_left_button
  924.     move.b    #1,mouse_button_status
  925.     bsr.w    check_which_button
  926.     move.w    button_id,d1
  927.     move.l    button_struct_address,a1
  928.     tst.w    d1
  929.     beq.w    main_control
  930.  
  931.     cmp.w    #10,d1
  932.     beq.s    .not_the_same
  933.  
  934.     cmp.w    d0,d1
  935.  
  936.     bne.s    .not_the_same
  937.     ;do action
  938.     bsr.b    restore_button
  939.     bsr.b    do_action
  940. .not_the_same
  941.     move.w    #0,button_id    
  942.     bra.w    main_control
  943.  
  944. quit_main_control    
  945.     rts
  946.  
  947.  
  948. restore_button
  949.     ;d1=button_id, a1 is pointer to button_structure....
  950.     lea    button_blit_jump_table,a6
  951.  
  952.     and.w    #$00ff,d1    ;not more than 256 buttons :-)
  953.  
  954.     add.w     d1,d1
  955.     add.w    d1,d1        ;d1 * 4
  956.  
  957.     move.l    (a6,d1.w),a5    ;get address of routine....
  958.     move.l    10(a1),a4    ;get address of unselected image to render.
  959.  
  960. .end_of_routine
  961.     jmp    (a5)        ;jsr + rts to restore routine...
  962.  
  963.  
  964. blit_new_button
  965.     ;d0=button_id, a0 is pointer to button_structure....
  966.     lea    button_blit_jump_table,a6
  967.  
  968.     and.w    #$00ff,d0
  969.  
  970.     add.w    d0,d0
  971.     add.w    d0,d0        ;d0 * 4    
  972.  
  973.     move.l    (a6,d0.w),a5    ;get address of blit_routine
  974.     move.l    14(a0),a4    ;get address of selected image to render.
  975.  
  976. .end_of_routine
  977.     jmp    (a5)        ;jsr + rts to blit routine...
  978.  
  979.  
  980. do_action
  981.     lea    button_action_jump_table,a6
  982.  
  983.     add.w    d0,d0
  984.     add.w    d0,d0
  985.  
  986.     move.l    (a6,d0.w),a5
  987.     jmp    (a5)        ;jsr + rts to action routine..
  988.  
  989. show_about
  990.     lea    about_text_struct,a0
  991.     bsr    show_text_in_window
  992.     rts
  993.     
  994. show_mod_text
  995.     lea    mod_text_struct,a0
  996.     bsr    show_text_in_window
  997.     rts
  998.     
  999. do_restart
  1000.     move.w    #$0020,$dff09a
  1001.  
  1002.     jsr    ResetCIAInt
  1003.     jsr    mt_end
  1004.  
  1005.     bsr    clear_sample_structs
  1006.  
  1007.     move.b    #0,hours
  1008.     move.b    #0,minutes
  1009.     move.b    #0,seconds
  1010.     move.w    #0,pattern_slot_teller
  1011.     move.w    #0,blit_note_slot_teller
  1012.     move.b    #1,new_time
  1013.     move.b    #1,new_pattern    
  1014.     move.l    mt_data,a0
  1015.     lea    952(a0),a0
  1016.     move.b    (a0),pattern_pointer
  1017.  
  1018.     jsr    init_song
  1019.  
  1020.     move.w    #$8020,$dff09a
  1021.     rts
  1022.  
  1023.  
  1024. do_quit
  1025.     move.b    #1,quit_program
  1026.     rts
  1027.  
  1028.  
  1029. show_uga
  1030.     lea    uga_text_struct,a0
  1031.     bsr    show_text_in_window
  1032.     rts
  1033.  
  1034.  
  1035. do_sample_up
  1036.     moveq    #0,d0
  1037.     move.b    sample_info_shown,d0
  1038.     cmp.b    #31,d0
  1039.     beq.s    end_do_sample_up
  1040.     addq.b    #1,d0
  1041.     move.b    d0,sample_info_shown
  1042.     bsr.w    blit_sample_info
  1043. end_do_sample_up    
  1044.     rts
  1045.  
  1046.     
  1047. do_sample_down
  1048.     moveq    #0,d0
  1049.     move.b    sample_info_shown,d0
  1050.     cmp.b    #1,d0
  1051.     beq.s    end_do_sample_down
  1052.     subq.b    #1,d0
  1053.     move.b    d0,sample_info_shown
  1054.     bsr.w    blit_sample_info
  1055. end_do_sample_down
  1056.     rts
  1057.  
  1058.  
  1059. do_textwindow_up
  1060.     bsr    move_text_up
  1061.     rts
  1062.  
  1063.  
  1064. do_textwindow_down
  1065.     bsr    move_text_down
  1066.     rts
  1067.  
  1068.  
  1069. blit_about_button
  1070.     lea    screen_picture+188*80+40+200*80,a3
  1071.     bsr.b    blit_major_buttons
  1072.     rts
  1073.  
  1074.     
  1075. blit_mod_text_button
  1076.     lea    screen_picture+188*80+48+200*80,a3
  1077.     bsr.b    blit_major_buttons
  1078.     rts
  1079.  
  1080.  
  1081. blit_restart_button
  1082.     lea    screen_picture+188*80+56+200*80,a3
  1083.     bsr.b    blit_major_buttons
  1084.     rts
  1085.  
  1086.  
  1087. blit_quit_button
  1088.     lea    screen_picture+188*80+64+200*80,a3
  1089.     bsr.b    blit_major_buttons
  1090.     rts
  1091.  
  1092.  
  1093. blit_uga_button
  1094.     lea    screen_picture+188*80+72+200*80,a3
  1095.     bsr.b    blit_major_buttons
  1096.     rts
  1097.  
  1098.  
  1099. blit_sample_arrow_up
  1100.     lea    screen_picture+162*80+74+200*80,a3
  1101.     bsr.w    blit_arrow
  1102.     rts
  1103.  
  1104.  
  1105. blit_sample_arrow_down
  1106.     lea    screen_picture+172*80+74+200*80,a3
  1107.     bsr.w    blit_arrow
  1108.     rts
  1109.  
  1110.  
  1111. blit_scrollbar_arrow_up
  1112.     lea    screen_picture+85*80+78+200*80,a3
  1113.     bsr.w    blit_arrow
  1114.     rts
  1115.  
  1116.  
  1117. blit_scrollbar_arrow_down
  1118.     lea    screen_picture+95*80+78+200*80,a3
  1119.     bsr.w    blit_arrow
  1120.     rts
  1121.  
  1122.  
  1123. blit_close_button
  1124.     lea    screen_picture+200*80,a3
  1125.     bsr.w    blit_cl_button
  1126.     rts
  1127.  
  1128.  
  1129. blit_major_buttons    ;about ... UGA button...
  1130. ;destination in a3, source in a4...
  1131.     lea    $dff000,a6
  1132.  
  1133.     ;bitplane 1
  1134. .wait_blitter1
  1135.     btst    #14,$2(a6)
  1136.     btst    #14,$2(a6)
  1137.     bne.s    .wait_blitter1
  1138.  
  1139.     move.w    #$0070,$9a(a6)        ;no vbl interrupt...
  1140.  
  1141.     move.l    a4,$50(a6)
  1142.     move.l    a3,$54(a6)
  1143.     move.l    #-1,$44(a6)
  1144.     move.l    #$09f00000,$40(a6)
  1145.     move.l    #$00200048,$64(a6)
  1146.     move.w    #$0304,$58(a6)
  1147.  
  1148.     move.w    #$8020,$9a(A6)
  1149.  
  1150.     add.l    #40*12,a4
  1151.     add.l    #200*80,a3
  1152.  
  1153.     ;bitplane 2
  1154. .wait_blitter2
  1155.     btst    #14,$2(a6)
  1156.     btst    #14,$2(a6)
  1157.     bne.s    .wait_blitter2
  1158.  
  1159.     move.w    #$0070,$9a(a6)        ;no vbl interrupt...
  1160.  
  1161.     move.l    a4,$50(a6)
  1162.     move.l    a3,$54(a6)
  1163.     move.l    #-1,$44(a6)
  1164.     move.l    #$09f00000,$40(a6)
  1165.     move.l    #$00200048,$64(a6)
  1166.     move.w    #$0304,$58(a6)
  1167.  
  1168.     move.w    #$8020,$9a(A6)
  1169.  
  1170.     rts
  1171.  
  1172.  
  1173. blit_arrow
  1174. ;destination in a3, source in a4...
  1175.     lea    $dff000,a6
  1176.     lea    arrow_button_mask,a2
  1177.     ;bitplane 1
  1178. .wait_blitter1
  1179.     btst    #14,$2(a6)
  1180.     btst    #14,$2(a6)
  1181.     bne.s    .wait_blitter1
  1182.  
  1183.     move.w    #$0070,$9a(a6)        ;no vbl interrupt...
  1184.  
  1185.     move.l    a2,$50(a6)
  1186.     move.l    a3,$54(a6)
  1187.     move.l    a3,$48(a6)
  1188.     move.l    a4,$4c(a6)
  1189.     move.l    #$fff8fff8,$44(a6)    ;mask only the most left 13 bits.
  1190.     move.l    #$0fca0000,$40(a6)
  1191.     move.l    #$004e0000,$60(a6)
  1192.     move.l    #$0000004e,$64(a6)
  1193.     move.w    #$0281,$58(a6)
  1194.  
  1195.     move.w    #$8020,$9a(A6)
  1196.  
  1197.     add.l    #200*80,a3
  1198.     add.l    #2*10,a4
  1199.  
  1200.     ;bitplane 2
  1201. .wait_blitter2
  1202.     btst    #14,$2(a6)
  1203.     btst    #14,$2(a6)
  1204.     bne.s    .wait_blitter2
  1205.  
  1206.     move.w    #$0070,$9a(a6)        ;no vbl interrupt...
  1207.  
  1208.     move.l    a2,$50(a6)
  1209.     move.l    a3,$54(a6)
  1210.     move.l    a3,$48(a6)
  1211.     move.l    a4,$4c(a6)
  1212.     move.l    #$fff8fff8,$44(a6)    ;mask only the most left 13 bits.
  1213.     move.l    #$0fca0000,$40(a6)
  1214.     move.l    #$004e0000,$60(a6)
  1215.     move.l    #$0000004e,$64(a6)
  1216.     move.w    #$0281,$58(a6)
  1217.  
  1218.     move.w    #$8020,$9a(A6)
  1219.  
  1220.     rts
  1221.  
  1222.  
  1223. blit_cl_button
  1224. ;destination in a3, source in a4...
  1225.     lea    $dff000,a6
  1226.     ;bitplane 1
  1227. .wait_blitter1
  1228.     btst    #14,$2(a6)
  1229.     btst    #14,$2(a6)
  1230.     bne.w    .wait_blitter1
  1231.  
  1232.     move.w    #$0070,$9a(a6)        ;no vbl interrupt...
  1233.  
  1234.     move.l    a4,$50(a6)
  1235.     move.l    a3,$54(a6)
  1236.     move.l    #-1,$44(a6)
  1237.     move.l    #$09f00000,$40(a6)
  1238.     move.l    #$0000004e,$64(a6)
  1239.     move.w    #$0281,$58(a6)
  1240.  
  1241.     move.w    #$8020,$9a(A6)
  1242.  
  1243.     add.l    #200*80,a3
  1244.     add.l    #2*10,a4
  1245.  
  1246.     ;bitplane 2
  1247. .wait_blitter2
  1248.     btst    #14,$2(a6)
  1249.     btst    #14,$2(a6)
  1250.     bne.s    .wait_blitter2
  1251.  
  1252.     move.w    #$0070,$9a(a6)        ;no vbl interrupt...
  1253.  
  1254.     move.l    a4,$50(a6)
  1255.     move.l    a3,$54(a6)
  1256.     move.l    #-1,$44(a6)
  1257.     move.l    #$09f00000,$40(a6)
  1258.     move.l    #$0000004e,$64(a6)
  1259.     move.w    #$0281,$58(a6)
  1260.  
  1261.     move.w    #$8020,$9a(A6)
  1262.  
  1263.     rts
  1264.  
  1265.  
  1266. blit_sample_info
  1267.     subq.b    #1,d0
  1268.     mulu    #[23*26],d0
  1269.     lea    sample_info_buffer,a0
  1270.     add.l    d0,a0
  1271.  
  1272.     move.l    scopes_clear_buffer,a1
  1273.     add.l    #[18*80]+48,a1
  1274.  
  1275.     lea    $dff000,a6
  1276.  
  1277.     move.w    #$0070,$9a(a6)
  1278. .wait_blitter
  1279.     btst    #14,2(a6)
  1280.     btst    #14,2(a6)
  1281.     bne.s    .wait_blitter
  1282.  
  1283.     move.l    a1,$54(a6)
  1284.     move.l    a0,$50(a6)
  1285.     move.l    #-1,$44(a6)
  1286.     move.l    #$09f00000,$40(a6)
  1287.     move.l    #$00000036,$64(a6)
  1288.     move.w    #$05cd,$58(a6)
  1289.  
  1290.     move.w    #$8020,$9a(a6)
  1291.  
  1292.     move.l    scopes_build_buffer,a1
  1293.     add.l    #[18*80]+48,a1
  1294.  
  1295.     move.w    #$0070,$9a(a6)
  1296. .wait_blitter2
  1297.     btst    #14,2(a6)
  1298.     btst    #14,2(a6)
  1299.     bne.s    .wait_blitter2
  1300.  
  1301.     move.l    a1,$54(a6)
  1302.     move.l    a0,$50(a6)
  1303.     move.l    #-1,$44(a6)
  1304.     move.l    #$09f00000,$40(a6)
  1305.     move.l    #$00000036,$64(a6)
  1306.     move.w    #$05cd,$58(a6)
  1307.  
  1308.     move.w    #$8020,$9a(a6)
  1309.  
  1310.     move.l    scopes_show_buffer,a1
  1311.     add.l    #[18*80]+48,a1
  1312.  
  1313.     move.w    #$0070,$9a(a6)
  1314. .wait_blitter3
  1315.     btst    #14,2(a6)
  1316.     btst    #14,2(a6)
  1317.     bne.s    .wait_blitter3
  1318.  
  1319.     move.l    a1,$54(a6)
  1320.     move.l    a0,$50(a6)
  1321.     move.l    #-1,$44(a6)
  1322.     move.l    #$09f00000,$40(a6)
  1323.     move.l    #$00000036,$64(a6)
  1324.     move.w    #$05cd,$58(a6)
  1325.  
  1326.     move.w    #$8020,$9a(a6)
  1327.  
  1328.     rts
  1329.  
  1330.  
  1331. update_playing_time
  1332.     move.b    frame_counter,d0
  1333.     tst.b    pal_ntsc
  1334.     bne.s    u_p_t_ntsc
  1335. u_p_t_pal    
  1336.     move.b    #50,d1
  1337.     bra.s    u_p_t_v    
  1338. u_p_t_ntsc    
  1339.     move.b    #60,d1
  1340. u_p_t_v
  1341.     cmp.b    d1,d0
  1342.     bge.s    u_p_t_new_second
  1343.     addq.b    #1,frame_counter
  1344.     bra.s    u_p_t_end
  1345.  
  1346. u_p_t_new_second
  1347.     move.b    #0,frame_counter
  1348.     move.b    #1,new_time        ;to force a timeblit        
  1349.     move.b    seconds,d0
  1350.     cmp.b    #59,d0
  1351.     bge.s    u_p_t_new_minute
  1352.     addq.b    #1,seconds
  1353.     bra.s    u_p_t_end
  1354. u_p_t_new_minute
  1355.     move.b    #0,seconds
  1356.     move.b    minutes,d0
  1357.     cmp.b    #59,d0
  1358.     bge.s    u_p_t_new_hour        ;'hmm it's gonna get annoying, jim'
  1359.     addq.b    #1,minutes
  1360.     bra.s    u_p_t_end
  1361. u_p_t_new_hour
  1362.     move.b    #0,minutes
  1363.     move.b    hours,d0
  1364.     cmp.b    #99,d0
  1365.     blt.s    u_p_t_end
  1366.     move.b    #0,hours        ;if it last that long, hmm!
  1367. u_p_t_end
  1368.     rts    
  1369.  
  1370.  
  1371. clear_sample_structs
  1372.     lea    mt_chan1temp,a0
  1373.     move.l    #0,4(a0)
  1374.     move.w    #0,8(a0)
  1375.     move.l    #0,10(a0)
  1376.     move.w    #0,14(a0)
  1377.     move.l    #0,36(a0)
  1378.     move.w    #0,40(a0)
  1379.  
  1380.     lea    mt_chan2temp,a0
  1381.     move.l    #0,4(a0)
  1382.     move.w    #0,8(a0)
  1383.     move.l    #0,10(a0)
  1384.     move.w    #0,14(a0)
  1385.     move.l    #0,36(a0)
  1386.     move.w    #0,40(a0)
  1387.  
  1388.     lea    mt_chan3temp,a0
  1389.     move.l    #0,4(a0)
  1390.     move.w    #0,8(a0)
  1391.     move.l    #0,10(a0)
  1392.     move.w    #0,14(a0)
  1393.     move.l    #0,36(a0)
  1394.     move.w    #0,40(a0)
  1395.  
  1396.     lea    mt_chan4temp,a0
  1397.     move.l    #0,4(a0)
  1398.     move.w    #0,8(a0)
  1399.     move.l    #0,10(a0)
  1400.     move.w    #0,14(a0)
  1401.     move.l    #0,36(a0)
  1402.     move.w    #0,40(a0)
  1403.     rts    
  1404.  
  1405.  
  1406. fill_char_tab
  1407.     lea    char_tab,a0
  1408.     lea    font,a1
  1409.     move.l    #6-1,d7
  1410.     move.w    #$09f0,d6
  1411.     move.w    #$8bfa,d5
  1412. f_c_l1
  1413.     move.l    #20-1,d2
  1414. f_c_l2
  1415.     move.l    a1,(a0)+
  1416.     addq.l    #2,a1
  1417.     move.w    d5,(a0)+
  1418.     move.w    d6,(a0)+
  1419.  
  1420.     dbf    d2,f_c_l2
  1421.  
  1422.     add.l    #[8*40],a1
  1423.  
  1424.     dbf    d7,f_c_l1
  1425.  
  1426.     rts
  1427.     
  1428.  
  1429. fill_track_pos_tab
  1430.     lea    tracks_bitplane,a0
  1431.     lea    track_pos_tab,a1
  1432.  
  1433.     move.l    #[64+7+8]-1,d7
  1434. f_t_p_t_l
  1435.     move.l    a0,(a1)+
  1436.     add.l    #[8*80],a0
  1437.     dbf    d7,f_t_p_t_l
  1438.  
  1439.     rts
  1440.  
  1441.     
  1442. move_track_bitplane
  1443.     lea    track_wait,a0
  1444.     lea    track_pos_tab,a1
  1445.     move.w    mt_patternpos,d0
  1446.     lsr.w    #4,d0
  1447.  
  1448.     add.w    d0,d0
  1449.     add.w    d0,d0
  1450.  
  1451.     move.w    (a1,d0.w),d1
  1452.     move.w    d1,6(a0)
  1453.     addq.w    #2,d0
  1454.     move.w    (a1,d0.w),d1
  1455.     move.w    d1,$a(a0)
  1456.  
  1457.     rts
  1458.  
  1459.  
  1460. store_original_sample_area
  1461.     lea    sample_info_buffer,a0
  1462.     lea    screen_picture+[162*80]+48,a1
  1463.     lea    $dff000,a6
  1464.  
  1465.     move.l    #32-1,d7
  1466. s_o_s_a_l
  1467. .waitblitter
  1468.     btst    #14,2(a6)
  1469.     btst    #14,2(a6)
  1470.     bne.s    .waitblitter
  1471.  
  1472.     move.l    a0,$54(a6)
  1473.     move.l    a1,$50(a6)
  1474.     move.l    #-1,$44(a6)
  1475.     move.l    #$09f00000,$40(a6)
  1476.     move.l    #$00360000,$64(a6)
  1477.     move.w    #$05cd,$58(a6)
  1478.  
  1479.     lea    [23*26](a0),a0
  1480.  
  1481.     dbf    d7,s_o_s_a_l
  1482.  
  1483.     rts
  1484.  
  1485.  
  1486.  
  1487. fill_sample_info_buffer
  1488.     bsr.b    store_original_sample_area
  1489.  
  1490.     move.l    mt_data,a2
  1491.     lea    20(a2),a2
  1492.     lea    sample_info_buffer,a4
  1493.  
  1494.     moveq    #1,d7
  1495. f_s_i_b_l
  1496.     ;blit_sample_name of number (d7)
  1497.     lea    4(a4),a5
  1498.     lea    (a2),a0
  1499. .loop
  1500.     move.b    (a0)+,d0
  1501.     tst.b    d0
  1502.     beq.s    .end_of_samplename
  1503.     lea    (a5),a1
  1504.     bsr.w    blit_char_II
  1505.  
  1506.     addq.l    #1,a5
  1507.     bra.s    .loop
  1508.  
  1509. .end_of_samplename
  1510.     moveq    #0,d1
  1511.     move.w    22(a2),d1        ;get samplelength
  1512.     add.l    d1,d1
  1513.     lea    [13*26](a4),a5
  1514.  
  1515. ;blit samplelength
  1516.     moveq    #5-1,d6
  1517.     move.l    #10000,d4
  1518. .loop2
  1519.     divu    d4,d1
  1520.     move.w    d1,d0
  1521.     add.b    #"0",d0
  1522.     lea    (a5),a1
  1523.     bsr.b    blit_char_II
  1524.     move.w    #0,d1
  1525.     swap    d1
  1526.     addq.l    #1,a5        
  1527.     divu    #10,d4
  1528.     dbf    d6,.loop2
  1529.  
  1530. ;blit sample volume
  1531.     moveq    #0,d1
  1532.     move.b    25(a2),d1
  1533.     lea    [14+[13*26]](a4),a5
  1534.     
  1535.     move.w    d1,d0
  1536.     and.b    #$f0,d0
  1537.     lsr.w    #4,d0
  1538.     bsr.w    bits_to_char
  1539.     lea    (a5),a1
  1540.     bsr.b    blit_char_II
  1541.  
  1542.     addq.l    #1,a5
  1543.         
  1544.     move.w    d1,d0
  1545.     and.b    #$0f,d0
  1546.     bsr.w    bits_to_char
  1547.     lea    (a5),a1
  1548.     bsr.b    blit_char_II
  1549.  
  1550. ;blit sample_number
  1551.     lea    [23+[13*26]](a4),a5
  1552.     move.l    d7,d0
  1553.     and.b    #$f0,d0
  1554.     lsr.b    #4,d0
  1555.     bsr.w    bits_to_char
  1556.     lea    (a5),a1
  1557.     bsr.b    blit_char_II
  1558.  
  1559.     addq.l    #1,a5
  1560.  
  1561.     move.l    d7,d0
  1562.     and.b    #$0f,d0
  1563.     bsr.w    bits_to_char
  1564.     lea    (a5),a1
  1565.     bsr.b    blit_char_II
  1566.  
  1567.     lea    30(a2),a2
  1568.     lea    [26*23](a4),a4
  1569.     addq.b    #1,d7
  1570.     cmp.b    #31,d7
  1571.     ble.w    f_s_i_b_l
  1572.     rts
  1573.  
  1574.     
  1575. ;this blitter routine is used only by fill_sample_info_buffer
  1576. ;this is done to prevent a modulo passing to the other blit_char
  1577. blit_char_II
  1578.     lea    $dff000,a6
  1579.     lea    char_tab,a3
  1580.  
  1581.     and.l    #$ff,d0
  1582.     sub.b    #32,d0
  1583.     lsl.w    #3,d0
  1584.     add.l    d0,a3
  1585.  
  1586.     move.w    #$0070,$9a(a6)        ;prevent for a lev3 interrupt
  1587.  
  1588. .wait_blitter
  1589.     btst    #14,$02(a6)
  1590.     btst    #14,$02(a6)
  1591.     bne.s    .wait_blitter    
  1592.  
  1593.     move.l    a1,d2
  1594.     btst    #0,d2
  1595.     bne.s    b_c_II_dest_is_odd
  1596. b_c_II_dest_is_even
  1597.     move.w    6(a3),$40(a6)
  1598.     clr.w    $42(a6)
  1599.     bra.s    b_c_II_v
  1600. b_c_II_dest_is_odd
  1601.     subq.l    #1,a1
  1602.     move.w    4(a3),$40(a6)
  1603.     clr.w    $42(a6)
  1604. b_c_II_v            
  1605.     move.l    #$ff00ff00,$44(a6)
  1606.     move.l    (a3),$50(a6)
  1607.     move.l    a1,$48(a6)
  1608.     move.l    a1,$54(a6)        ;this blitteroperation is unsplittable!
  1609.     move.l    #$00260018,$64(a6)
  1610.     move.w    #$0018,$60(a6)
  1611.     move.w    #$0201,$58(a6)      
  1612.  
  1613.     move.w    #$8020,$9a(a6)        ;set vbl enable. 
  1614.  
  1615.     rts
  1616.  
  1617.  
  1618. bits_to_char
  1619.     ;d0 has to be number e [0..15]
  1620.  
  1621.     cmp.b    #10,d0
  1622.     blt.s    b_t_c_digit
  1623.     add.b    #55,d0
  1624.     rts
  1625.  
  1626. b_t_c_digit
  1627.     add.b    #48,d0
  1628.     rts    
  1629.  
  1630.     
  1631.  
  1632. ;blits da 64 slotnumbers in the patternbitplane
  1633.  
  1634. blit_slotnos
  1635.     lea    tracks_bitplane+[7*8*80],a1
  1636.     moveq    #0,d7
  1637.  
  1638. b_s_l
  1639.     move.l    d7,d0
  1640.  
  1641.     addq.l    #1,a1
  1642.     divu.w    #10,d0
  1643.     move.l    d0,d3
  1644.     add.b    #48,d0
  1645.  
  1646.     bsr.b    blit_char
  1647.  
  1648.     addq.l    #2,a1
  1649.     swap    d3
  1650.     move.w    d3,d0
  1651.     add.b    #48,d0
  1652.     bsr.b    blit_char
  1653.  
  1654.     add.l    #[[80*8]-2],a1
  1655.     addq.b    #1,d7
  1656.     cmp.b    #64,d7
  1657.     blt.s    b_s_l
  1658.     rts
  1659.             
  1660.         
  1661.     
  1662.  
  1663. blit_char
  1664.     ;d0 = char
  1665.     ;a1 = destination    if a1 is odd, the character is placed in
  1666.                 ;the 8 bits folowing the even part of
  1667.                 ;the addres a1 is containing.
  1668.                 ;a1 is made even before dumped in blitter.
  1669.                 ;this is a fast solution to solve the 
  1670.                 ;problem with 8 bit wide fontblitting ...
  1671.                 ;this font is (sneaky) 16 bits for 1 8bit char
  1672.                 ;to prevent left shifting, (and nasty 
  1673.                 ;calculations..
  1674.  
  1675.     lea    $dff000,a6
  1676.     lea    char_tab,a3
  1677.  
  1678.     and.l    #$ff,d0
  1679.     sub.b    #32,d0
  1680.     lsl.w    #3,d0
  1681.     add.l    d0,a3
  1682.  
  1683.     move.w    #$0070,$9a(a6)        ;prevent for a lev3 interrupt
  1684.  
  1685. .wait_blitter
  1686.     btst    #14,$02(a6)
  1687.     btst    #14,$02(a6)
  1688.     bne.s    .wait_blitter    
  1689.  
  1690.     move.l    a1,d2
  1691.     btst    #0,d2
  1692.     bne.s    b_c_dest_is_odd
  1693. b_c_dest_is_even
  1694.     move.w    6(a3),$40(a6)
  1695.     clr.w    $42(a6)
  1696.     bra.s    b_c_v
  1697. b_c_dest_is_odd
  1698.     subq.l    #1,a1
  1699.     move.w    4(a3),$40(a6)
  1700.     clr.w    $42(a6)
  1701. b_c_v            
  1702.     move.l    #$ff00ff00,$44(a6)
  1703.     move.l    (a3),$50(a6)
  1704.     move.l    a1,$48(a6)
  1705.     move.l    a1,$54(a6)        ;this blitteroperation is unsplittable!
  1706.     move.l    #$0026004e,$64(a6)
  1707.     move.w    #$004e,$60(a6)
  1708.     move.w    #$0201,$58(a6)      
  1709.  
  1710.     move.w    #$8020,$9a(a6)        ;set vbl enable. 
  1711.  
  1712.     rts
  1713.  
  1714.  
  1715. blit_note
  1716.     ;d0.l = note from pattern
  1717.  
  1718.     lea    notetab,a0
  1719.      move.l    a4,a1            ;use a4(is notedestination)
  1720.     lea    mt_periodtable,a2
  1721.  
  1722.     move.l    d0,d3
  1723.     move.l    d0,d4
  1724.  
  1725.     swap    d0
  1726.     and.l    #$0fff,d0
  1727.  
  1728.     moveq    #0,d1
  1729. search_period    
  1730.     move.w    (a2)+,d2
  1731.     cmp.w    d0,d2
  1732.     beq.s    b_n_v
  1733.     addq.w    #1,d1
  1734.     cmp.w    #36,d1
  1735.     blt.s    search_period
  1736.  
  1737. b_n_v
  1738.     add.w    d1,d1            
  1739.     add.w    d1,d1            
  1740.  
  1741.     add.l    d1,a0
  1742.  
  1743.     ; blit note 
  1744.     
  1745.     moveq    #0,d0
  1746.     move.b    (a0)+,d0
  1747.     bsr.w    blit_char    
  1748.     add.l    d5,a1
  1749.  
  1750.     moveq    #0,d0
  1751.     move.b    (a0)+,d0
  1752.     bsr.w    blit_char    
  1753.     add.l    d6,a1
  1754.  
  1755.     moveq    #0,d0
  1756.     move.b    (a0)+,d0
  1757.     bsr.w    blit_char    
  1758.  
  1759.     ;blit samplenr 
  1760.  
  1761.     moveq    #12,d2
  1762.  
  1763.     and.l    #$f000f000,d3    ;get only the sample number.
  1764.     lsr.l    d2,d3
  1765.  
  1766.     swap    d3
  1767.     move.w    d3,d0
  1768.     bsr.w    bits_to_char
  1769.  
  1770.     add.l    d5,a1        ;skip a space between samplenr and note.
  1771.     bsr.w    blit_char
  1772.  
  1773.     swap    d3
  1774.     move.w    d3,d0
  1775.     bsr.w    bits_to_char    ;in d0 da bits, returns in d0 the asciicode
  1776.  
  1777.     add.l    d6,a1
  1778.     bsr.w    blit_char
  1779.  
  1780.     ;blit effect command and command data
  1781.  
  1782.     and.l    #$0fff,d4    ;to get only the effect command and the data
  1783.     
  1784.     move.l    d4,d0
  1785.  
  1786.     lsr.w    #8,d0
  1787.     bsr.w    bits_to_char
  1788.  
  1789.     add.l    d5,a1
  1790.     bsr.w    blit_char        
  1791.  
  1792.     move.l    d4,d0
  1793.     lsr.w    #4,d0
  1794.     and.b    #$0f,d0
  1795.     bsr.w    bits_to_char
  1796.  
  1797.     add.l    d6,a1
  1798.     bsr.w    blit_char
  1799.  
  1800.     move.l    d4,d0
  1801.     and.b    #$0f,d0
  1802.     bsr.w    bits_to_char
  1803.  
  1804.     add.l    d5,a1
  1805.     bsr.w    blit_char
  1806.  
  1807.     add.l    d6,a1
  1808.     move.l    #32,d0
  1809.     bsr.w    blit_char
  1810.     rts        
  1811.  
  1812.  
  1813. blit_row
  1814.     move.l    pattern_pos,a5    ;patternpos is slotpointer. (no trackpointer)
  1815.     move.l    note_dest,a4
  1816.     moveq    #1,d5        ;skip a1 on odd addies    
  1817.     moveq    #2,d6        ;skip a1 on even$addies
  1818.  
  1819.     move.l    a4,a1
  1820.  
  1821.     move.l    (a5),d0
  1822.     bsr.w    blit_note
  1823.     add.l    #9,a4
  1824.     
  1825.     exg    d5,d6
  1826.  
  1827.     move.l    4(a5),d0
  1828.     bsr.w    blit_note
  1829.     add.l    #9,a4
  1830.  
  1831.     exg    d5,d6
  1832.         
  1833.     move.l    8(a5),d0
  1834.     bsr.w    blit_note
  1835.     add.l    #9,a4
  1836.  
  1837.     exg    d5,d6
  1838.  
  1839.     move.l    12(a5),d0
  1840.     bsr.w    blit_note
  1841.  
  1842.     add.l    #[8*80],note_dest    ;next pos in bitplane
  1843.     rts
  1844.  
  1845.  
  1846. blit_pattern
  1847.     moveq    #0,d1
  1848.     lea    track_pos_tab,a0
  1849.     move.w    blit_note_slot_teller,d1
  1850.  
  1851.     cmp.w    #64,d1
  1852.  
  1853.     bge.b    b_p_e    
  1854.  
  1855.     ;calc note_destination
  1856.     add.w    d1,d1
  1857.     add.w    d1,d1
  1858.  
  1859.     add.w    #[7*4],d1
  1860.     move.l    (a0,d1.w),a1
  1861.  
  1862.     add.l    #4,a1
  1863.     move.l    a1,note_dest
  1864.  
  1865.     moveq    #0,d0
  1866.     move.b    pattern_pointer,d0
  1867.  
  1868.     moveq    #10,d2
  1869.     lsl     d2,d0        ;d0 * 1024    (pattern is 1K long.)
  1870.  
  1871.     add.l    #1084,d0    
  1872.     add.l    mt_data,d0
  1873.     sub.w    #[7*4],d1
  1874.  
  1875.     add.w    d1,d1
  1876.     add.w    d1,d1
  1877.     add.l    d1,d0
  1878.  
  1879.     move.l    d0,pattern_pos    ;start pattern.
  1880.  
  1881.     bsr.w    blit_row
  1882.  
  1883.     add.w    #1,blit_note_slot_teller
  1884.  
  1885. b_p_e
  1886.     rts
  1887.  
  1888.  
  1889.  
  1890. clear_area
  1891.     ;a0=destination address
  1892.     ;d0=bltsize
  1893.     ;d1=mask
  1894.     ;d2=modulo a & d
  1895.     ;d3=modulo c
  1896.  
  1897.     move.w    #$0070,$9a(a6)        ;prevent for a lev3 interrupt
  1898.  
  1899. c_a_wait_blitter
  1900.     btst    #14,$2(a6)
  1901.     btst    #14,$2(a6)
  1902.     bne.s    c_a_wait_blitter
  1903.  
  1904.     move.l    #clear_block,$50(a6)
  1905.     move.l    d1,$44(a6)        ;this blit is unsplittable!!!!
  1906.     move.l    a0,$48(a6)
  1907.     move.l    a0,$54(a6)
  1908.     move.l    #$0ba00000,$40(a6)
  1909.     move.l    d2,$64(a6)
  1910.     move.w    d3,$60(a6)
  1911.     move.w    d0,$58(a6)
  1912.  
  1913.     move.w    #$8020,$9a(a6)        ;set vbl enable
  1914.  
  1915.     rts
  1916.  
  1917.  
  1918.  
  1919. blit_play_time
  1920.     move.b    #0,new_time
  1921.  
  1922.     ;blit hours
  1923.     moveq    #0,d1
  1924.     move.b    hours,d1
  1925.  
  1926.     divu    #10,d1
  1927.     moveq    #0,d0
  1928.     move.b    d1,d0
  1929.  
  1930.     add.b    #"0",d0
  1931.     lea    screen_picture+[3*80*200]+[111*80]+53,a1
  1932.     bsr.w    blit_char
  1933.  
  1934.     swap    d1
  1935.  
  1936.     moveq    #0,d0
  1937.     move.b    d1,d0
  1938.     add.b    #"0",d0
  1939.     lea    screen_picture+[3*80*200]+[111*80]+54,a1
  1940.  
  1941.     bsr.w    blit_char
  1942.  
  1943.     ;blit ':'
  1944.  
  1945.     moveq    #0,d0
  1946.     move.b    #":",d0
  1947.     lea    screen_picture+[3*80*200]+[111*80]+55,a1
  1948.  
  1949.     bsr.w    blit_char
  1950.  
  1951.     ;blit_minutes
  1952.     
  1953.     moveq    #0,d1
  1954.     move.b    minutes,d1
  1955.  
  1956.     divu    #10,d1
  1957.     moveq    #0,d0
  1958.     move.b    d1,d0
  1959.  
  1960.     add.b    #"0",d0
  1961.     lea    screen_picture+[3*80*200]+[111*80]+56,a1
  1962.     bsr.w    blit_char
  1963.  
  1964.     swap    d1
  1965.  
  1966.     moveq    #0,d0
  1967.     move.b    d1,d0
  1968.     add.b    #"0",d0
  1969.     lea    screen_picture+[3*80*200]+[111*80]+57,a1
  1970.  
  1971.     bsr.w    blit_char
  1972.  
  1973.     ;blit '.'
  1974.  
  1975.     moveq    #0,d0
  1976.     move.b    #".",d0
  1977.     lea    screen_picture+[3*80*200]+[111*80]+58,a1
  1978.  
  1979.     bsr.w    blit_char
  1980.  
  1981.     moveq    #0,d1
  1982.     move.b    seconds,d1
  1983.  
  1984.     divu    #10,d1
  1985.     moveq    #0,d0
  1986.     move.b    d1,d0
  1987.  
  1988.     add.b    #"0",d0
  1989.     lea    screen_picture+[3*80*200]+[111*80]+59,a1
  1990.     bsr.w    blit_char
  1991.  
  1992.     swap    d1
  1993.  
  1994.     moveq    #0,d0
  1995.     move.b    d1,d0
  1996.     add.b    #"0",d0
  1997.     lea    screen_picture+[3*80*200]+[111*80]+60,a1
  1998.  
  1999.     bsr.w    blit_char
  2000.  
  2001.     rts
  2002.  
  2003.  
  2004. blit_pattern_no
  2005.     lea    $dff000,a6
  2006.  
  2007.     move.l    #$000000ff,d1
  2008.     lea    screen_picture+[13*80]+4,a0
  2009.     move.l    #$0000004c,d2
  2010.     move.w    #$004c,d3
  2011.     move.w    #$0202,d0
  2012.     
  2013.     bsr.w    clear_area
  2014.  
  2015.     moveq    #0,d1
  2016.     move.b    pattern_pointer,d1
  2017.  
  2018.     cmp.b    #10,d1
  2019.     blt.b    b_p_n_only_tens
  2020.  
  2021.     divu    #10,d1
  2022.  
  2023.     lea    screen_picture+[13*80]+4+1,a1
  2024.  
  2025.     moveq    #0,d0
  2026.     move.b    d1,d0
  2027.     add.b    #"0",d0
  2028.  
  2029.     bsr.w    blit_char
  2030.     swap    d1
  2031.  
  2032. b_p_n_only_tens    
  2033.     lea    screen_picture+[13*80]+4+2,a1
  2034.  
  2035.     moveq    #0,d0
  2036.     move.b    d1,d0
  2037.     add.b    #"0",d0
  2038.  
  2039.     bsr.w    blit_char
  2040.  
  2041.     rts
  2042.  
  2043.  
  2044. blit_song_name:
  2045.     move.l    mt_data,a0
  2046.     lea    screen_picture+[3*80*200]+[123*80]+50,a1
  2047.     moveq    #1,d5
  2048.     moveq    #2,d6
  2049.  
  2050.     moveq    #20-1,d7
  2051. b_sng_n_l
  2052.     moveq    #0,d0
  2053.     move.b    (a0)+,d0
  2054.     tst.b    d0
  2055.     beq.s    b_sng_n_v
  2056.  
  2057.     bsr.w    blit_char
  2058.     add.l    d5,a1
  2059.     exg    d5,d6
  2060.     dbf    d7,b_sng_n_l
  2061.  
  2062. b_sng_n_v
  2063.     rts    
  2064.  
  2065.  
  2066. blit_song_length
  2067.     lea    $dff000,a6
  2068.  
  2069.     move.l    #$000000ff,d1
  2070.     lea    screen_picture+[3*80*200]+[135*80]+48,a0
  2071.     move.l    #$0000004c,d2
  2072.     move.w    #$004c,d3
  2073.     move.w    #$0202,d0
  2074.  
  2075.     bsr.w    clear_area    
  2076.  
  2077.     move.l    mt_data,a6
  2078.     moveq    #0,d1
  2079.     move.b    950(a6),d1    
  2080.  
  2081.     lea    $dff000,a6
  2082.  
  2083.     cmp.b    #10,d1
  2084.     blt.s    b_sng_l_only_tens
  2085.     cmp.b    #100,d1
  2086.     blt.s    b_sng_l_under_hundred
  2087.  
  2088.     divu    #100,d1
  2089.     
  2090.     lea    screen_picture+[3*80*200]+[135*80]+48,a1
  2091.     moveq    #0,d0
  2092.     move.b    d1,d0
  2093.     add.b    #"0",d0
  2094.     bsr.w    blit_char
  2095.  
  2096.     move.w    #0,d1
  2097.     swap     d1
  2098.     
  2099. b_sng_l_under_hundred
  2100.     divu    #10,d1
  2101.  
  2102.     lea    screen_picture+[3*80*200]+[135*80]+48+1,a1
  2103.  
  2104.     moveq    #0,d0
  2105.     move.b    d1,d0
  2106.     add.b    #"0",d0
  2107.  
  2108.     bsr.w    blit_char
  2109.     swap    d1
  2110.  
  2111. b_sng_l_only_tens    
  2112.     lea    screen_picture+[3*80*200]+[135*80]+48+2,a1
  2113.  
  2114.     moveq    #0,d0
  2115.     move.b    d1,d0
  2116.     add.b    #"0",d0
  2117.  
  2118.     bsr.w    blit_char
  2119.  
  2120.     rts
  2121.  
  2122.  
  2123.  
  2124. blit_song_pos
  2125.     lea    $dff000,a6
  2126.  
  2127.     moveq    #0,d1
  2128.     lea    screen_picture+[3*80*200]+[135*80]+56,a0
  2129.     move.l    #$0000004e,d2
  2130.     move.w    #$004e,d3
  2131.     move.w    #$0201,d0
  2132.  
  2133.     bsr.w    clear_area
  2134.  
  2135.     moveq    #0,d1
  2136.     move.b    mt_SongPos,d1
  2137.     cmp.b    #10,d1
  2138.     blt.b    b_s_p_only_tens
  2139.     cmp.b    #100,d1
  2140.     blt.s    b_s_p_under_hundred
  2141.  
  2142.     divu    #100,d1
  2143.     
  2144.     lea    screen_picture+[3*80*200]+[135*80]+56,a1
  2145.     moveq    #0,d0
  2146.     move.b    d1,d0
  2147.     add.b    #"0",d0
  2148.     bsr.w    blit_char
  2149.  
  2150.     move.w    #0,d1
  2151.     swap     d1
  2152.     
  2153. b_s_p_under_hundred
  2154.  
  2155.     divu    #10,d1
  2156.  
  2157.     lea    screen_picture+[3*80*200]+[135*80]+56+1,a1
  2158.  
  2159.     moveq    #0,d0
  2160.     move.b    d1,d0
  2161.     add.b    #"0",d0
  2162.  
  2163.     bsr.w    blit_char
  2164.     swap    d1
  2165.  
  2166. b_s_p_only_tens    
  2167.     lea    screen_picture+[3*80*200]+[135*80]+56+2,a1
  2168.  
  2169.     moveq    #0,d0
  2170.     move.b    d1,d0
  2171.     add.b    #"0",d0
  2172.  
  2173.     bsr.w    blit_char
  2174.  
  2175.     rts
  2176.  
  2177.  
  2178.  
  2179. blit_vbl_tempo
  2180.     lea    $dff000,a6
  2181.  
  2182.     moveq    #0,d1
  2183.     lea    screen_picture+[3*80*200]+[135*80]+68,a0
  2184.     move.l    #$0000004e,d2
  2185.     move.w    #$004e,d3
  2186.     move.w    #$0201,d0
  2187.  
  2188.     bsr.w    clear_area
  2189.  
  2190.     moveq    #0,d1
  2191.     move.b    mt_speed,d1
  2192.  
  2193.     cmp.b    #10,d1
  2194.     blt.b    b_vbl_t_only_tens
  2195.  
  2196.     divu    #10,d1
  2197.  
  2198.     lea    screen_picture+[3*80*200]+[135*80]+68,a1
  2199.  
  2200.     moveq    #0,d0
  2201.     move.b    d1,d0
  2202.     add.b    #"0",d0
  2203.  
  2204.     bsr.w    blit_char
  2205.     swap    d1
  2206.  
  2207. b_vbl_t_only_tens    
  2208.     lea    screen_picture+[3*80*200]+[135*80]+68+1,a1
  2209.  
  2210.     moveq    #0,d0
  2211.     move.b    d1,d0
  2212.     add.b    #"0",d0
  2213.  
  2214.     bsr.w    blit_char
  2215.  
  2216.     rts
  2217.  
  2218.  
  2219.  
  2220. blit_bpm
  2221.     lea    $dff000,a6
  2222.  
  2223.     move.l    #$000000ff,d1
  2224.     lea    screen_picture+[3*200*80]+[135*80]+76,a0
  2225.     move.l    #$0000004c,d2
  2226.     move.w    #$004c,d3
  2227.     move.w    #$0202,d0
  2228.  
  2229.     bsr.w    clear_area
  2230.  
  2231.     moveq    #0,d1
  2232.     move.w    RealTempo,d1
  2233.  
  2234.     cmp.w    #10,d1
  2235.     blt.b    b_bpm_only_tens
  2236.     cmp.w    #100,d1
  2237.     blt.s    b_bpm_under_hundred
  2238.  
  2239.     divu    #100,d1
  2240.     
  2241.     lea    screen_picture+[3*80*200]+[135*80]+76,a1
  2242.     moveq    #0,d0
  2243.     move.b    d1,d0
  2244.     add.b    #"0",d0
  2245.     bsr.w    blit_char
  2246.  
  2247.     move.w    #0,d1
  2248.     swap     d1
  2249.     
  2250. b_bpm_under_hundred
  2251.  
  2252.     divu    #10,d1
  2253.  
  2254.     lea    screen_picture+[3*80*200]+[135*80]+76+1,a1
  2255.  
  2256.     moveq    #0,d0
  2257.     move.b    d1,d0
  2258.     add.b    #"0",d0
  2259.  
  2260.     bsr.w    blit_char
  2261.     swap    d1
  2262.  
  2263. b_bpm_only_tens    
  2264.     lea    screen_picture+[3*80*200]+[135*80]+76+2,a1
  2265.  
  2266.     moveq    #0,d0
  2267.     move.b    d1,d0
  2268.     add.b    #"0",d0
  2269.  
  2270.     bsr.w    blit_char
  2271.  
  2272.     rts
  2273.  
  2274. copy_scopes_bitplane_to_buffers
  2275.     lea    screen_picture+[[24+120]*80],a0
  2276.     lea    second_buf_scopes,a1
  2277.     lea    third_buf_scopes,a2
  2278.     lea    $dff000,a6
  2279.  
  2280. .wait
  2281.     btst    #14,$2(a6)
  2282.     btst    #14,$2(a6)
  2283.     bne.s    .wait
  2284.  
  2285.     ;blit to second buffer
  2286.  
  2287.     move.l    a0,$50(a6)
  2288.     move.l    #$09f00000,$40(a6)
  2289.     move.l    #$00000000,$64(a6)
  2290.     move.l    a1,$54(a6)
  2291.     move.l    #-1,$44(a6)
  2292.  
  2293.     move.w    #$1068,$58(a6)
  2294.  
  2295.  
  2296. .wait2
  2297.     btst    #14,$2(a6)
  2298.     btst    #14,$2(a6)
  2299.     bne.s    .wait2
  2300.  
  2301.     ;blit to third buffer
  2302.  
  2303.     move.l    a0,$50(a6)
  2304.     move.l    #$09f00000,$40(a6)
  2305.     move.l    #$00000000,$64(a6)
  2306.     move.l    a2,$54(a6)
  2307.     move.l    #-1,$44(a6)
  2308.  
  2309.     move.w    #$1068,$58(a6)
  2310.  
  2311.     rts
  2312.  
  2313.  
  2314.  
  2315. clear_scope_area
  2316.     lea    $dff000,a6
  2317.  
  2318. c_s_a_wb_l
  2319.     btst    #14,$2(a6)
  2320.     btst    #14,$2(a6)
  2321.     bne.s    c_s_a_wb_l
  2322.  
  2323.     move.l    #$01000000,$40(a6)
  2324.     move.w    #$2c,$66(a6)
  2325.     move.l    scopes_clear_buffer,d0
  2326.     add.l    #[16*80]+4,d0
  2327.     move.l    d0,$54(a6)
  2328.     move.w    #$0812,$58(a6)
  2329.     rts
  2330.  
  2331. plot_scopes
  2332.     ;check for pal or NTWC, now only PAL...
  2333.     ;PAL has 318 lines in a frame, NTSC 262.
  2334.     ;this means that there are 318 words read in a frame. NTSC
  2335.     ;audio hardware reads 262 words in a frame.
  2336.  
  2337.     ;after that, the number of sample bytes per frame is calculated
  2338.     ;no of bytes per frame = (clockconstant/50)/periode)
  2339.  
  2340.     lea    plot_table,a0
  2341.     move.l    scopes_build_buffer,a6
  2342.     add.l    #[15*80],a6
  2343.  
  2344.     tst.b    pal_ntsc
  2345.     bne.s    p_s_ntsc
  2346.  
  2347. p_s_pal
  2348.     lea    [3546895/50],a5    ;clockconstante /50
  2349.     bra.s    p_s_verder
  2350.  
  2351. p_s_ntsc
  2352.     lea    [3579545/60],a5    ;clockconstante /60
  2353.  
  2354. p_s_verder
  2355.     lea    mt_chan1temp,a1
  2356.     move.w    n_replen(a1),chan1_replen
  2357.     move.l    n_loopstart(a1),chan1_loopstart
  2358.     move.w    n_length(a1),chan1_length
  2359.     move.l    n_start(a1),chan1_start
  2360.     move.w    n_period(a1),chan1_period
  2361.     move.b    n_volume(a1),chan1_volume
  2362.  
  2363.     lea    mt_chan2temp,a1
  2364.     move.w    n_replen(a1),chan2_replen
  2365.     move.l    n_loopstart(a1),chan2_loopstart
  2366.     move.w    n_length(a1),chan2_length
  2367.     move.l    n_start(a1),chan2_start
  2368.     move.w    n_period(a1),chan2_period
  2369.     move.b    n_volume(a1),chan2_volume
  2370.     
  2371.  
  2372.     lea    mt_chan3temp,a1
  2373.     move.w    n_replen(a1),chan3_replen
  2374.     move.l    n_loopstart(a1),chan3_loopstart
  2375.     move.w    n_length(a1),chan3_length
  2376.     move.l    n_start(a1),chan3_start
  2377.     move.w    n_period(a1),chan3_period
  2378.     move.b    n_volume(a1),chan3_volume
  2379.  
  2380.     lea    mt_chan4temp,a1
  2381.     move.w    n_replen(a1),chan4_replen
  2382.     move.l    n_loopstart(a1),chan4_loopstart
  2383.     move.w    n_length(a1),chan4_length
  2384.     move.l    n_start(a1),chan4_start
  2385.     move.w    n_period(a1),chan4_period
  2386.     move.b    n_volume(a1),chan4_volume
  2387.  
  2388. ;scope1    
  2389.     lea    chan1_start,a1
  2390.     move.l    #32,d5
  2391.     lea    sample_chan1_pointer,a4
  2392.     move.l    a5,d0
  2393.     bsr.b    plot_a_scope
  2394. ;scope2    
  2395.     lea    chan2_start,a1
  2396.     move.l    #104,d5
  2397.     lea    sample_chan2_pointer,a4
  2398.     move.l    a5,d0
  2399.     bsr.b    plot_a_scope
  2400. ;scope3    
  2401.     lea    chan3_start,a1
  2402.     move.l    #176,d5
  2403.     lea    sample_chan3_pointer,a4
  2404.     move.l    a5,d0
  2405.     bsr.b    plot_a_scope
  2406. ;scope4    
  2407.     lea    chan4_start,a1
  2408.     move.l    #248,d5
  2409.     lea    sample_chan4_pointer,a4
  2410.     move.l    a5,d0
  2411.     bsr.b    plot_a_scope
  2412.  
  2413.     rts
  2414.  
  2415.  
  2416. plot_a_scope
  2417.     ;a1 = pointer to tempstructure
  2418.     ;d5=start x xcoordinate
  2419.     ;a0=plottab    
  2420.     ;a4=sample_chanx_pointer
  2421.  
  2422.     moveq    #0,d1
  2423.     move.w    12(a1),d1    ;get period
  2424.  
  2425.     tst.w    d1
  2426.     bne.s    sc_period
  2427.  
  2428.     moveq    #0,d2
  2429.     bra.s    sc_v
  2430.  
  2431. sc_period    
  2432.     move.l    d0,d2
  2433.     divu     d1,d2            ;calc number of bytes per frame
  2434.     bclr    #0,d2            ;even no of bytes!
  2435.     and.l    #$ffff,d2
  2436.  
  2437. sc_v
  2438.     cmp.w    #1,10(a1)
  2439.     bgt.s    scope_loop
  2440.  
  2441.     ;plot the sample
  2442.  
  2443.     move.l    (a4),d3            ;get hardware position in sample
  2444.     
  2445.     move.l    d3,a2
  2446.  
  2447.     add.l    d2,d3    
  2448.     move.l    d3,(a4)
  2449.  
  2450.     moveq    #0,d7
  2451.     move.l    0(a1),d4    ;start
  2452.     move.w    4(a1),d7
  2453.     add.w    d7,d7
  2454.     add.l    d7,d4        ;add length
  2455.  
  2456.     move.l    #64-1,d7
  2457.  
  2458.     moveq    #0,d6
  2459.     move.b    14(a1),d6    ;get volume
  2460.     
  2461. sc_p_l
  2462.     moveq    #0,d0
  2463.     move.b    (a2)+,d0
  2464.     cmp.l    d4,a2
  2465.     bge.s    sc_p_l0
  2466.  
  2467.     ext.w    d0
  2468.     muls    d6,d0
  2469.     asr.w    #6,d0
  2470.     bra.s    sc_p_l_n0
  2471.  
  2472. sc_p_l0
  2473.     moveq    #0,d0
  2474. sc_p_l_n0
  2475.     add.w    #128,d0
  2476.     add.w    d0,d0
  2477.  
  2478.     moveq    #0,d1
  2479.     
  2480.     move.w    (a0,d0.w),d1
  2481.     move.l    a6,a3
  2482.     add.l    d1,a3    
  2483.  
  2484.     move.l    d5,d0
  2485.     lsr.w    #3,d0
  2486.     
  2487.     move.l    d5,d1
  2488.     and.l    #$07,d1
  2489.     eor.b    #7,d1
  2490.  
  2491.     bset    d1,(a3,d0.w)
  2492.     addq.l    #1,d5
  2493.  
  2494.     dbf    d7,sc_p_l    
  2495.     rts
  2496.  
  2497.  
  2498. scope_loop
  2499.     ;plot the sample
  2500.  
  2501.     move.l    (a4),d3            ;get hardware position in sample
  2502.     move.l    6(a1),d1    ;loopstart
  2503.  
  2504.     moveq    #0,d4
  2505.     move.w    10(a1),d4
  2506.     lsl.w    #1,d4
  2507.     add.l    d4,d1        ;replen
  2508.  
  2509.     add.l    d2,d3    
  2510.     move.l    d3,a2
  2511.  
  2512.     cmp.l    d1,d3
  2513.     ble.s    l_sc_no_loop_restart
  2514.  
  2515.     sub.l    d1,d3
  2516.     
  2517.     moveq    #0,d4
  2518.     move.w    10(a1),d4
  2519.  
  2520.     add.w    d4,d4
  2521.     divu    d4,d3
  2522.     move.w    #0,d3
  2523.     swap    d3
  2524.     add.l    6(a1),d3    ;loopstart
  2525.  
  2526.     move.l    d3,a2
  2527. l_sc_no_loop_restart
  2528.     move.l    d3,(a4)
  2529.  
  2530.     move.l    #64-1,d7
  2531.  
  2532.     moveq    #0,d6
  2533.     move.b    14(a1),d6
  2534.         
  2535. l_sc_p_l
  2536.     moveq    #0,d0
  2537.     move.b    (a2)+,d0
  2538.     cmp.l    d1,a2
  2539.     bge.s    l_sc_p_l_rs
  2540.  
  2541.     ext.w    d0
  2542.     muls    d6,d0
  2543.     asr.w    #6,d0
  2544.     bra.s    l_sc_p_l_nrs
  2545.     
  2546. l_sc_p_l_rs
  2547.     move.l    6(a1),a2    ;loopstart
  2548.     move.b    (a2)+,d0
  2549.     ext.w    d0
  2550.     muls    d6,d0
  2551.     asr.w    #6,d0
  2552.             
  2553. l_sc_p_l_nrs
  2554.     add.w    #128,d0
  2555.     add.w    d0,d0
  2556.  
  2557.     moveq    #0,d2
  2558.  
  2559.     move.w    (a0,d0.w),d2
  2560.  
  2561.     move.l    a6,a3
  2562.     add.l    d2,a3
  2563.  
  2564.     move.l    d5,d0
  2565.     lsr.w    #3,d0
  2566.     
  2567.     move.l    d5,d2
  2568.     and.l    #$07,d2
  2569.     eor.b    #7,d2
  2570.  
  2571.     bset    d2,(a3,d0.w)
  2572.     addq.l    #1,d5
  2573.  
  2574.     dbf    d7,l_sc_p_l    
  2575.  
  2576.     rts
  2577.  
  2578.  
  2579. swap_scopes_screen
  2580.     move.l    scopes_show_buffer,d0
  2581.     move.l    scopes_clear_buffer,d1
  2582.     move.l    scopes_build_buffer,d2
  2583.  
  2584.     move.l    d2,scopes_show_buffer
  2585.     move.l    d1,scopes_build_buffer
  2586.     move.l    d0,scopes_clear_buffer
  2587.  
  2588.     move.l    scope_screen,a0
  2589.     swap    d2
  2590.     move.w    d2,2(a0)
  2591.     swap    d2
  2592.     move.w    d2,6(a0)
  2593.  
  2594.     rts
  2595.  
  2596.  
  2597. move_vu_meters
  2598.     ;chan1
  2599.     tst.w    mt_chan1temp
  2600.     beq.s    move_down_chan1
  2601. chan1_up    
  2602.     move.w    #0,mt_chan1temp
  2603.     moveq    #0,d0
  2604.     move.b    chan1_volume,d0
  2605.     lsl.w    #7,d0
  2606.     move.b    #0,d0
  2607.     move.w    #$b84e,d1
  2608.     sub.w    d0,d1
  2609.     move.w    d1,vu1_xy
  2610.     move.w    #$b900,vu1_stop
  2611.     bra.s    chan2_up
  2612.  
  2613. move_down_chan1
  2614.     moveq    #0,d0
  2615.     move.w    vu1_xy,d0
  2616.     add.w    #$0100,d0
  2617.     cmp.l    #$b84e,d0
  2618.     ble.s    .vu1skip    
  2619.     move.w    #$b84e,d0
  2620. .vu1skip
  2621.     move.w    d0,vu1_xy
  2622.  
  2623.     ;chan2
  2624. chan2_up
  2625.     tst.w    mt_chan2temp
  2626.     beq.s    move_down_chan2
  2627.     move.w    #0,mt_chan2temp
  2628.     moveq    #0,d0
  2629.     move.b    chan2_volume,d0
  2630.     lsl.w    #7,d0
  2631.     move.b    #0,d0
  2632.     move.w    #$b860,d1
  2633.     sub.w    d0,d1
  2634.     move.w    d1,vu2_xy
  2635.     move.w    #$b900,vu2_stop
  2636.     bra.s    chan3_up
  2637.  
  2638. move_down_chan2
  2639.     moveq    #0,d0
  2640.     move.w    vu2_xy,d0
  2641.     add.w    #$0100,d0
  2642.     cmp.l    #$b860,d0
  2643.     ble.s    .vu2skip    
  2644.  
  2645.     move.w    #$b860,d0
  2646. .vu2skip
  2647.     move.w    d0,vu2_xy
  2648.  
  2649.     ;chan3
  2650. chan3_up
  2651.     tst.w    mt_chan3temp
  2652.     beq.s    move_down_chan3
  2653.     move.w    #0,mt_chan3temp
  2654.     moveq    #0,d0
  2655.     move.b    chan3_volume,d0
  2656.     lsl.w    #7,d0
  2657.     move.b    #0,d0
  2658.     move.w    #$b872,d1
  2659.     sub.w    d0,d1
  2660.     move.w    d1,vu3_xy
  2661.     move.w    #$b900,vu3_stop
  2662.     bra.s    chan4_up
  2663.  
  2664. move_down_chan3
  2665.     moveq    #0,d0
  2666.     move.w    vu3_xy,d0
  2667.     add.w    #$0100,d0
  2668.     cmp.l    #$b872,d0
  2669.     ble.s    .vu3skip    
  2670.  
  2671.     move.w    #$b872,d0
  2672. .vu3skip
  2673.     move.w    d0,vu3_xy
  2674.  
  2675.  
  2676.     ;chan4
  2677. chan4_up
  2678.     tst.w    mt_chan4temp
  2679.     beq.s    move_down_chan4
  2680.     move.w    #0,mt_chan4temp
  2681.     moveq    #0,d0
  2682.     move.b    chan4_volume,d0
  2683.     lsl.w    #7,d0
  2684.     move.b    #0,d0
  2685.     move.w    #$b884,d1
  2686.     sub.w    d0,d1
  2687.     move.w    d1,vu4_xy
  2688.     move.w    #$b900,vu4_stop
  2689.     bra.s    m_v_m_end
  2690.     
  2691. move_down_chan4
  2692.     moveq    #0,d0
  2693.     move.w    vu4_xy,d0
  2694.     add.w    #$0100,d0
  2695.     cmp.l    #$b884,d0
  2696.     ble.s    .vu4skip    
  2697.  
  2698.     move.w    #$b884,d0
  2699. .vu4skip
  2700.     move.w    d0,vu4_xy
  2701.  
  2702. m_v_m_end
  2703.     rts
  2704.     
  2705.  
  2706. move_pointer
  2707.     moveq    #0,d1
  2708.     moveq    #0,d2
  2709.     moveq    #0,d3
  2710.     move.w    $dff00a,d0
  2711.     move.b    last_pulses_x,d1
  2712.     move.b    last_pulses_y,d2
  2713.     move.w    d0,d3
  2714.  
  2715.     move.b    d3,last_pulses_x
  2716.     lsr.w    #8,d3
  2717.     move.b    d3,last_pulses_y
  2718.  
  2719.     ;d3 contains the current Y pulse count
  2720.  
  2721. m_p_check_x
  2722.     sub.b    d1,d0    ;calculate speed in x direction
  2723.     tst.b    d0
  2724.     blt.s    m_p_x_left
  2725.  
  2726. m_p_x_right
  2727.     and.w    #$00ff,d0
  2728.     move.w    x_coordinate,d4
  2729.     move.w    d4,x_coordinate_old
  2730.     add.w    d0,d4
  2731.     cmp.w    #319,d4
  2732.     ble.s    .put_coordinate
  2733.     move.w    #319,d4
  2734. .put_coordinate
  2735.     move.w    d4,x_coordinate
  2736.  
  2737.     bra.s    m_p_check_y        
  2738.     
  2739. m_p_x_left
  2740.     ;d0.b is negative
  2741.     
  2742.     and.w    #$00ff,d0
  2743.     move.w    x_coordinate,d4
  2744.     move.w    d4,x_coordinate_old
  2745.     neg.b    d0
  2746.     sub.w    d0,d4
  2747.     tst.w    d4
  2748.     bge.s    .put_coordinate
  2749.     moveq    #0,d4
  2750. .put_coordinate
  2751.     move.w    d4,x_coordinate
  2752.  
  2753. m_p_check_y
  2754.     sub.b    d2,d3    ;calculate speed in x direction
  2755.     tst.b    d3
  2756.     blt.s    m_p_y_up
  2757.  
  2758. m_p_y_down
  2759.     and.w    #$00ff,d3
  2760.     move.w    y_coordinate,d5
  2761.     move.w    d5,y_coordinate_old
  2762.     add.w    d3,d5
  2763.     cmp.w    #199,d5
  2764.     ble.s    .put_coordinate
  2765.     move.w    #199,d5
  2766. .put_coordinate
  2767.     move.w    d5,y_coordinate
  2768.  
  2769.     bra.s    update_sprite_struct        
  2770.     
  2771. m_p_y_up
  2772.     and.w    #$00ff,d3
  2773.     move.w    y_coordinate,d5
  2774.     move.w    d5,y_coordinate_old
  2775.     neg.b    d3
  2776.     sub.w    d3,d5
  2777.     tst.w    d5
  2778.     bge.s    .put_coordinate
  2779.     moveq    #0,d5
  2780. .put_coordinate
  2781.     move.w    d5,y_coordinate
  2782.  
  2783.  
  2784. update_sprite_struct
  2785.     ;highbits of vstart and vstop are always 0 (range y = e[0-200])
  2786.     
  2787.     move.w    #$0080,d0
  2788.     add.w    x_coordinate,d0
  2789.     move.w    d0,d1
  2790.     and.w    #1,d1
  2791.     lsr.w    #1,d0
  2792.     move.w    #$0029,d2
  2793.     add.w    y_coordinate,d2
  2794.     lsl.w    #8,d2
  2795.     add.w    d0,d2        ;d2=sprxpos (sprite control word 1)
  2796.  
  2797.     move.w    d2,d0
  2798.     and.w    #$ff00,d0
  2799.     add.w    d0,d1
  2800.     add.w    #$0600,d1    ;calc vstop
  2801.     and.w    #$ff01,d1    ;clear unused bits
  2802.  
  2803.     move.w    d1,pointer_stop
  2804.     move.w    d2,pointer_xy    
  2805.     rts
  2806.  
  2807.  
  2808.  
  2809. ;the following routine is called when a mousebutton is pressed.
  2810. ;this routine compares the current mousepointer coordinates with all the
  2811. ;known buttons. if there is a button that is pressed, the ID of the button
  2812. ;is returned (in d0) and the address of the structure in a0
  2813. ;when there is no button pressed, thus an unkown area, 0 is returned in d0
  2814. ;a0 is then not valid.
  2815. ;after this routine a jumptable is used to blit the buttons.
  2816.  
  2817. check_which_button
  2818.     lea    button_structures,a0
  2819.     move.w    x_coordinate,d1
  2820.     move.w    y_coordinate,d2
  2821.  
  2822.     add.w    d1,d1
  2823.  
  2824.     moveq    #11-1,d7
  2825. c_w_b_l
  2826.     move.w    (a0),d0
  2827.     move.w    2(a0),d3
  2828.     move.w    4(a0),d4
  2829.     cmp.w    d3,d1
  2830.     blt.s    .skip
  2831.     cmp.w    d4,d1
  2832.     bge.s    .skip
  2833.     move.w    6(a0),d3
  2834.     move.w    8(a0),d4
  2835.     cmp.w    d3,d2
  2836.     blt.s    .skip
  2837.     cmp.w    d4,d2
  2838.     bge.s    .skip
  2839.     bra.s    c_w_b_found
  2840. .skip
  2841.     lea    18(a0),a0
  2842.     dbf    d7,c_w_b_l    
  2843.  
  2844.     ;not found => 0 in d0
  2845.     moveq    #0,d0
  2846. c_w_b_found
  2847.     rts    
  2848.  
  2849.  
  2850. ;a0 is pointing to text_structure
  2851. allocate_text_bitmap_space
  2852.     moveq    #0,d0
  2853.     move.w    8(a0),d0
  2854.     move.l    a0,-(sp)
  2855.     mulu    #80*8,d0    ;#lines * 80 * 9 is # of bytes
  2856.     move.l    $4.w,a6
  2857.     move.l    #MEMF_CHIP,d1        ;chipmem
  2858.     jsr    -198(a6)    ;allocate memory
  2859.     move.l    (sp)+,a0
  2860.     move.l    d0,4(a0)
  2861.     rts
  2862.  
  2863.  
  2864. ;a0 is pointing to text_structure
  2865. free_memory
  2866.     move.l    4(a0),d0
  2867.     cmp.l    #dummy_bitplane,d0
  2868.     beq.s    .end
  2869.     moveq    #0,d0
  2870.     move.w    8(a0),d0
  2871.     mulu    #8*80,d0
  2872.     move.l    $4.w,a6
  2873.     move.l    4(a0),a1
  2874.     jsr    -210(a6)
  2875. .end
  2876.     rts
  2877.  
  2878.  
  2879. ;a0 is pointer to textstruct
  2880. clear_bitplane
  2881.     lea    $dff000,a6
  2882.     move.l    4(a0),d6
  2883.  
  2884.     moveq    #0,d0
  2885.     move.w    8(a0),d0
  2886.     lsl.l    #3,d0        ;mulu 8 is no of lines to clear
  2887.  
  2888.     ;check if we can clear it all in 1 blit
  2889.  
  2890.     divu     #1024,d0    ;to get the number of times to do a 1024
  2891.                 ;line blit (huge!!!:)
  2892.  
  2893.     tst.w    d0
  2894.     beq.s    c_b_not_max_blit        
  2895. c_b_max_blit
  2896.     moveq    #0,d7
  2897.     move.w    d0,d7
  2898.     subq    #1,d7
  2899. c_b_m_b_l    
  2900.     move.w    #40,d0
  2901. .wait_blitter
  2902.     btst    #14,$2(a6)
  2903.     btst    #14,$2(a6)
  2904.     bne.s    .wait_blitter
  2905.  
  2906.     move.l    d6,$54(a6)
  2907.     move.l    #$01000000,$40(a6)
  2908.     move.w    #$0000,$66(a6)
  2909.     move.l    #-1,$44(a6)
  2910.     move.w    d0,$58(a6)
  2911.     add.l    #1024*80,d6
  2912.  
  2913.     dbf    d7,c_b_m_b_l
  2914.     
  2915. c_b_not_max_blit
  2916.     swap    d0
  2917.     lsl.w    #6,d0
  2918.     add.w    #40,d0
  2919. .wait_blitter
  2920.     btst    #14,$2(a6)
  2921.     btst    #14,$2(a6)
  2922.     bne.s    .wait_blitter
  2923.  
  2924.     move.l    d6,$54(a6)
  2925.     move.l    #$01000000,$40(a6)
  2926.     move.w    #$0000,$66(a6)
  2927.     move.l    #$ffffffff,$44(a6)
  2928.     move.w    d0,$58(a6)
  2929.     rts
  2930.  
  2931.  
  2932. ;a0 is pointer to text structure
  2933. insert_empty_space
  2934.     lea    no_mem_text_struct,a3    ;insert text 'not enuff chipmemory'
  2935.     move.l    (a3),(a0)
  2936.     move.l    4(a3),4(a0)
  2937.     move.w    8(a3),8(a0)
  2938.     move.w    10(a3),10(a0)
  2939.     rts
  2940.  
  2941.  
  2942. ;a0=pointer to text_structure
  2943. blit_text
  2944.     move.l    (a0),a4
  2945.     move.l    a4,a2
  2946.     move.l    4(a0),a1    ;get bitplane pointer
  2947.     add.l    #40,a1
  2948.     move.l    a1,a5
  2949.     moveq    #0,d3
  2950.     move.w    10(a0),d3
  2951.     add.l    d3,a2
  2952.     moveq    #0,d3        ;x counter
  2953.     move.b    #" ",d0
  2954.     move.l    a5,a1
  2955.     bsr    blit_char    ;blit a space to prevent nasty bars...
  2956. b_t_loop
  2957.     move.b    (a4)+,d0
  2958.     cmp.l    a2,a4
  2959.     bgt.s    b_t_end
  2960.     addq    #1,d3
  2961.     cmp.b    #10,d0
  2962.     bne.s    .no_cr
  2963.     moveq    #0,d3
  2964.     add.l    #8*80,a5
  2965.     move.l    #" ",d0
  2966.     move.l    a5,a1
  2967.     bsr    blit_char
  2968.     bra.s    b_t_loop
  2969. .no_cr
  2970.     cmp.b    #36,d3
  2971.     ble.s    .not_end_of_line
  2972.     add.l    #8*80,a5
  2973.     moveq    #0,d3
  2974.     move.b    d0,d4
  2975.     move.l    #" ",d0
  2976.     move.l    a5,a1
  2977.     bsr    blit_char    ;blit a space to prevent nasty bars ;-)
  2978.     move.b    d4,d0
  2979.     addq    #1,d3
  2980.     move.l    a5,a1
  2981.     add.l    d3,a1
  2982.     bsr    blit_char
  2983.     bra.s    b_t_loop
  2984. .not_end_of_line
  2985.     move.l    a5,a1
  2986.     add.l    d3,a1
  2987.     bsr    blit_char
  2988.     bra.s    b_t_loop
  2989. b_t_end
  2990.     rts
  2991.  
  2992.  
  2993. ;a0 is pointing to the text_structure that has to be examined
  2994. get_number_of_lines
  2995.     move.l    (a0),a1
  2996.     move.l    a1,a2
  2997.     moveq    #0,d0
  2998.     move.w    10(a0),d0
  2999.     add.l    d0,a2
  3000.     moveq    #0,d0        ;x counter
  3001.     moveq    #0,d1        ;line counter
  3002. g_n_o_l_loop
  3003.     move.b    (a1)+,d7
  3004.     cmp.l    a2,a1
  3005.     bgt.s    g_n_o_l_end
  3006.     addq    #1,d0
  3007.     cmp.b    #10,d7
  3008.     bne.s    .no_cr
  3009.     addq    #1,d1
  3010.     moveq    #0,d0
  3011.     bra.s    g_n_o_l_loop
  3012.  
  3013. .no_cr
  3014.     cmp.b    #36,d0
  3015.     ble.s    .not_end_of_line
  3016.     moveq    #0,d0
  3017.     addq    #1,d1
  3018. .not_end_of_line
  3019.     bra.s    g_n_o_l_loop
  3020.  
  3021. g_n_o_l_end
  3022.     cmp.w    #10,d1
  3023.     bgt.s    .greater_10
  3024.     moveq    #10,d1
  3025. .greater_10    
  3026.     move.w    d1,8(a0)
  3027.     rts
  3028.  
  3029.  
  3030. ;a0 is pointer to text_structure
  3031. show_text_in_window
  3032.     move.w    #0,actual_line
  3033.     move.l    a0,actual_text
  3034.  
  3035.     move.l    4(a0),d0
  3036.     move.w    d0,bpl_4+6
  3037.     swap    d0
  3038.     move.w    d0,bpl_4+2
  3039.     move.l    12(a0),a1
  3040.     move.w    #0,8(a1)
  3041.     moveq    #24,d0
  3042.     move.w    d0,scrollbar+6
  3043.     add.w    4(a1),d0
  3044.     move.w    d0,scrollbar+8
  3045.     bsr    update_scrollbar_sprite
  3046.     
  3047.     move.l    (a1),d0
  3048.     lea    c_scrollbar,a0
  3049.     move.w    d0,6(a0)
  3050.     swap    d0
  3051.     move.w    d0,2(a0)
  3052.     rts
  3053.  
  3054.  
  3055. ;used by routine that handles the arrow down event
  3056. move_text_up
  3057.     move.l    actual_text,a0
  3058.     moveq    #0,d0
  3059.     move.w    actual_line,d0
  3060.     move.w    8(a0),d1
  3061.     move.w    d0,d2
  3062.     add.w    #10,d2
  3063.     cmp.w    d1,d2
  3064.     bge.s    .end        ;no more lines to show
  3065.  
  3066.     addq.w    #1,d0
  3067.     move.w    d0,actual_line
  3068.     mulu    #80*8,d0
  3069.     move.l    4(a0),d1
  3070.     add.l    d0,d1
  3071.     move.l    d1,d0
  3072.     move.w    d0,bpl_4+6
  3073.     swap    d0
  3074.     move.w    d0,bpl_4+2
  3075.  
  3076.     move.l    12(a0),a1
  3077.     move.w    6(a1),d6    ;update_scrollteller
  3078.     add.w    d6,8(a1)
  3079.     
  3080.     move.w    8(a1),d6
  3081.     lsr.w    #8,d6        ;get scroll counter y
  3082.     add.w    #24,d6
  3083.     move.w    d6,scrollbar+6
  3084.     add.w    4(a1),d6
  3085.     move.w    d6,scrollbar+8
  3086.  
  3087.     bsr    update_scrollbar_sprite
  3088. .end
  3089.     rts
  3090.  
  3091.  
  3092.  
  3093.  
  3094. move_text_down
  3095.     move.l    actual_text,a0
  3096.     moveq    #0,d0
  3097.     move.w    actual_line,d0
  3098.     tst.w    d0
  3099.     beq.s    .end
  3100.  
  3101.     subq.w    #1,d0
  3102.     move.w    d0,actual_line
  3103.     move.l    4(a0),d1
  3104.     mulu    #8*80,d0
  3105.     add.l    d0,d1
  3106.     move.l    d1,d0
  3107.     move.w    d0,bpl_4+6
  3108.     swap    d0
  3109.     move.w    d0,bpl_4+2
  3110.     
  3111.     move.l    12(a0),a1
  3112.     move.w    6(a1),d6
  3113.     sub.w    d6,8(a1)
  3114.  
  3115.     move.w    8(a1),d6
  3116.     lsr.w    #8,d6        ;get scroll counter y
  3117.     add.w    #24,d6
  3118.     move.w    d6,scrollbar+6
  3119.     add.w    4(a1),d6
  3120.     move.w    d6,scrollbar+8
  3121.  
  3122.     bsr    update_scrollbar_sprite
  3123. .end    
  3124.     rts    
  3125.  
  3126.  
  3127. ;used by move_scrollbar
  3128. move_text_up_2
  3129.     move.l    actual_text,a0
  3130.     moveq    #0,d0
  3131.     move.w    actual_line,d0
  3132.     move.w    8(a0),d1
  3133.     move.w    d0,d2
  3134.     add.w    #10,d2
  3135.     cmp.w    d1,d2
  3136.     bge.s    .end        ;no more lines to show
  3137.  
  3138.     move.w    6(a1),d6    ;update_scrollteller
  3139.     add.w    d6,8(a1)
  3140.  
  3141.     addq.w    #1,d0
  3142.     move.w    d0,actual_line
  3143.     mulu    #80*8,d0
  3144.     move.l    4(a0),d1
  3145.     add.l    d0,d1
  3146.     move.l    d1,d0
  3147.     move.w    d0,bpl_4+6
  3148.     swap    d0
  3149.     move.w    d0,bpl_4+2
  3150. .end
  3151.     rts
  3152.  
  3153.  
  3154. ;used by move_scrollbar
  3155. move_text_down_2
  3156.     move.l    actual_text,a0
  3157.     moveq    #0,d0
  3158.     move.w    actual_line,d0
  3159.     tst.w    d0
  3160.     beq.s    .end
  3161.  
  3162.     move.w    6(a1),d6
  3163.     sub.w    d6,8(a1)
  3164.  
  3165.     subq.w    #1,d0
  3166.     move.w    d0,actual_line
  3167.     move.l    4(a0),d1
  3168.     mulu    #8*80,d0
  3169.     add.l    d0,d1
  3170.     move.l    d1,d0
  3171.     move.w    d0,bpl_4+6
  3172.     swap    d0
  3173.     move.w    d0,bpl_4+2
  3174. .end    
  3175.     rts    
  3176.  
  3177.  
  3178. ;a1 is pointing to sprite_struct (NOT sprite DATA!!!!!)
  3179. update_scrollbar_sprite
  3180.     move.w    scrollbar+6,d0
  3181.     move.w    scrollbar+8,d1
  3182.     move.l    (a1),a2
  3183.     move.w    (a2),d2
  3184.     and.w    #$00ff,d2
  3185.     add.w    #$29,d0
  3186.     lsl.w    #8,d0
  3187.     add.w    d0,d2
  3188.     move.w    d2,(a2)
  3189.     move.w    2(a2),d2
  3190.     add.w    #$29,d1
  3191.     and.w    #$00ff,d2
  3192.     lsl.w    #8,d1
  3193.     add.w    d1,d2
  3194.     move.w    d2,2(a2)
  3195.     rts
  3196.  
  3197.  
  3198.  
  3199. ;a0 is pointer to text_structure
  3200. calc_scrollbar_info
  3201.     moveq    #0,d0
  3202.     move.w    8(a0),d0
  3203.     cmp    #10,d0
  3204.     bgt.s    .greater_10
  3205.     moveq    #10,d0
  3206. .greater_10    
  3207.     move.l    12(a0),a1
  3208.     move.l    #600,d1
  3209.     divu    d0,d1        ;(60*10)/#lines in text = size of bar
  3210.     tst.w    d1
  3211.     bne.s    .not_null
  3212.     move.w    #3,d1        ;minimal 3 lines in scrollbar
  3213. .not_null    
  3214.     move.w    d1,4(a1)    ;store length in lines
  3215.     move.l    #60,d2
  3216.     sub.w    d1,d2
  3217.     sub.w    #10,d0
  3218.     lsl.w    #8,d2
  3219.     tst.w    d0
  3220.     beq.s    .stay
  3221.     divu    d0,d2        ;(60-size)/(#lines - 10) * 2^8 = scrolloffset
  3222. .stay
  3223.     move.w    d2,6(a1)
  3224.     move.w    #0,8(a1)
  3225.     rts
  3226.  
  3227.  
  3228. ;a0=pointer to text_structure
  3229. generate_scrollbar_sprite
  3230.     move.l    12(a0),a1
  3231.     move.l    (a1),a2
  3232.     addq.l    #4,a2
  3233.     moveq    #0,d7
  3234.     move.w    4(a1),d7
  3235.     subq    #3,d7
  3236.     move.w    #$f000,(a2)+
  3237.     move.w    #$1000,(a2)+
  3238. .loop
  3239.     move.w    #$9000,(a2)+
  3240.     move.w    #$7000,(a2)+
  3241.     dbf    d7,.loop
  3242.     move.w    #$8000,(a2)+
  3243.     move.w    #$7000,(a2)+
  3244.     
  3245.     move.l    (a1),a2
  3246.     move.w    #[$2900+$18dc],(a2)+
  3247.     move.w    #[$2900+$1801],d4
  3248.     move.w    4(a1),d0
  3249.     lsl.w    #8,d0
  3250.     add.w    d0,d4
  3251.     move.w    d4,(a2)
  3252.     rts
  3253.  
  3254.  
  3255. move_scrollbar
  3256.     move.l    actual_text,a0
  3257.     move.l    12(a0),a1
  3258.     tst.w    6(a1)            ;check if scrollbar CAN be moved
  3259.     beq.w    m_s_end
  3260.     move.w    y_coordinate,d0
  3261.     move.w    y_coordinate_old,d1
  3262.     cmp.w    d1,d0
  3263.     beq.w    m_s_end
  3264.     blt.s    m_s_up
  3265.  
  3266. m_s_down
  3267.     sub.w    d1,d0        ;get amount of scrolled screenlines
  3268.     move.w    scrollbar+6,d2    
  3269.     move.w    scrollbar+8,d3    ;get y coordinate of underside of bar
  3270.     add.w    d0,d3
  3271.     cmp.w    #83,d3    
  3272.     ble.s    m_s_not_end
  3273.     move.w    #84,d3
  3274.     move.w    d3,d2
  3275.     sub.w    4(a1),d2
  3276.     bra.s    m_s_v1
  3277. m_s_not_end
  3278.     add.w    d0,d2
  3279. m_s_v1
  3280.     move.w    d2,scrollbar+6
  3281.     move.w    d3,scrollbar+8
  3282.     move.w    #24,d0
  3283.     add.w    4(a1),d0
  3284.     sub.w    d0,d3
  3285.  
  3286.     move.w    8(a1),d4
  3287.     lsr.w    #8,d4
  3288.     cmp.w    d3,d4
  3289.     bgt.s    m_s_no_scroll
  3290.     ;scroll text x lines up
  3291.     sub.w    d4,d3
  3292.     move.w    6(a1),d5
  3293.     lsl.w    #8,d3
  3294. .loop
  3295.     bsr    move_text_up_2
  3296.     sub.w    d5,d3
  3297.     cmp.w    d5,d3
  3298.     bge.s    .loop
  3299.     bra.s    m_s_no_scroll
  3300.  
  3301. m_s_up
  3302.     sub.w    d0,d1        ;get amount of scrolled screenlines
  3303.     move.w    scrollbar+6,d2    
  3304.     move.w    scrollbar+8,d3    ;get y coordinate of underside of bar
  3305.     sub.w    d1,d2
  3306.     cmp.w    #25,d2    
  3307.     bge.s    m_s_not_start
  3308.     move.w    #24,d2
  3309.     move.w    d2,d3
  3310.     add.w    4(a1),d3
  3311.     bra.s    m_s_v2
  3312. m_s_not_start
  3313.     sub.w    d1,d3
  3314. m_s_v2
  3315.     move.w    d2,scrollbar+6
  3316.     move.w    d3,scrollbar+8
  3317.     move.w    #24,d0
  3318.     add.w    4(a1),d0
  3319.     sub.w    d0,d3
  3320.  
  3321.     move.w    8(a1),d4
  3322.     lsr.w    #8,d4
  3323.     cmp.w    d3,d4
  3324.     blt.s    m_s_no_scroll
  3325.     ;scroll text x lines down
  3326.     sub.w    d3,d4
  3327.     move.w    6(a1),d5
  3328.     lsl.w    #8,d4
  3329. .loop
  3330.     bsr    move_text_down_2
  3331.     sub.w    d5,d4
  3332.     cmp.w    d5,d4
  3333.     bge.s    .loop
  3334.  
  3335. m_s_no_scroll
  3336.     bsr    update_scrollbar_sprite
  3337. m_s_end
  3338.     rts
  3339.  
  3340.  
  3341. dummy_routine
  3342.     rts
  3343.  
  3344.  
  3345. kill_disk_motor
  3346.     ;we don't know which drive is on, so kill all.
  3347.     lea    $bfd100,a6
  3348.     moveq    #3,d0
  3349.     moveq    #4-1,d7
  3350. .loop    
  3351.     move.b    #$fd,(a6)
  3352.     nop
  3353.     bclr    d0,(a6)
  3354.     nop
  3355.     bset    d0,(a6)
  3356.     addq    #1,d0
  3357.     dbf    d7,.loop
  3358.     rts
  3359.  
  3360.  
  3361. ;************ tables *********************
  3362.  
  3363.     SECTION tables,BSS
  3364.  
  3365.  
  3366. char_tab    ds.b    128*2*4    ;1l: addy to char in font
  3367.                 ;2w: bltcon 0  if destination is 8 bit range
  3368.                 ;3w: bltcon 0  if destination is 16 bit range
  3369.  
  3370. track_pos_tab    ds.b    2*[2*[64+7+8]]
  3371.                 ;this table is used for putting fast
  3372.                 ;the track bitplane address in the copperlist
  3373.                 ;in contains 64 longwords whitch are the 
  3374.                 ;addresses of the 64 lines....
  3375.  
  3376.             
  3377. clean_block    ds.b    256
  3378.  
  3379.  
  3380.  
  3381.  
  3382. ;*************** variables ******************
  3383.  
  3384.     SECTION variables,data
  3385.  
  3386.                 ;table used for fast plotting the scopes.
  3387.                 ;in this table are the offsets for the
  3388.                 ;256 possible values of a samplebyte.
  3389.                 ;scopes are 32 lines high so every line is 
  3390.                 ;mentioned in the table 8 times...
  3391.                 ;(saves a divu operation (or shift))
  3392.  
  3393. plot_table
  3394. tempvar set 32*80
  3395.     rept 32
  3396.      blk.w 8,tempvar
  3397. tempvar set tempvar-80
  3398.     endr
  3399.  
  3400.     rept 32
  3401.      blk.w 8,tempvar
  3402. tempvar set tempvar+80
  3403.     endr
  3404.  
  3405.  
  3406. mt_data        dc.l    0
  3407. tune_length    dc.l    0        
  3408.  
  3409. argv        dc.l    0
  3410. argv_length    dc.l    0
  3411.  
  3412. stdout        dc.l    0
  3413.  
  3414. dos_base    dc.l    0
  3415. pp_base        dc.l    0
  3416. gfx_base    dc.l    0
  3417.  
  3418. vbl_save    dc.l    0    
  3419. pattern_pos    dc.l    0
  3420. note_dest    dc.l    0
  3421. scope_screen    dc.l    0    
  3422.  
  3423. vbr        dc.l    0
  3424.  
  3425. old_view    dc.l    0
  3426.  
  3427. pattern_slot_teller    dc.w    0    ;offset in track_pos_tab
  3428.  
  3429. blit_note_slot_teller    dc.w    0
  3430.  
  3431. dmacon_save    dc.w    0
  3432. intena_save    dc.w    0    
  3433.  
  3434. clear_block    blk.w    20*8,$ffff
  3435.  
  3436. scopes_clear_buffer    dc.l    second_buf_scopes
  3437. scopes_build_buffer    dc.l    third_buf_scopes
  3438. scopes_show_buffer    dc.l    screen_picture+[[24+120]*80]
  3439.  
  3440. sample_chan1_pointer    dc.l    clean_block
  3441. chan1_start    dc.l    0
  3442. chan1_length    dc.w    0
  3443. chan1_loopstart    dc.l    0
  3444. chan1_replen    dc.w    0
  3445. chan1_period    dc.w    0
  3446. chan1_volume    dc.b    0        
  3447.  
  3448.     EVEN    
  3449.  
  3450. sample_chan2_pointer    dc.l    clean_block
  3451. chan2_start    dc.l    0
  3452. chan2_length    dc.w    0
  3453. chan2_loopstart    dc.l    0
  3454. chan2_replen    dc.w    0
  3455. chan2_period    dc.w    0
  3456. chan2_volume    dc.b    0        
  3457.  
  3458.     EVEN
  3459.  
  3460. sample_chan3_pointer    dc.l    clean_block
  3461. chan3_start    dc.l    0
  3462. chan3_length    dc.w    0
  3463. chan3_loopstart    dc.l    0
  3464. chan3_replen    dc.w    0
  3465. chan3_period    dc.w    0
  3466. chan3_volume    dc.b    0        
  3467.  
  3468.     EVEN
  3469.  
  3470. sample_chan4_pointer    dc.l    clean_block
  3471. chan4_start    dc.l    0
  3472. chan4_length    dc.w    0
  3473. chan4_loopstart    dc.l    0
  3474. chan4_replen    dc.w    0
  3475. chan4_period    dc.w    0
  3476. chan4_volume    dc.b    0    
  3477.  
  3478.     EVEN
  3479.     
  3480. graph_name    dc.b    'graphics.library',0
  3481.  
  3482.     EVEN
  3483. pp_name        dc.b    'powerpacker.library',0
  3484.  
  3485.     EVEN
  3486. dos_name    dc.b    'dos.library',0
  3487.  
  3488.     EVEN
  3489.  
  3490. pattern_pointer    dc.b    0
  3491.  
  3492. scrollbar_moved    dc.b    0
  3493.  
  3494. new_pattern    dc.b    1
  3495. new_bpm        dc.b    1
  3496. new_vbl_tempo    dc.b    1
  3497.  
  3498. hours        dc.b    0
  3499. minutes        dc.b    0
  3500. seconds        dc.b    0
  3501. frame_counter    dc.b    0
  3502. new_time    dc.b    1
  3503.  
  3504. last_pulses_x    dc.b    0
  3505. last_pulses_y    dc.b    0
  3506.  
  3507. pal_ntsc    dc.b    0    ;0 = pal ; 1 = Never The Same Color
  3508.  
  3509. quit_program    dc.b    0
  3510.  
  3511.     EVEN
  3512.  
  3513. x_coordinate        dc.w    0
  3514. x_coordinate_old    dc.w    0
  3515. y_coordinate        dc.w    0    
  3516. y_coordinate_old    dc.w    0
  3517.  
  3518.     EVEN
  3519.  
  3520. button_id        dc.w    0
  3521. button_struct_address    dc.l    0
  3522.  
  3523. mouse_button_status    dc.b    1    ;1 is no button pressed
  3524.  
  3525.     EVEN
  3526.  
  3527. sample_info_shown    
  3528.             dc.b    0    ;number of sample that is current
  3529.                     ;shown in the sampleinfo area
  3530.     EVEN
  3531.     
  3532. actual_line        dc.w    0    ;top line of text in textwindow
  3533. actual_text        dc.l    0    ;pointer to text_structure of text
  3534.                     ;that's in the textwindow
  3535.     EVEN
  3536.  
  3537. ;button_structs:
  3538. ;button id (word)
  3539. ;minimal x, maximal x    (words)
  3540. ;minimal y, maximal y    (words)
  3541. ;pointer to unselected image    (long)
  3542. ;pointer to selected image (long)
  3543.  
  3544. button_structures
  3545. about_button_struct
  3546.     dc.w    1            ;id = 1            offset 0
  3547.     dc.w    320,384            ;min x, max x        offset 2
  3548.     dc.w    188,200            ;min y, max y        offset 6
  3549.     dc.l    buttons_1_normal+40*12    ;pointer to unselect image offset 10
  3550.     dc.l    buttons_1_pressed+40*12    ;pointer to select image  offset 14
  3551.  
  3552. mod_text_button_struct
  3553.     dc.w    2            ;id = 2
  3554.     dc.w    384,448
  3555.     dc.w    188,200
  3556.     dc.l    buttons_1_normal+8+40*12
  3557.     dc.l    buttons_1_pressed+8+40*12
  3558.  
  3559. restart_button_struct
  3560.     dc.w    3            ;id = 3
  3561.     dc.w    448,512
  3562.     dc.w    188,200
  3563.     dc.l    buttons_1_normal+16+40*12
  3564.     dc.l    buttons_1_pressed+16+40*12
  3565.  
  3566. quit_button
  3567.     dc.w    4            ;id = 4
  3568.     dc.w    512,576
  3569.     dc.w    188,200
  3570.     dc.l    buttons_1_normal+24+40*12
  3571.     dc.l    buttons_1_pressed+24+40*12
  3572.  
  3573. uga_button
  3574.     dc.w    5            ;id = 5
  3575.     dc.w    576,640
  3576.     dc.w    188,200
  3577.     dc.l    buttons_1_normal+32+40*12
  3578.     dc.l    buttons_1_pressed+32+40*12
  3579.  
  3580. sample_arrow_up
  3581.     dc.w    6    ;id = 6
  3582.     dc.w    592,605
  3583.     dc.w    162,172
  3584.     dc.l    arrow_up_normal+2*10
  3585.     dc.l    arrow_up_pressed+2*10
  3586.     
  3587. sample_arrow_down
  3588.     dc.w    7    ;id = 7
  3589.     dc.w    592,605
  3590.     dc.w    172,182
  3591.     dc.l    arrow_down_normal+2*10
  3592.     dc.l    arrow_down_pressed+2*10
  3593.  
  3594. scrollbar_arrow_up
  3595.     dc.w    8    ;id = 8
  3596.     dc.w    624,637
  3597.     dc.w    85,95
  3598.     dc.l    arrow_up_normal+2*10
  3599.     dc.l    arrow_up_pressed+2*10
  3600.  
  3601. scrollbar_arrow_down
  3602.     dc.w    9    ;id = 9
  3603.     dc.w    624,637
  3604.     dc.w    95,105
  3605.     dc.l    arrow_down_normal+2*10
  3606.     dc.l    arrow_down_pressed+2*10
  3607.  
  3608. scrollbar
  3609.     dc.w    10    ;id = 10
  3610.     dc.w    626,635
  3611.     dc.w    0,0    ;y coordinates are dynamic.
  3612.     dc.l    0
  3613.     dc.l    0
  3614.  
  3615. close_button
  3616.     dc.w    11
  3617.     dc.w    0,16
  3618.     dc.w    0,10
  3619.     dc.l    close_button_normal+2*10
  3620.     dc.l    close_button_pressed+2*10
  3621.  
  3622.  
  3623. colors
  3624.     dc.w    $0000,$0fff,$0abd,$0ed0
  3625.     dc.w    $078a,$0fff,$0568,$0f52
  3626.     dc.w    $0fff,$0000,$0ed0,$0000
  3627.     dc.w    $0,0,$0eef,0
  3628.  
  3629.  
  3630. notetab
  3631.     ;use the offset in the finetunetab, and get the string from this
  3632.     ;table to put it in the display.
  3633.     
  3634.     dc.b    "C-1",0
  3635.     dc.b    "C#1",0
  3636.     dc.b    "D-1",0
  3637.     dc.b    "D#1",0
  3638.     dc.b    "E-1",0
  3639.     dc.b    "F-1",0
  3640.     dc.b    "F#1",0
  3641.     dc.b    "G-1",0
  3642.     dc.b    "G#1",0
  3643.     dc.b    "A-1",0
  3644.     dc.b    "A#1",0
  3645.     dc.b    "B-1",0
  3646.  
  3647.     dc.b    "C-2",0
  3648.     dc.b    "C#2",0
  3649.     dc.b    "D-2",0
  3650.     dc.b    "D#2",0
  3651.     dc.b    "E-2",0
  3652.     dc.b    "F-2",0
  3653.     dc.b    "F#2",0
  3654.     dc.b    "G-2",0
  3655.     dc.b    "G#2",0
  3656.     dc.b    "A-2",0
  3657.     dc.b    "A#2",0
  3658.     dc.b    "B-2",0
  3659.  
  3660.     dc.b    "C-3",0
  3661.     dc.b    "C#3",0
  3662.     dc.b    "D-3",0
  3663.     dc.b    "D#3",0
  3664.     dc.b    "E-3",0
  3665.     dc.b    "F-3",0
  3666.     dc.b    "F#3",0
  3667.     dc.b    "G-3",0
  3668.     dc.b    "G#3",0
  3669.     dc.b    "A-3",0
  3670.     dc.b    "A#3",0
  3671.     dc.b    "B-3",0
  3672.  
  3673.     dc.b    "---",0
  3674.  
  3675.     EVEN
  3676.  
  3677. button_blit_jump_table
  3678.     dc.l    0            ;dummy long. coz aboutbutton has id 1.
  3679.     dc.l    blit_about_button
  3680.     dc.l    blit_mod_text_button
  3681.     dc.l    blit_restart_button
  3682.     dc.l    blit_quit_button
  3683.     dc.l    blit_uga_button
  3684.     dc.l    blit_sample_arrow_up
  3685.     dc.l    blit_sample_arrow_down
  3686.     dc.l    blit_scrollbar_arrow_up
  3687.     dc.l    blit_scrollbar_arrow_down
  3688.     dc.l    dummy_routine        ;dummy long (scrollbar)
  3689.     dc.l    blit_close_button
  3690.  
  3691. button_action_jump_table
  3692.     dc.l    0    ;dummy
  3693.     dc.l    show_about
  3694.     dc.l    show_mod_text
  3695.     dc.l    do_restart
  3696.     dc.l    do_quit
  3697.     dc.l    show_uga
  3698.     dc.l    do_sample_up
  3699.     dc.l    do_sample_down
  3700.     dc.l    do_textwindow_down
  3701.     dc.l    do_textwindow_up
  3702.     dc.l    dummy_routine
  3703.     dc.l    do_quit
  3704.  
  3705.     
  3706.     section    texts,DATA
  3707.  
  3708. ;if the first longword of each structure is 0, there is no text of this
  3709. ;subject availabe
  3710. ;about text and UGA (or IC) text are ELWAYS available.
  3711.  
  3712. about_text_struct
  3713.     dc.l    about_text    ;about_text
  3714.     dc.l    0        ;about_text_bitplane
  3715.     dc.w    0        ;a_t_no_of_lines
  3716.     dc.w    898        ;a_b_text_length    (bytes)
  3717.     dc.l    about_scrollbar_struct    ;pointer to scrollbar_struct    
  3718.  
  3719. mod_text_struct
  3720.     dc.l    0        ;mod_text
  3721.     dc.l    0        ;mod_text_bitplane
  3722.     dc.w    0        ;m_t_no_of_lines
  3723.     dc.w    0        ;m_t_text_length    (bytes)
  3724.     dc.l    mod_text_scrollbar_struct ;pointer to scrollbar_struct    
  3725.  
  3726. uga_text_struct
  3727.     dc.l    uga_text    ;text
  3728.     dc.l    0        ;3rd text bitplane
  3729.     dc.w    0        ;t_t_no_of_lines
  3730.     dc.w    294        ;t_t_text_length    (bytes)
  3731.     dc.l    uga_text_scrollbar_struct ;pointer to scrollbar_struct
  3732.  
  3733. no_mem_text_struct
  3734.     dc.l    no_mem_text
  3735.     dc.l    dummy_bitplane
  3736.     dc.w    1
  3737.     dc.w    36
  3738.     dc.l    0
  3739.  
  3740. about_scrollbar_struct
  3741.     dc.l    scrollbar_about    ;pointer to scrollbar sprite
  3742.     dc.w    0        ;length (in screenlines)
  3743.     dc.w    0        ;no of pixels : no of lines
  3744.     dc.w    0        ;scroll counter (in screenlines)
  3745.  
  3746. mod_text_scrollbar_struct
  3747.     dc.l    scrollbar_mod_text    ;pointer to scrollbar sprite
  3748.     dc.w    0        ;length (in screenlines)
  3749.     dc.w    0        ;no of pixels : no of lines
  3750.     dc.w    0        ;scroll counter (in screenlines)
  3751.  
  3752. uga_text_scrollbar_struct
  3753.     dc.l    scrollbar_uga_text    ;pointer to scrollbar sprite
  3754.     dc.w    0        ;length (in screenlines)
  3755.     dc.w    0        ;no of pixels : no of lines
  3756.     dc.w    0        ;scroll counter (in screenlines)
  3757.  
  3758. mod_text        dc.l    0
  3759. mod_text_length        dc.l    0
  3760.  
  3761. about_text
  3762.     incbin    "about_text"
  3763.  
  3764. uga_text
  3765.     incbin    "uga_text"
  3766.  
  3767. no_mem_text
  3768.     dc.b    "  Not enuff CHIP mem available :(   "
  3769.  
  3770. no_mod_text_text    dc.b    '      no mod text specified!!!      ',0
  3771.  
  3772.     EVEN
  3773.     
  3774. no_mod_text_text_length        dc.w    36
  3775.  
  3776. return        dc.b    $0a
  3777.  
  3778. usage_text    dc.b 'Usage: ptplay module[.pp] [text[.pp]]',10,0
  3779.  
  3780. opening_text    
  3781.     dc.b 'PtPlay - protracker module player. (c)1993 Otis/InfoCorner',10,0
  3782.  
  3783. pp_needed
  3784.     dc.b 'Needs powerpacker.library!!!!!',10,0
  3785.  
  3786. filename1    blk.b    200,0
  3787.  
  3788. filename2    blk.b    200,0
  3789.  
  3790.     EVEN
  3791.  
  3792.     Section    replayer,CODE
  3793.  
  3794. ;**************************************************
  3795. ;*    ----- Protracker V2.3A Playroutine -----    *
  3796. ;**************************************************
  3797.  
  3798.  
  3799. ; Call SetCIAInt to install the interrupt server. Then call mt_init
  3800. ; to initialize the song. Playback starts when the mt_enable flag
  3801. ; is set to a nonzero value. To end the song and turn off all voices,
  3802. ; call mt_end. At last, call ResetCIAInt to remove the interrupt.
  3803.  
  3804.  
  3805. SetCIAInt
  3806.     MOVEQ    #2,D6
  3807.     LEA    $BFD000,A5
  3808.     MOVE.B    #'b',CIAAname+3
  3809. SetCIALoop
  3810.     MOVEQ    #0,D0
  3811.     LEA    CIAAname(PC),A1
  3812.     MOVE.L    4.W,A6
  3813.     JSR    LVOOpenResource(A6)
  3814.     MOVE.L    D0,CIAAbase
  3815.     BEQ.W    mt_Return
  3816.  
  3817.     LEA    GfxName(PC),A1
  3818.     MOVEQ    #0,D0
  3819.     JSR    LVOOpenLibrary(A6)
  3820.     TST.L    D0
  3821.     BEQ.W    ResetCIAInt
  3822.     MOVE.L    D0,A1
  3823.     MOVE.W    206(A1),D0    ; DisplayFlags
  3824.     BTST    #2,D0        ; PAL?
  3825.     BEQ.S    WasNTSC
  3826.     move.b    #0,pal_ntsc
  3827.     MOVE.L    #1773447,D7 ; PAL
  3828.     BRA.S    sciask
  3829. WasNTSC    MOVE.L    #1789773,D7 ; NTSC
  3830.     move.b    #1,pal_ntsc
  3831. sciask    MOVE.L    D7,TimerValue
  3832.     DIVU    #125,D7 ; Default to normal 50 Hz timer
  3833.     JSR    LVOCloseLibrary(A6)
  3834.  
  3835.     MOVE.L    CIAAbase(PC),A6
  3836.     CMP.W    #2,D6
  3837.     BEQ.S    TryTimerA
  3838. TryTimerB
  3839.     LEA    MusicIntServer(PC),A1
  3840.     MOVEQ    #1,D0    ; Bit 1: Timer B
  3841.     JSR    AddICRVector(A6)
  3842.     MOVE.L    #1,TimerFlag
  3843.     TST.L    D0
  3844.     BNE.S    CIAError
  3845.     MOVE.L    A5,CIAAaddr
  3846.     MOVE.B    D7,ciatblo(A5)
  3847.     LSR.W    #8,D7
  3848.     MOVE.B    D7,ciatbhi(A5)
  3849.     BSET    #0,ciacrb(A5)
  3850.     RTS
  3851.  
  3852. TryTimerA
  3853.     LEA    MusicIntServer(PC),A1
  3854.     MOVEQ    #0,D0    ; Bit 0: Timer A
  3855.     JSR    AddICRVector(A6)
  3856.     CLR.L    TimerFlag
  3857.     TST.L    D0
  3858.     BNE.S    CIAError
  3859.     MOVE.L    A5,CIAAaddr
  3860.     MOVE.B    D7,ciatalo(A5)
  3861.     LSR.W    #8,D7
  3862.     MOVE.B    D7,ciatahi(A5)
  3863.     BSET    #0,ciacra(A5)
  3864.     RTS
  3865.  
  3866. CIAError
  3867.     MOVE.B    #'a',CIAAname+3
  3868.     LEA    $BFE001,A5
  3869.     SUBQ.W    #1,D6
  3870.     BNE.W    SetCIALoop
  3871.     CLR.L    CIAAbase
  3872.     RTS
  3873.  
  3874. ResetCIAInt
  3875.     MOVE.L    CIAAbase(PC),D0
  3876.     BEQ.W    mt_Return
  3877.     CLR.L    CIAAbase
  3878.     MOVE.L    D0,A6
  3879.     MOVE.L    CIAAaddr(PC),A5
  3880.     TST.L    TimerFlag
  3881.     BEQ.S    ResTimerA
  3882.  
  3883.     BCLR    #0,ciacrb(A5)
  3884.     MOVEQ    #1,D0
  3885.     BRA.S    RemInt
  3886.  
  3887. ResTimerA
  3888.     BCLR    #0,ciacra(A5)
  3889.     MOVEQ    #0,D0
  3890. RemInt    LEA    MusicIntServer(PC),A1
  3891.     MOVEQ    #0,d0
  3892.     JSR    RemICRVector(A6)
  3893.     RTS
  3894.  
  3895. ;---- Tempo ----
  3896.  
  3897. SetTempo
  3898.     MOVE.L    CIAAbase(PC),D2
  3899.     BEQ.W    mt_Return
  3900.     CMP.W    #32,D0
  3901.     BHS.S    setemsk
  3902.     MOVEQ    #32,D0
  3903. setemsk    MOVE.W    D0,RealTempo
  3904.     move.b    #1,new_bpm
  3905.     MOVE.L    TimerValue(PC),D2
  3906.     DIVU    D0,D2
  3907.     MOVE.L    CIAAaddr(PC),A4
  3908.     MOVE.L    TimerFlag(PC),D0
  3909.     BEQ.S    SetTemA
  3910.     MOVE.B    D2,ciatblo(A4)
  3911.     LSR.W    #8,D2
  3912.     MOVE.B    D2,ciatbhi(A4)
  3913.     RTS
  3914.  
  3915. SetTemA    MOVE.B    D2,ciatalo(A4)
  3916.     LSR.W    #8,D2
  3917.     MOVE.B    D2,ciatahi(A4)
  3918.     RTS
  3919.  
  3920. RealTempo    dc.w 125
  3921. CIAAaddr    dc.l 0
  3922. CIAAname    dc.b "ciaa.resource",0
  3923. CIAAbase    dc.l 0
  3924. TimerFlag    dc.l 0
  3925. TimerValue    dc.l 0
  3926. GfxName        dc.b "graphics.library",0,0
  3927.  
  3928. MusicIntServer
  3929.     dc.l 0,0
  3930.     dc.b 2,5 ; type, priority
  3931.     dc.l musintname
  3932.     dc.l 0,mt_music
  3933.  
  3934. musintname    dc.b "Protracker MusicInt",0
  3935.  
  3936. ;---- Playroutine ----
  3937.  
  3938. n_note        EQU    0  ; W
  3939. n_cmd        EQU    2  ; W
  3940. n_cmdlo        EQU    3  ; B
  3941. n_start        EQU    4  ; L
  3942. n_length    EQU    8  ; W
  3943. n_loopstart    EQU    10 ; L
  3944. n_replen    EQU    14 ; W
  3945. n_period    EQU    16 ; W
  3946. n_finetune    EQU    18 ; B
  3947. n_volume    EQU    19 ; B
  3948. n_dmabit    EQU    20 ; W
  3949. n_toneportdirec    EQU    22 ; B
  3950. n_toneportspeed    EQU    23 ; B
  3951. n_wantedperiod    EQU    24 ; W
  3952. n_vibratocmd    EQU    26 ; B
  3953. n_vibratopos    EQU    27 ; B
  3954. n_tremolocmd    EQU    28 ; B
  3955. n_tremolopos    EQU    29 ; B
  3956. n_wavecontrol    EQU    30 ; B
  3957. n_glissfunk    EQU    31 ; B
  3958. n_sampleoffset    EQU    32 ; B
  3959. n_pattpos    EQU    33 ; B
  3960. n_loopcount    EQU    34 ; B
  3961. n_funkoffset    EQU    35 ; B
  3962. n_wavestart    EQU    36 ; L
  3963. n_reallength    EQU    40 ; W
  3964.  
  3965. mt_init    move.l    mt_data,A0
  3966.     MOVE.L    A0,mt_SongDataPtr
  3967.     MOVE.L    A0,A1
  3968.     LEA    952(A1),A1
  3969.     MOVEQ    #127,D0
  3970.     MOVEQ    #0,D1
  3971. mtloop    MOVE.L    D1,D2
  3972.     SUBQ.W    #1,D0
  3973. mtloop2    MOVE.B    (A1)+,D1
  3974.     CMP.B    D2,D1
  3975.     BGT.S    mtloop
  3976.     DBRA    D0,mtloop2
  3977.     ADDQ.B    #1,D2
  3978.             
  3979.     LEA    mt_SampleStarts(PC),A1
  3980.     ASL.L    #8,D2
  3981.     ASL.L    #2,D2
  3982.     ADD.L    #1084,D2
  3983.     ADD.L    A0,D2
  3984.     MOVE.L    D2,A2
  3985.     MOVEQ    #30,D0
  3986. mtloop3    CLR.L    (A2)
  3987.     MOVE.L    A2,(A1)+
  3988.     MOVEQ    #0,D1
  3989.     MOVE.W    42(A0),D1
  3990.     ASL.L    #1,D1
  3991.     ADD.L    D1,A2
  3992.     ADD.L    #30,A0
  3993.     DBRA    D0,mtloop3
  3994.  
  3995.     OR.B    #2,$BFE001
  3996.     MOVE.B    #6,mt_speed
  3997.     CLR.B    mt_counter
  3998.     CLR.B    mt_SongPos
  3999.     CLR.W    mt_PatternPos
  4000. mt_end    SF    mt_Enable
  4001.     LEA    $DFF000,A0
  4002.     CLR.W    $A8(A0)
  4003.     CLR.W    $B8(A0)
  4004.     CLR.W    $C8(A0)
  4005.     CLR.W    $D8(A0)
  4006.     MOVE.W    #$F,$DFF096
  4007.     RTS
  4008.  
  4009. mt_music
  4010.     MOVEM.L    D0-D7/A0-A6,-(SP)
  4011.     TST.B    mt_Enable
  4012.     BEQ.W    mt_exit
  4013.     ADDQ.B    #1,mt_counter
  4014.     MOVE.B    mt_counter(PC),D0
  4015.     CMP.B    mt_speed(PC),D0
  4016.     BLO.S    mt_NoNewNote
  4017.     CLR.B    mt_counter
  4018.     TST.B    mt_PattDelTime2
  4019.     BEQ.S    mt_GetNewNote
  4020.     BSR.S    mt_NoNewAllChannels
  4021.     BRA.W    mt_dskip
  4022.  
  4023. mt_NoNewNote
  4024.     BSR.S    mt_NoNewAllChannels
  4025.     BRA.W    mt_NoNewPosYet
  4026.  
  4027. mt_NoNewAllChannels
  4028.     LEA    $DFF0A0,A5
  4029.     LEA    mt_chan1temp(PC),A6
  4030.     BSR.W    mt_CheckEfx
  4031.     LEA    $DFF0B0,A5
  4032.     LEA    mt_chan2temp(PC),A6
  4033.     BSR.W    mt_CheckEfx
  4034.     LEA    $DFF0C0,A5
  4035.     LEA    mt_chan3temp(PC),A6
  4036.     BSR.W    mt_CheckEfx
  4037.     LEA    $DFF0D0,A5
  4038.     LEA    mt_chan4temp(PC),A6
  4039.     BRA.W    mt_CheckEfx
  4040.  
  4041. mt_GetNewNote
  4042.     jsr    move_track_bitplane        ;moves the tracks on screen
  4043.                         ;1 slot up
  4044.                         
  4045.     MOVE.L    mt_SongDataPtr(PC),A0
  4046.     LEA    12(A0),A3
  4047.     LEA    952(A0),A2    ;pattpo
  4048.     LEA    1084(A0),A0    ;patterndata
  4049.     MOVEQ    #0,D0
  4050.     MOVEQ    #0,D1
  4051.     MOVE.B    mt_SongPos(PC),D0
  4052.     MOVE.B    (A2,D0.W),D1
  4053.     ASL.L    #8,D1
  4054.     ASL.L    #2,D1
  4055.     ADD.W    mt_PatternPos(PC),D1
  4056.     CLR.W    mt_DMACONtemp
  4057.  
  4058.     LEA    $DFF0A0,A5
  4059.     LEA    mt_chan1temp(PC),A6
  4060.     lea    sample_chan1_pointer,a4
  4061.     BSR.S    mt_PlayVoice
  4062.     LEA    $DFF0B0,A5
  4063.     LEA    mt_chan2temp(PC),A6
  4064.     lea    sample_chan2_pointer,a4
  4065.     BSR.S    mt_PlayVoice
  4066.     LEA    $DFF0C0,A5
  4067.     LEA    mt_chan3temp(PC),A6
  4068.     lea    sample_chan3_pointer,a4
  4069.     BSR.S    mt_PlayVoice
  4070.     LEA    $DFF0D0,A5
  4071.     LEA    mt_chan4temp(PC),A6
  4072.     lea    sample_chan4_pointer,a4
  4073.     BSR.S    mt_PlayVoice
  4074.     BRA.W    mt_SetDMA
  4075.  
  4076. mt_PlayVoice
  4077.     TST.L    (A6)
  4078.     BNE.S    mt_plvskip
  4079.     BSR.W    mt_PerNop
  4080. mt_plvskip
  4081.     MOVE.L    (A0,D1.L),(A6)
  4082.     ADDQ.L    #4,D1
  4083.     MOVEQ    #0,D2
  4084.     MOVE.B    n_cmd(A6),D2
  4085.     AND.B    #$F0,D2
  4086.     LSR.B    #4,D2
  4087.     MOVE.B    (A6),D0
  4088.     AND.B    #$F0,D0
  4089.     OR.B    D0,D2
  4090.     TST.B    D2
  4091.     beq.w    mt_SetRegs
  4092.  
  4093.     MOVEQ    #0,D3
  4094.     LEA    mt_SampleStarts(PC),A1
  4095.     MOVE    D2,D4
  4096.     SUBQ.L    #1,D2
  4097.     ASL.L    #2,D2
  4098.     MULU    #30,D4
  4099.     MOVE.L    (A1,D2.L),n_start(A6)
  4100.     
  4101.     MOVE.W    (A3,D4.L),n_length(A6)
  4102.     MOVE.W    (A3,D4.L),n_reallength(A6)
  4103.     MOVE.B    2(A3,D4.L),n_finetune(A6)
  4104.     MOVE.B    3(A3,D4.L),n_volume(A6)
  4105.     MOVE.W    4(A3,D4.L),D3 ;$Get repeat
  4106.     TST.W    D3
  4107.     BEQ.S    mt_NoLoop
  4108.     MOVE.L    n_start(A6),D2    ; Get start
  4109.     ASL.W    #1,D3
  4110.     ADD.L    D3,D2        ; Add repeat
  4111.     MOVE.L    D2,n_loopstart(A6)
  4112.     MOVE.L    D2,n_wavestart(A6)
  4113.     MOVE.W    4(A3,D4.L),D0    ; Get repeat
  4114.     ADD.W    6(A3,D4.L),D0    ; Add replen
  4115.     MOVE.W    D0,n_length(A6)
  4116.     MOVE.W    6(A3,D4.L),n_replen(A6)    ; Save replen    
  4117.     MOVEQ    #0,D0
  4118.     MOVE.B    n_volume(A6),D0
  4119.     MOVE.W    D0,8(A5)    ; Set volume
  4120.     BRA.S    mt_SetRegs
  4121.  
  4122. mt_NoLoop
  4123.     MOVE.L    n_start(A6),D2
  4124.     ADD.L    D3,D2
  4125.     MOVE.L    D2,n_loopstart(A6)
  4126.     MOVE.L    D2,n_wavestart(A6)
  4127.     MOVE.W    6(A3,D4.L),n_replen(A6)    ; Save replen
  4128.     MOVEQ    #0,D0
  4129.     MOVE.B    n_volume(A6),D0
  4130.     MOVE.W    D0,8(A5)    ; Set volume
  4131. mt_SetRegs
  4132.     MOVE.W    (A6),D0
  4133.     AND.W    #$0FFF,D0
  4134.     BEQ.W    mt_CheckMoreEfx    ; If no note
  4135.  
  4136.     move.l    n_start(a6),(a4)
  4137.  
  4138.     MOVE.W    2(A6),D0
  4139.     AND.W    #$0FF0,D0
  4140.     CMP.W    #$0E50,D0
  4141.     BEQ.S    mt_DoSetFineTune
  4142.     MOVE.B    2(A6),D0
  4143.     AND.B    #$0F,D0
  4144.     CMP.B    #3,D0    ; TonePortamento
  4145.     BEQ.S    mt_ChkTonePorta
  4146.     CMP.B    #5,D0
  4147.     BEQ.S    mt_ChkTonePorta
  4148.     CMP.B    #9,D0    ; Sample Offset
  4149.     BNE.S    mt_SetPeriod
  4150.     BSR.W    mt_CheckMoreEfx
  4151.     BRA.S    mt_SetPeriod
  4152.  
  4153. mt_DoSetFineTune
  4154.     BSR.W    mt_SetFineTune
  4155.     BRA.S    mt_SetPeriod
  4156.  
  4157. mt_ChkTonePorta
  4158.     BSR.W    mt_SetTonePorta
  4159.     BRA.W    mt_CheckMoreEfx
  4160.  
  4161. mt_SetPeriod
  4162.     MOVEM.L    D0-D1/A0-A1,-(SP)
  4163.     MOVE.W    (A6),D1
  4164.     AND.W    #$0FFF,D1
  4165.     LEA    mt_PeriodTable(PC),A1
  4166.     MOVEQ    #0,D0
  4167.     MOVEQ    #36,D2
  4168. mt_ftuloop
  4169.     CMP.W    (A1,D0.W),D1
  4170.     BHS.S    mt_ftufound
  4171.     ADDQ.L    #2,D0
  4172.     DBRA    D2,mt_ftuloop
  4173. mt_ftufound
  4174.     MOVEQ    #0,D1
  4175.     MOVE.B    n_finetune(A6),D1
  4176.     MULU    #36*2,D1
  4177.     ADD.L    D1,A1
  4178.     MOVE.W    (A1,D0.W),n_period(A6)
  4179.     MOVEM.L    (SP)+,D0-D1/A0-A1
  4180.  
  4181.     MOVE.W    2(A6),D0
  4182.     AND.W    #$0FF0,D0
  4183.     CMP.W    #$0ED0,D0 ; Notedelay
  4184.     BEQ.W    mt_CheckMoreEfx
  4185.  
  4186.     MOVE.W    n_dmabit(A6),$DFF096
  4187.     BTST    #2,n_wavecontrol(A6)
  4188.     BNE.S    mt_vibnoc
  4189.     CLR.B    n_vibratopos(A6)
  4190. mt_vibnoc
  4191.     BTST    #6,n_wavecontrol(A6)
  4192.     BNE.S    mt_trenoc
  4193.     CLR.B    n_tremolopos(A6)
  4194. mt_trenoc
  4195.     MOVE.L    n_start(A6),(A5)    ; Set start
  4196.     MOVE.W    n_length(A6),4(A5)    ; Set length
  4197.     MOVE.W    n_period(A6),D0
  4198.     MOVE.W    D0,6(A5)        ; Set period
  4199.     MOVE.W    n_dmabit(A6),D0
  4200.     OR.W    D0,mt_DMACONtemp
  4201.     BRA.W    mt_CheckMoreEfx
  4202.  
  4203. ;wait 10 rasterlines instead of a dbfloop of 300 loops! (now also '030!)
  4204. wait10lines:
  4205.     movem.w    d1/d2,-(sp)
  4206.     moveq    #10,d0            ; number of rasterlines to wait
  4207.     move.b    $dff006,d1
  4208. .loop    move.b    $dff006,d2
  4209.     cmp.b    d1,d2
  4210.     beq.s    .loop            ; wait until difference
  4211.     move.b    d2,d1
  4212.     dbf    d0,.loop
  4213.     movem.w    (sp)+,d1/d2
  4214.     rts
  4215.  
  4216. mt_SetDMA
  4217.     bsr.b    wait10lines
  4218.  
  4219.     MOVE.W    mt_DMACONtemp(PC),D0
  4220.     OR.W    #$8000,D0
  4221.     MOVE.W    D0,$DFF096
  4222.  
  4223.     bsr.b    wait10lines
  4224.  
  4225.     LEA    $DFF000,A5
  4226.     LEA    mt_chan4temp(PC),A6
  4227.     MOVE.L    n_loopstart(A6),$D0(A5)
  4228.     MOVE.W    n_replen(A6),$D4(A5)
  4229.     LEA    mt_chan3temp(PC),A6
  4230.     MOVE.L    n_loopstart(A6),$C0(A5)
  4231.     MOVE.W    n_replen(A6),$C4(A5)
  4232.     LEA    mt_chan2temp(PC),A6
  4233.     MOVE.L    n_loopstart(A6),$B0(A5)
  4234.     MOVE.W    n_replen(A6),$B4(A5)
  4235.     LEA    mt_chan1temp(PC),A6
  4236.     MOVE.L    n_loopstart(A6),$A0(A5)
  4237.     MOVE.W    n_replen(A6),$A4(A5)
  4238.  
  4239. mt_dskip
  4240.     ADD.W    #16,mt_PatternPos
  4241.     MOVE.B    mt_PattDelTime,D0
  4242.     BEQ.S    mt_dskc
  4243.     MOVE.B    D0,mt_PattDelTime2
  4244.     CLR.B    mt_PattDelTime
  4245. mt_dskc    TST.B    mt_PattDelTime2
  4246.     BEQ.S    mt_dska
  4247.     SUBQ.B    #1,mt_PattDelTime2
  4248.     BEQ.S    mt_dska
  4249.     SUB.W    #16,mt_PatternPos
  4250. mt_dska    TST.B    mt_PBreakFlag
  4251.     BEQ.S    mt_nnpysk
  4252.     SF    mt_PBreakFlag
  4253.     MOVEQ    #0,D0
  4254.     MOVE.B    mt_PBreakPos(PC),D0
  4255.     CLR.B    mt_PBreakPos
  4256.     LSL.W    #4,D0
  4257.     MOVE.W    D0,mt_PatternPos
  4258. mt_nnpysk
  4259.  
  4260.     CMP.W    #1024,mt_PatternPos
  4261.     BLO.S    mt_NoNewPosYet
  4262.  
  4263.     tst.b    mt_posjumpflag
  4264.     bne.s    mt_nextposition
  4265.  
  4266.     clr.w    blit_note_slot_teller
  4267.  
  4268. mt_NextPosition    
  4269.     MOVEQ    #0,D0
  4270.     MOVE.B    mt_PBreakPos(PC),D0
  4271.  
  4272.     move.b    #1,new_pattern
  4273.  
  4274.     LSL.W    #4,D0
  4275.     MOVE.W    D0,mt_PatternPos
  4276.     CLR.B    mt_PBreakPos
  4277.     CLR.B    mt_PosJumpFlag
  4278.     ADDQ.B    #1,mt_SongPos
  4279.  
  4280.     AND.B    #$7F,mt_SongPos
  4281.     MOVE.B    mt_SongPos(PC),D1
  4282.     MOVE.L    mt_SongDataPtr(PC),A0
  4283.     
  4284.     CMP.B    950(A0),D1
  4285.     BLO.S    mt_NoNewPosYet
  4286.     CLR.B    mt_SongPos
  4287.  
  4288. mt_NoNewPosYet    
  4289.     TST.B    mt_PosJumpFlag
  4290.     BNE.S    mt_NextPosition
  4291.  
  4292. ;store the value of the pattern current played
  4293.  
  4294. mt_exit
  4295.     move.l    mt_data,a0
  4296.     lea    952(a0),a0
  4297.     
  4298.     moveq    #0,d0
  4299.     move.b    mt_SongPos(PC),d0
  4300.     move.b    (a0,d0.w),pattern_pointer
  4301.  
  4302.     MOVEM.L    (SP)+,D0-D7/A0-A6
  4303.     RTS
  4304.  
  4305. mt_CheckEfx
  4306.     BSR.W    mt_UpdateFunk
  4307.     MOVE.W    n_cmd(A6),D0
  4308.     AND.W    #$0FFF,D0
  4309.     BEQ.S    mt_PerNop
  4310.     MOVE.B    n_cmd(A6),D0
  4311.     AND.B    #$0F,D0
  4312.     BEQ.S    mt_Arpeggio
  4313.     CMP.B    #1,D0
  4314.     BEQ.W    mt_PortaUp
  4315.     CMP.B    #2,D0
  4316.     BEQ.W    mt_PortaDown
  4317.     CMP.B    #3,D0
  4318.     BEQ.W    mt_TonePortamento
  4319.     CMP.B    #4,D0
  4320.     BEQ.W    mt_Vibrato
  4321.     CMP.B    #5,D0
  4322.     BEQ.W    mt_TonePlusVolSlide
  4323.     CMP.B    #6,D0
  4324.     BEQ.W    mt_VibratoPlusVolSlide
  4325.     CMP.B    #$E,D0
  4326.     BEQ.W    mt_E_Commands
  4327. SetBack    MOVE.W    n_period(A6),6(A5)
  4328.     CMP.B    #7,D0
  4329.     BEQ.W    mt_Tremolo
  4330.     CMP.B    #$A,D0
  4331.     BEQ.W    mt_VolumeSlide
  4332. mt_Return
  4333.     RTS
  4334.  
  4335. mt_PerNop
  4336.     MOVE.W    n_period(A6),6(A5)
  4337.     RTS
  4338.  
  4339. mt_Arpeggio
  4340.     MOVEQ    #0,D0
  4341.     MOVE.B    mt_counter(PC),D0
  4342.     DIVS    #3,D0
  4343.     SWAP    D0
  4344.     CMP.W    #0,D0
  4345.     BEQ.S    mt_Arpeggio2
  4346.     CMP.W    #2,D0
  4347.     BEQ.S    mt_Arpeggio1
  4348.     MOVEQ    #0,D0
  4349.     MOVE.B    n_cmdlo(A6),D0
  4350.     LSR.B    #4,D0
  4351.     BRA.S    mt_Arpeggio3
  4352.  
  4353. mt_Arpeggio1
  4354.     MOVEQ    #0,D0
  4355.     MOVE.B    n_cmdlo(A6),D0
  4356.     AND.B    #15,D0
  4357.     BRA.S    mt_Arpeggio3
  4358.  
  4359. mt_Arpeggio2
  4360.     MOVE.W    n_period(A6),D2
  4361.     BRA.S    mt_Arpeggio4
  4362.  
  4363. mt_Arpeggio3
  4364.     ASL.W    #1,D0
  4365.     MOVEQ    #0,D1
  4366.     MOVE.B    n_finetune(A6),D1
  4367.     MULU    #36*2,D1
  4368.     LEA    mt_PeriodTable(PC),A0
  4369.     ADD.L    D1,A0
  4370.     MOVEQ    #0,D1
  4371.     MOVE.W    n_period(A6),D1
  4372.     MOVEQ    #36,D3
  4373. mt_arploop
  4374.     MOVE.W    (A0,D0.W),D2
  4375.     CMP.W    (A0),D1
  4376.     BHS.S    mt_Arpeggio4
  4377.     ADDQ.L    #2,A0
  4378.     DBRA    D3,mt_arploop
  4379.     RTS
  4380.  
  4381. mt_Arpeggio4
  4382.     MOVE.W    D2,6(A5)
  4383.     RTS
  4384.  
  4385. mt_FinePortaUp
  4386.     TST.B    mt_counter
  4387.     BNE.S    mt_Return
  4388.     MOVE.B    #$0F,mt_LowMask
  4389. mt_PortaUp
  4390.     MOVEQ    #0,D0
  4391.     MOVE.B    n_cmdlo(A6),D0
  4392.     AND.B    mt_LowMask(PC),D0
  4393.     MOVE.B    #$FF,mt_LowMask
  4394.     SUB.W    D0,n_period(A6)
  4395.     MOVE.W    n_period(A6),D0
  4396.     AND.W    #$0FFF,D0
  4397.     CMP.W    #113,D0
  4398.     BPL.S    mt_PortaUskip
  4399.     AND.W    #$F000,n_period(A6)
  4400.     OR.W    #113,n_period(A6)
  4401. mt_PortaUskip
  4402.     MOVE.W    n_period(A6),D0
  4403.     AND.W    #$0FFF,D0
  4404.     MOVE.W    D0,6(A5)
  4405.     RTS    
  4406.  
  4407. mt_FinePortaDown
  4408.     TST.B    mt_counter
  4409.     BNE.W    mt_Return
  4410.     MOVE.B    #$0F,mt_LowMask
  4411. mt_PortaDown
  4412.     CLR.W    D0
  4413.     MOVE.B    n_cmdlo(A6),D0
  4414.     AND.B    mt_LowMask(PC),D0
  4415.     MOVE.B    #$FF,mt_LowMask
  4416.     ADD.W    D0,n_period(A6)
  4417.     MOVE.W    n_period(A6),D0
  4418.     AND.W    #$0FFF,D0
  4419.     CMP.W    #856,D0
  4420.     BMI.S    mt_PortaDskip
  4421.     AND.W    #$F000,n_period(A6)
  4422.     OR.W    #856,n_period(A6)
  4423. mt_PortaDskip
  4424.     MOVE.W    n_period(A6),D0
  4425.     AND.W    #$0FFF,D0
  4426.     MOVE.W    D0,6(A5)
  4427.     RTS
  4428.  
  4429. mt_SetTonePorta
  4430.     MOVE.L    A0,-(SP)
  4431.     MOVE.W    (A6),D2
  4432.     AND.W    #$0FFF,D2
  4433.     MOVEQ    #0,D0
  4434.     MOVE.B    n_finetune(A6),D0
  4435.     MULU    #36*2,D0 ;37?
  4436.     LEA    mt_PeriodTable(PC),A0
  4437.     ADD.L    D0,A0
  4438.     MOVEQ    #0,D0
  4439. mt_StpLoop
  4440.     CMP.W    (A0,D0.W),D2
  4441.     BHS.S    mt_StpFound
  4442.     ADDQ.W    #2,D0
  4443.     CMP.W    #36*2,D0 ;37?
  4444.     BLO.S    mt_StpLoop
  4445.     MOVEQ    #35*2,D0
  4446. mt_StpFound
  4447.     MOVE.B    n_finetune(A6),D2
  4448.     AND.B    #8,D2
  4449.     BEQ.S    mt_StpGoss
  4450.     TST.W    D0
  4451.     BEQ.S    mt_StpGoss
  4452.     SUBQ.W    #2,D0
  4453. mt_StpGoss
  4454.     MOVE.W    (A0,D0.W),D2
  4455.     MOVE.L    (SP)+,A0
  4456.     MOVE.W    D2,n_wantedperiod(A6)
  4457.     MOVE.W    n_period(A6),D0
  4458.     CLR.B    n_toneportdirec(A6)
  4459.     CMP.W    D0,D2
  4460.     BEQ.S    mt_ClearTonePorta
  4461.     BGE.W    mt_Return
  4462.     MOVE.B    #1,n_toneportdirec(A6)
  4463.     RTS
  4464.  
  4465. mt_ClearTonePorta
  4466.     CLR.W    n_wantedperiod(A6)
  4467.     RTS
  4468.  
  4469. mt_TonePortamento
  4470.     MOVE.B    n_cmdlo(A6),D0
  4471.     BEQ.S    mt_TonePortNoChange
  4472.     MOVE.B    D0,n_toneportspeed(A6)
  4473.     CLR.B    n_cmdlo(A6)
  4474. mt_TonePortNoChange
  4475.     TST.W    n_wantedperiod(A6)
  4476.     BEQ.W    mt_Return
  4477.     MOVEQ    #0,D0
  4478.     MOVE.B    n_toneportspeed(A6),D0
  4479.     TST.B    n_toneportdirec(A6)
  4480.     BNE.S    mt_TonePortaUp
  4481. mt_TonePortaDown
  4482.     ADD.W    D0,n_period(A6)
  4483.     MOVE.W    n_wantedperiod(A6),D0
  4484.     CMP.W    n_period(A6),D0
  4485.     BGT.S    mt_TonePortaSetPer
  4486.     MOVE.W    n_wantedperiod(A6),n_period(A6)
  4487.     CLR.W    n_wantedperiod(A6)
  4488.     BRA.S    mt_TonePortaSetPer
  4489.  
  4490. mt_TonePortaUp
  4491.     SUB.W    D0,n_period(A6)
  4492.     MOVE.W    n_wantedperiod(A6),D0
  4493.     CMP.W    n_period(A6),D0
  4494.     BLT.S    mt_TonePortaSetPer
  4495.     MOVE.W    n_wantedperiod(A6),n_period(A6)
  4496.     CLR.W    n_wantedperiod(A6)
  4497.  
  4498. mt_TonePortaSetPer
  4499.     MOVE.W    n_period(A6),D2
  4500.     MOVE.B    n_glissfunk(A6),D0
  4501.     AND.B    #$0F,D0
  4502.     BEQ.B    mt_GlissSkip
  4503.     MOVEQ    #0,D0
  4504.     MOVE.B    n_finetune(A6),D0
  4505.     MULU    #36*2,D0
  4506.     LEA    mt_PeriodTable(PC),A0
  4507.     ADD.L    D0,A0
  4508.     MOVEQ    #0,D0
  4509. mt_GlissLoop
  4510.     CMP.W    (A0,D0.W),D2
  4511.     BHS.S    mt_GlissFound
  4512.     ADDQ.W    #2,D0
  4513.     CMP.W    #36*2,D0
  4514.     BLO.S    mt_GlissLoop
  4515.     MOVEQ    #35*2,D0
  4516. mt_GlissFound
  4517.     MOVE.W    (A0,D0.W),D2
  4518. mt_GlissSkip
  4519.     MOVE.W    D2,6(A5) ; Set period
  4520.     RTS
  4521.  
  4522. mt_Vibrato
  4523.     MOVE.B    n_cmdlo(A6),D0
  4524.     BEQ.S    mt_Vibrato2
  4525.     MOVE.B    n_vibratocmd(A6),D2
  4526.     AND.B    #$0F,D0
  4527.     BEQ.S    mt_vibskip
  4528.     AND.B    #$F0,D2
  4529.     OR.B    D0,D2
  4530. mt_vibskip
  4531.     MOVE.B    n_cmdlo(A6),D0
  4532.     AND.B    #$F0,D0
  4533.     BEQ.S    mt_vibskip2
  4534.     AND.B    #$0F,D2
  4535.     OR.B    D0,D2
  4536. mt_vibskip2
  4537.     MOVE.B    D2,n_vibratocmd(A6)
  4538. mt_Vibrato2
  4539.     MOVE.B    n_vibratopos(A6),D0
  4540.     LEA    mt_VibratoTable(PC),A4
  4541.     LSR.W    #2,D0
  4542.     AND.W    #$001F,D0
  4543.     MOVEQ    #0,D2
  4544.     MOVE.B    n_wavecontrol(A6),D2
  4545.     AND.B    #$03,D2
  4546.     BEQ.S    mt_vib_sine
  4547.     LSL.B    #3,D0
  4548.     CMP.B    #1,D2
  4549.     BEQ.S    mt_vib_rampdown
  4550.     MOVE.B    #255,D2
  4551.     BRA.S    mt_vib_set
  4552. mt_vib_rampdown
  4553.     TST.B    n_vibratopos(A6)
  4554.     BPL.S    mt_vib_rampdown2
  4555.     MOVE.B    #255,D2
  4556.     SUB.B    D0,D2
  4557.     BRA.S    mt_vib_set
  4558. mt_vib_rampdown2
  4559.     MOVE.B    D0,D2
  4560.     BRA.S    mt_vib_set
  4561. mt_vib_sine
  4562.     MOVE.B    (A4,D0.W),D2
  4563. mt_vib_set
  4564.     MOVE.B    n_vibratocmd(A6),D0
  4565.     AND.W    #15,D0
  4566.     MULU    D0,D2
  4567.     LSR.W    #7,D2
  4568.     MOVE.W    n_period(A6),D0
  4569.     TST.B    n_vibratopos(A6)
  4570.     BMI.S    mt_VibratoNeg
  4571.     ADD.W    D2,D0
  4572.     BRA.S    mt_Vibrato3
  4573. mt_VibratoNeg
  4574.     SUB.W    D2,D0
  4575. mt_Vibrato3
  4576.     MOVE.W    D0,6(A5)
  4577.     MOVE.B    n_vibratocmd(A6),D0
  4578.     LSR.W    #2,D0
  4579.     AND.W    #$003C,D0
  4580.     ADD.B    D0,n_vibratopos(A6)
  4581.     RTS
  4582.  
  4583. mt_TonePlusVolSlide
  4584.     BSR.W    mt_TonePortNoChange
  4585.     BRA.W    mt_VolumeSlide
  4586.  
  4587. mt_VibratoPlusVolSlide
  4588.     BSR.S    mt_Vibrato2
  4589.     BRA.W    mt_VolumeSlide
  4590.  
  4591. mt_Tremolo
  4592.     MOVE.B    n_cmdlo(A6),D0
  4593.     BEQ.S    mt_Tremolo2
  4594.     MOVE.B    n_tremolocmd(A6),D2
  4595.     AND.B    #$0F,D0
  4596.     BEQ.S    mt_treskip
  4597.     AND.B    #$F0,D2
  4598.     OR.B    D0,D2
  4599. mt_treskip
  4600.     MOVE.B    n_cmdlo(A6),D0
  4601.     AND.B    #$F0,D0
  4602.     BEQ.S    mt_treskip2
  4603.     AND.B    #$0F,D2
  4604.     OR.B    D0,D2
  4605. mt_treskip2
  4606.     MOVE.B    D2,n_tremolocmd(A6)
  4607. mt_Tremolo2
  4608.     MOVE.B    n_tremolopos(A6),D0
  4609.     LEA    mt_VibratoTable(PC),A4
  4610.     LSR.W    #2,D0
  4611.     AND.W    #$001F,D0
  4612.     MOVEQ    #0,D2
  4613.     MOVE.B    n_wavecontrol(A6),D2
  4614.     LSR.B    #4,D2
  4615.     AND.B    #$03,D2
  4616.     BEQ.S    mt_tre_sine
  4617.     LSL.B    #3,D0
  4618.     CMP.B    #1,D2
  4619.     BEQ.S    mt_tre_rampdown
  4620.     MOVE.B    #255,D2
  4621.     BRA.S    mt_tre_set
  4622. mt_tre_rampdown
  4623.     TST.B    n_vibratopos(A6)
  4624.     BPL.S    mt_tre_rampdown2
  4625.     MOVE.B    #255,D2
  4626.     SUB.B    D0,D2
  4627.     BRA.S    mt_tre_set
  4628. mt_tre_rampdown2
  4629.     MOVE.B    D0,D2
  4630.     BRA.S    mt_tre_set
  4631. mt_tre_sine
  4632.     MOVE.B    (A4,D0.W),D2
  4633. mt_tre_set
  4634.     MOVE.B    n_tremolocmd(A6),D0
  4635.     AND.W    #15,D0
  4636.     MULU    D0,D2
  4637.     LSR.W    #6,D2
  4638.     MOVEQ    #0,D0
  4639.     MOVE.B    n_volume(A6),D0
  4640.     TST.B    n_tremolopos(A6)
  4641.     BMI.S    mt_TremoloNeg
  4642.     ADD.W    D2,D0
  4643.     BRA.S    mt_Tremolo3
  4644. mt_TremoloNeg
  4645.     SUB.W    D2,D0
  4646. mt_Tremolo3
  4647.     BPL.S    mt_TremoloSkip
  4648.     CLR.W    D0
  4649. mt_TremoloSkip
  4650.     CMP.W    #$40,D0
  4651.     BLS.S    mt_TremoloOk
  4652.     MOVE.W    #$40,D0
  4653. mt_TremoloOk
  4654.     MOVE.W    D0,8(A5)
  4655.     MOVE.B    n_tremolocmd(A6),D0
  4656.     LSR.W    #2,D0
  4657.     AND.W    #$003C,D0
  4658.     ADD.B    D0,n_tremolopos(A6)
  4659.     RTS
  4660.     
  4661. mt_SampleOffset
  4662.     MOVEQ    #0,D0
  4663.     MOVE.B    n_cmdlo(A6),D0
  4664.     BEQ.S    mt_sononew
  4665.     MOVE.B    D0,n_sampleoffset(A6)
  4666. mt_sononew
  4667.     MOVE.B    n_sampleoffset(A6),D0
  4668.     LSL.W    #7,D0
  4669.     CMP.W    n_length(A6),D0
  4670.     BGE.S    mt_sofskip
  4671.     SUB.W    D0,n_length(A6)
  4672.     LSL.W    #1,D0
  4673.     ADD.L    D0,n_start(A6)
  4674.     RTS
  4675. mt_sofskip
  4676.     MOVE.W    #$0001,n_length(A6)
  4677.     RTS
  4678.  
  4679. mt_VolumeSlide
  4680.     MOVEQ    #0,D0
  4681.     MOVE.B    n_cmdlo(A6),D0
  4682.     LSR.B    #4,D0
  4683.     TST.B    D0
  4684.     BEQ.S    mt_VolSlideDown
  4685. mt_VolSlideUp
  4686.     ADD.B    D0,n_volume(A6)
  4687.     CMP.B    #$40,n_volume(A6)
  4688.     BMI.S    mt_vsuskip
  4689.     MOVE.B    #$40,n_volume(A6)
  4690. mt_vsuskip
  4691.     MOVE.B    n_volume(A6),D0
  4692.     MOVE.W    D0,8(A5)
  4693.     RTS
  4694.  
  4695. mt_VolSlideDown
  4696.     MOVEQ    #0,D0
  4697.     MOVE.B    n_cmdlo(A6),D0
  4698.     AND.B    #$0F,D0
  4699. mt_VolSlideDown2
  4700.     SUB.B    D0,n_volume(A6)
  4701.     BPL.S    mt_vsdskip
  4702.     CLR.B    n_volume(A6)
  4703. mt_vsdskip
  4704.     MOVE.B    n_volume(A6),D0
  4705.     MOVE.W    D0,8(A5)
  4706.     RTS
  4707.  
  4708. mt_PositionJump
  4709.     MOVE.B    n_cmdlo(A6),D0
  4710.     SUBQ.B    #1,D0
  4711.     MOVE.B    D0,mt_SongPos
  4712. mt_pj2    CLR.B    mt_PBreakPos
  4713.     ST     mt_PosJumpFlag
  4714.  
  4715.     move.b    #1,new_pattern
  4716.     move.w    #0,blit_note_slot_teller    
  4717.  
  4718.     RTS
  4719.  
  4720. mt_VolumeChange
  4721.     MOVEQ    #0,D0
  4722.     MOVE.B    n_cmdlo(A6),D0
  4723.     CMP.B    #$40,D0
  4724.     BLS.S    mt_VolumeOk
  4725.     MOVEQ    #$40,D0
  4726. mt_VolumeOk
  4727.     MOVE.B    D0,n_volume(A6)
  4728.     MOVE.W    D0,8(A5)
  4729.     RTS
  4730.  
  4731. mt_PatternBreak
  4732.     MOVEQ    #0,D0
  4733.     MOVE.B    n_cmdlo(A6),D0
  4734.  
  4735.  
  4736.     MOVE.L    D0,D2
  4737.     LSR.B    #4,D0
  4738.     MULU    #10,D0
  4739.     AND.B    #$0F,D2
  4740.     ADD.B    D2,D0
  4741.     CMP.B    #63,D0
  4742.     BHI.S    mt_pj2
  4743.     MOVE.B    D0,mt_PBreakPos
  4744.  
  4745. ;pattern break, so store the restart position in the two tellers
  4746.  
  4747.     move.b    #1,new_pattern
  4748.     move.w    d0,blit_note_slot_teller    
  4749.  
  4750.     ST    mt_PosJumpFlag
  4751.     RTS
  4752.  
  4753. mt_SetSpeed
  4754.     MOVEQ    #0,D0
  4755.     MOVE.B    3(A6),D0
  4756.     BEQ.W    mt_end
  4757.     CMP.B    #32,D0
  4758.     BHS.W    SetTempo
  4759.     CLR.B    mt_counter
  4760.     MOVE.B    D0,mt_speed
  4761.     move.b    #1,new_vbl_tempo
  4762.     RTS
  4763.  
  4764. mt_CheckMoreEfx
  4765.     BSR.W    mt_UpdateFunk
  4766.     MOVE.B    2(A6),D0
  4767.     AND.B    #$0F,D0
  4768.     CMP.B    #$9,D0
  4769.     BEQ.W    mt_SampleOffset
  4770.     CMP.B    #$B,D0
  4771.     BEQ.W    mt_PositionJump
  4772.     CMP.B    #$D,D0
  4773.     BEQ.S    mt_PatternBreak
  4774.     CMP.B    #$E,D0
  4775.     BEQ.S    mt_E_Commands
  4776.     CMP.B    #$F,D0
  4777.     BEQ.S    mt_SetSpeed
  4778.     CMP.B    #$C,D0
  4779.     BEQ.W    mt_VolumeChange
  4780.     BRA.W    mt_PerNop
  4781.  
  4782. mt_E_Commands
  4783.     MOVE.B    n_cmdlo(A6),D0
  4784.     AND.B    #$F0,D0
  4785.     LSR.B    #4,D0
  4786.     BEQ.S    mt_FilterOnOff
  4787.     CMP.B    #1,D0
  4788.     BEQ.W    mt_FinePortaUp
  4789.     CMP.B    #2,D0
  4790.     BEQ.W    mt_FinePortaDown
  4791.     CMP.B    #3,D0
  4792.     BEQ.S    mt_SetGlissControl
  4793.     CMP.B    #4,D0
  4794.     BEQ.W    mt_SetVibratoControl
  4795.     CMP.B    #5,D0
  4796.     BEQ.W    mt_SetFineTune
  4797.     CMP.B    #6,D0
  4798.     BEQ.W    mt_JumpLoop
  4799.     CMP.B    #7,D0
  4800.     BEQ.W    mt_SetTremoloControl
  4801.     CMP.B    #9,D0
  4802.     BEQ.W    mt_RetrigNote
  4803.     CMP.B    #$A,D0
  4804.     BEQ.W    mt_VolumeFineUp
  4805.     CMP.B    #$B,D0
  4806.     BEQ.W    mt_VolumeFineDown
  4807.     CMP.B    #$C,D0
  4808.     BEQ.W    mt_NoteCut
  4809.     CMP.B    #$D,D0
  4810.     BEQ.W    mt_NoteDelay
  4811.     CMP.B    #$E,D0
  4812.     BEQ.W    mt_PatternDelay
  4813.     CMP.B    #$F,D0
  4814.     BEQ.W    mt_FunkIt
  4815.     RTS
  4816.  
  4817. mt_FilterOnOff
  4818.     MOVE.B    n_cmdlo(A6),D0
  4819.     AND.B    #1,D0
  4820.     ASL.B    #1,D0
  4821.     AND.B    #$FD,$BFE001
  4822.     OR.B    D0,$BFE001
  4823.     RTS    
  4824.  
  4825. mt_SetGlissControl
  4826.     MOVE.B    n_cmdlo(A6),D0
  4827.     AND.B    #$0F,D0
  4828.     AND.B    #$F4,n_glissfunk(A6)
  4829.     OR.B    D0,n_glissfunk(A6)
  4830.     RTS
  4831.  
  4832. mt_SetVibratoControl
  4833.     MOVE.B    n_cmdlo(A6),D0
  4834.     AND.B    #$0F,D0
  4835.     AND.B    #$F0,n_wavecontrol(A6)
  4836.     OR.B    D0,n_wavecontrol(A6)
  4837.     RTS
  4838.  
  4839. mt_SetFineTune
  4840.     MOVE.B    n_cmdlo(A6),D0
  4841.     AND.B    #$0F,D0
  4842.     MOVE.B    D0,n_finetune(A6)
  4843.     RTS
  4844.  
  4845. mt_JumpLoop
  4846.     TST.B    mt_counter
  4847.     BNE.W    mt_Return
  4848.     MOVE.B    n_cmdlo(A6),D0
  4849.     AND.B    #$0F,D0
  4850.     BEQ.S    mt_SetLoop
  4851.     TST.B    n_loopcount(A6)
  4852.     BEQ.S    mt_jumpcnt
  4853.     SUBQ.B    #1,n_loopcount(A6)
  4854.     BEQ.W    mt_Return
  4855. mt_jmploop    MOVE.B    n_pattpos(A6),mt_PBreakPos
  4856.     ST    mt_PBreakFlag
  4857.     RTS
  4858.  
  4859. mt_jumpcnt
  4860.     MOVE.B    D0,n_loopcount(A6)
  4861.     BRA.S    mt_jmploop
  4862.  
  4863. mt_SetLoop
  4864.     MOVE.W    mt_PatternPos(PC),D0
  4865.     LSR.W    #4,D0
  4866.     MOVE.B    D0,n_pattpos(A6)
  4867.     RTS
  4868.  
  4869. mt_SetTremoloControl
  4870.     MOVE.B    n_cmdlo(A6),D0
  4871.     AND.B    #$0F,D0
  4872.     LSL.B    #4,D0
  4873.     AND.B    #$0F,n_wavecontrol(A6)
  4874.     OR.B    D0,n_wavecontrol(A6)
  4875.     RTS
  4876.  
  4877. mt_RetrigNote
  4878.     MOVE.L    D1,-(SP)
  4879.     MOVEQ    #0,D0
  4880.     MOVE.B    n_cmdlo(A6),D0
  4881.     AND.B    #$0F,D0
  4882.     BEQ.S    mt_rtnend
  4883.     MOVEQ    #0,D1
  4884.     MOVE.B    mt_counter(PC),D1
  4885.     BNE.S    mt_rtnskp
  4886.     MOVE.W    (A6),D1
  4887.     AND.W    #$0FFF,D1
  4888.     BNE.S    mt_rtnend
  4889.     MOVEQ    #0,D1
  4890.     MOVE.B    mt_counter(PC),D1
  4891. mt_rtnskp
  4892.     DIVU    D0,D1
  4893.     SWAP    D1
  4894.     TST.W    D1
  4895.     BNE.S    mt_rtnend
  4896. mt_DoRetrig
  4897.     MOVE.W    n_dmabit(A6),$DFF096    ; Channel DMA off
  4898.     MOVE.L    n_start(A6),(A5)    ; Set sampledata pointer
  4899.     MOVE.W    n_length(A6),4(A5)    ; Set length
  4900.  
  4901. * changed
  4902.     bsr.w    wait10lines
  4903.  
  4904.     MOVE.W    n_dmabit(A6),D0
  4905.     BSET    #15,D0
  4906.     MOVE.W    D0,$DFF096
  4907.  
  4908. * changed
  4909.     bsr.w    wait10lines
  4910.  
  4911.     MOVE.L    n_loopstart(A6),(A5)
  4912.     MOVE.L    n_replen(A6),4(A5)
  4913. mt_rtnend
  4914.     MOVE.L    (SP)+,D1
  4915.     RTS
  4916.  
  4917. mt_VolumeFineUp
  4918.     TST.B    mt_counter
  4919.     BNE.W    mt_Return
  4920.     MOVEQ    #0,D0
  4921.     MOVE.B    n_cmdlo(A6),D0
  4922.     AND.B    #$F,D0
  4923.     BRA.W    mt_VolSlideUp
  4924.  
  4925. mt_VolumeFineDown
  4926.     TST.B    mt_counter
  4927.     BNE.W    mt_Return
  4928.     MOVEQ    #0,D0
  4929.     MOVE.B    n_cmdlo(A6),D0
  4930.     AND.B    #$0F,D0
  4931.     BRA.W    mt_VolSlideDown2
  4932.  
  4933. mt_NoteCut
  4934.     MOVEQ    #0,D0
  4935.     MOVE.B    n_cmdlo(A6),D0
  4936.     AND.B    #$0F,D0
  4937.     CMP.B    mt_counter(PC),D0
  4938.     BNE.W    mt_Return
  4939.     CLR.B    n_volume(A6)
  4940.     MOVE.W    #0,8(A5)
  4941.     RTS
  4942.  
  4943. mt_NoteDelay
  4944.     MOVEQ    #0,D0
  4945.     MOVE.B    n_cmdlo(A6),D0
  4946.     AND.B    #$0F,D0
  4947.     CMP.B    mt_Counter,D0
  4948.     BNE.W    mt_Return
  4949.     MOVE.W    (A6),D0
  4950.     BEQ.W    mt_Return
  4951.     MOVE.L    D1,-(SP)
  4952.     BRA.W    mt_DoRetrig
  4953.  
  4954. mt_PatternDelay
  4955.     TST.B    mt_counter
  4956.     BNE.W    mt_Return
  4957.     MOVEQ    #0,D0
  4958.     MOVE.B    n_cmdlo(A6),D0
  4959.     AND.B    #$0F,D0
  4960.     TST.B    mt_PattDelTime2
  4961.     BNE.W    mt_Return
  4962.     ADDQ.B    #1,D0
  4963.     MOVE.B    D0,mt_PattDelTime
  4964.     RTS
  4965.  
  4966. mt_FunkIt
  4967.     TST.B    mt_counter
  4968.     BNE.W    mt_Return
  4969.     MOVE.B    n_cmdlo(A6),D0
  4970.     AND.B    #$0F,D0
  4971.     LSL.B    #4,D0
  4972.     AND.B    #$0F,n_glissfunk(A6)
  4973.     OR.B    D0,n_glissfunk(A6)
  4974.     TST.B    D0
  4975.     BEQ.W    mt_Return
  4976. mt_UpdateFunk
  4977.     MOVEM.L    A0/D1,-(SP)
  4978.     MOVEQ    #0,D0
  4979.     MOVE.B    n_glissfunk(A6),D0
  4980.     LSR.B    #4,D0
  4981.     BEQ.S    mt_funkend
  4982.     LEA    mt_FunkTable(PC),A0
  4983.     MOVE.B    (A0,D0.W),D0
  4984.     ADD.B    D0,n_funkoffset(A6)
  4985.     BTST    #7,n_funkoffset(A6)
  4986.     BEQ.S    mt_funkend
  4987.     CLR.B    n_funkoffset(A6)
  4988.  
  4989.     MOVE.L    n_loopstart(A6),D0
  4990.     MOVEQ    #0,D1
  4991.     MOVE.W    n_replen(A6),D1
  4992.     ADD.L    D1,D0
  4993.     ADD.L    D1,D0
  4994.     MOVE.L    n_wavestart(A6),A0
  4995.     ADDQ.L    #1,A0
  4996.     CMP.L    D0,A0
  4997.     BLO.S    mt_funkok
  4998.     MOVE.L    n_loopstart(A6),A0
  4999. mt_funkok
  5000.     MOVE.L    A0,n_wavestart(A6)
  5001.     MOVEQ    #-1,D0
  5002.     SUB.B    (A0),D0
  5003.     MOVE.B    D0,(A0)
  5004. mt_funkend
  5005.     MOVEM.L    (SP)+,A0/D1
  5006.     RTS
  5007.  
  5008.  
  5009. mt_FunkTable dc.b 0,5,6,7,8,10,11,13,16,19,22,26,32,43,64,128
  5010.  
  5011. mt_VibratoTable    
  5012.     dc.b   0, 24, 49, 74, 97,120,141,161
  5013.     dc.b 180,197,212,224,235,244,250,253
  5014.     dc.b 255,253,250,244,235,224,212,197
  5015.     dc.b 180,161,141,120, 97, 74, 49, 24
  5016.  
  5017. mt_PeriodTable
  5018. ; Tuning 0, Normal
  5019. ;c-1 - b3
  5020.  
  5021.     dc.w    856,808,762,720,678,640,604,570,538,508,480,453
  5022.     dc.w    428,404,381,360,339,320,302,285,269,254,240,226
  5023.     dc.w    214,202,190,180,170,160,151,143,135,127,120,113
  5024. ; Tuning 1
  5025.     dc.w    850,802,757,715,674,637,601,567,535,505,477,450
  5026.     dc.w    425,401,379,357,337,318,300,284,268,253,239,225
  5027.     dc.w    213,201,189,179,169,159,150,142,134,126,119,113
  5028. ; Tuning 2
  5029.     dc.w    844,796,752,709,670,632,597,563,532,502,474,447
  5030.     dc.w    422,398,376,355,335,316,298,282,266,251,237,224
  5031.     dc.w    211,199,188,177,167,158,149,141,133,125,118,112
  5032. ; Tuning 3
  5033.     dc.w    838,791,746,704,665,628,592,559,528,498,470,444
  5034.     dc.w    419,395,373,352,332,314,296,280,264,249,235,222
  5035.     dc.w    209,198,187,176,166,157,148,140,132,125,118,111
  5036. ; Tuning 4
  5037.     dc.w    832,785,741,699,660,623,588,555,524,495,467,441
  5038.     dc.w    416,392,370,350,330,312,294,278,262,247,233,220
  5039.     dc.w    208,196,185,175,165,156,147,139,131,124,117,110
  5040. ; Tuning 5
  5041.     dc.w    826,779,736,694,655,619,584,551,520,491,463,437
  5042.     dc.w    413,390,368,347,328,309,292,276,260,245,232,219
  5043.     dc.w    206,195,184,174,164,155,146,138,130,123,116,109
  5044. ; Tuning 6
  5045.     dc.w    820,774,730,689,651,614,580,547,516,487,460,434
  5046.     dc.w    410,387,365,345,325,307,290,274,258,244,230,217
  5047.     dc.w    205,193,183,172,163,154,145,137,129,122,115,109
  5048. ; Tuning 7
  5049.     dc.w    814,768,725,684,646,610,575,543,513,484,457,431
  5050.     dc.w    407,384,363,342,323,305,288,272,256,242,228,216
  5051.     dc.w    204,192,181,171,161,152,144,136,128,121,114,108
  5052. ; Tuning -8
  5053.     dc.w    907,856,808,762,720,678,640,604,570,538,508,480
  5054.     dc.w    453,428,404,381,360,339,320,302,285,269,254,240
  5055.     dc.w    226,214,202,190,180,170,160,151,143,135,127,120
  5056. ;$Tuning -7
  5057.     dc.w    900,850,802,757,715,675,636,601,567,535,505,477
  5058.     dc.w    450,425,401,379,357,337,318,300,284,268,253,238
  5059.     dc.w    225,212,200,189,179,169,159,150,142,134,126,119
  5060. ;$Tuning -6
  5061.     dc.w    894,844,796,752,709,670,632,597,563,532,502,474
  5062.     dc.w    447,422,398,376,355,335,316,298,282,266,251,237
  5063.     dc.w    223,211,199,188,177,167,158,149,141,133,125,118
  5064. ; Tuning -5
  5065.     dc.w    887,838,791,746,704,665,628,592,559,528,498,470
  5066.     dc.w    444,419,395,373,352,332,314,296,280,264,249,235
  5067.     dc.w    222,209,198,187,176,166,157,148,140,132,125,118
  5068. ;$Tuning -4
  5069.     dc.w    881,832,785,741,699,660,623,588,555,524,494,467
  5070.     dc.w    441,416,392,370,350,330,312,294,278,262,247,233
  5071.     dc.w    220,208,196,185,175,165,156,147,139,131,123,117
  5072. ; Tuning -3
  5073.     dc.w    875,826,779,736,694,655,619,584,551,520,491,463
  5074.     dc.w    437,413,390,368,347,328,309,292,276,260,245,232
  5075.     dc.w    219,206,195,184,174,164,155,146,138,130,123,116
  5076. ;$Tuning -2
  5077.     dc.w    868,820,774,730,689,651,614,580,547,516,487,460
  5078.     dc.w    434,410,387,365,345,325,307,290,274,258,244,230
  5079.     dc.w    217,205,193,183,172,163,154,145,137,129,122,115
  5080. ; Tuning -1
  5081.     dc.w    862,814,768,725,684,646,610,575,543,513,484,457
  5082.     dc.w    431,407,384,363,342,323,305,288,272,256,242,228
  5083.     dc.w    216,203,192,181,171,161,152,144,136,128,121,114
  5084.  
  5085. mt_chan1temp    dc.l    0,0,0,0,0,$00010000,0,  0,0,0,0
  5086. mt_chan2temp    dc.l    0,0,0,0,0,$00020000,0,  0,0,0,0
  5087. mt_chan3temp    dc.l    0,0,0,0,0,$00040000,0,  0,0,0,0
  5088. mt_chan4temp    dc.l    0,0,0,0,0,$00080000,0,  0,0,0,0
  5089.  
  5090. mt_SampleStarts    dc.l    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  5091.         dc.l    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  5092.  
  5093. mt_SongDataPtr    dc.l 0
  5094. mt_speed    dc.b 6
  5095. mt_counter    dc.b 0
  5096. mt_SongPos    dc.b 0
  5097. mt_PBreakPos    dc.b 0
  5098. mt_PosJumpFlag    dc.b 0
  5099. mt_PBreakFlag    dc.b 0
  5100. mt_LowMask    dc.b 0
  5101. mt_PattDelTime    dc.b 0
  5102. mt_PattDelTime2    dc.b 0
  5103. mt_Enable    dc.b 0
  5104. mt_PatternPos    dc.w 0
  5105. mt_DMACONtemp    dc.w 0
  5106.  
  5107.  
  5108. ;******************* chip data ***************
  5109.  
  5110.  
  5111.     SECTION CHIP_DATA,DATA_C
  5112.  
  5113. copper_list
  5114.     dc.l    $01800000
  5115.  
  5116. scherm
  5117.     dc.l    $00e00000,$00e20000
  5118.     dc.l    $00e40000,$00e60000
  5119.     dc.l    $00e80000,$00ea0000
  5120.  
  5121.     dc.l    $008e2981,$0090f4c1
  5122.     dc.l    $0092003c,$009400d4
  5123.     dc.l    $0100b200,$01020000    
  5124.     dc.l    $01080000,$010a0000
  5125.  
  5126. c_pointer
  5127.     dc.l    $01200000,$01220000
  5128.     dc.l    $01240000,$01260000
  5129.  
  5130. c_vu_meters
  5131.     dc.l    $01280000,$012a0000
  5132.     dc.l    $012c0000,$012e0000
  5133.     dc.l    $01300000,$01320000
  5134.     dc.l    $01340000,$01360000
  5135.  
  5136. c_scrollbar
  5137.     dc.l    $01380000,$013a0000
  5138.  
  5139. c_other    
  5140.     dc.l    $013c0000,$013e0000
  5141.  
  5142.     dc.l    $4101fffe
  5143.     dc.l    $0100c200
  5144.  
  5145. bpl_4
  5146.     dc.l    $00ec0000,$00ee0000
  5147.  
  5148. track_wait
  5149.     blk.l    100,0
  5150.  
  5151.  
  5152. ;*********** buffers**************
  5153.  
  5154.     SECTION bitplanebuffers,BSS_C
  5155.  
  5156. tracks_bitplane
  5157.     ds.b    [[16+64]*8*80]
  5158.  
  5159. second_buf_scopes
  5160.     ds.b    [65*80]
  5161.  
  5162. third_buf_scopes
  5163.     ds.b    [65*80]
  5164.  
  5165. sample_info_buffer
  5166.     ds.b    [26*23*32]    ;32 buffers of 208x23 pixels.
  5167.  
  5168.     EVEN
  5169.  
  5170. dummy_bitplane
  5171.     ds.b    [80*11*8]    ;dummy bitplane for textwindow
  5172.  
  5173. ;************** gfx data *****************
  5174.  
  5175.     SECTION gfx,DATA_C
  5176.  
  5177. screen_picture
  5178.     incbin    "gfx/ptplay_screen.raw"
  5179.  
  5180. font
  5181.     incbin     "gfx/ptplay_font.raw"
  5182.  
  5183.     even
  5184.  
  5185. buttons_1_normal
  5186.     incbin "gfx/ptplay_buttons.raw"
  5187.  
  5188.     even
  5189.  
  5190. buttons_1_pressed
  5191.     incbin "gfx/ptplay_buttons_pressed.raw"
  5192.  
  5193.     even    
  5194.  
  5195. arrow_up_normal
  5196.     incbin    "gfx/ptplay_arrow_up_button.raw"
  5197.  
  5198.     even
  5199.  
  5200. arrow_up_pressed
  5201.     incbin    "gfx/ptplay_arrow_up_button_pressed"
  5202.  
  5203.     even
  5204.  
  5205. arrow_down_normal
  5206.     incbin    "gfx/ptplay_arrow_down_button.raw"
  5207.  
  5208.     even
  5209.  
  5210. arrow_down_pressed
  5211.     incbin    "gfx/ptplay_arrow_down_button_press"
  5212.  
  5213.     even
  5214.  
  5215. close_button_normal
  5216.     incbin    "gfx/ptplay_close_button.raw"
  5217.  
  5218.     even
  5219.  
  5220. arrow_button_mask
  5221.     blk.w    10,$fff8
  5222.  
  5223. close_button_pressed
  5224.     incbin    "gfx/ptplay_close_button_pressed.ra"
  5225.  
  5226.     even
  5227.  
  5228. vu_meter_1
  5229. vu1_xy        dc.w    $b74e
  5230. vu1_stop    dc.w    $b900    
  5231.     dc.w    $ff00,$0000,$ff00,$0100,$c300,$3f00,$c300,$3f00
  5232.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5233.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5234.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5235.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5236.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5237.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5238.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5239.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5240.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5241.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5242.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5243.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5244.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5245.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5246.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5247.     dc.w    $c300,$3f00
  5248.  
  5249.  
  5250. vu_meter_2
  5251. vu2_xy        dc.w    $b760
  5252. vu2_stop    dc.w    $b900    
  5253.     dc.w    $ff00,$0000,$ff00,$0100,$c300,$3f00,$c300,$3f00
  5254.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5255.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5256.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5257.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5258.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5259.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5260.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5261.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5262.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5263.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5264.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5265.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5266.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5267.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5268.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5269.     dc.w    $c300,$3f00
  5270.  
  5271.  
  5272. vu_meter_3
  5273. vu3_xy        dc.w    $b772
  5274. vu3_stop    dc.w    $b900    
  5275.     dc.w    $ff00,$0000,$ff00,$0100,$c300,$3f00,$c300,$3f00
  5276.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5277.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5278.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5279.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5280.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5281.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5282.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5283.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5284.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5285.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5286.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5287.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5288.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5289.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5290.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5291.     dc.w    $c300,$3f00
  5292.  
  5293.  
  5294. vu_meter_4
  5295. vu4_xy        dc.w    $b784
  5296. vu4_stop    dc.w    $b900    
  5297.     dc.w    $ff00,$0000,$ff00,$0100,$c300,$3f00,$c300,$3f00
  5298.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5299.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5300.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5301.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5302.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5303.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5304.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5305.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5306.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5307.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5308.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5309.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5310.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5311.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5312.     dc.w    $c300,$3f00,$c300,$3f00,$c300,$3f00,$c300,$3f00
  5313.     dc.w    $c300,$3f00
  5314.  
  5315. mouse_pointer
  5316. pointer_xy    dc.w    0
  5317. pointer_stop    dc.w    0    
  5318.     dc.w    $fc00,$0000,$8800,$7800,$9000,$7000,$a000,$6000
  5319.     dc.w    $c000,$4000,$8000,$0000,$0000,$0000
  5320.     dc.w    0,0
  5321.  
  5322.  
  5323. scrollbar_about
  5324. s_b_a_xy    dc.w    0
  5325. s_b_a_stop    dc.w    0
  5326.         blk.w    122,0
  5327.  
  5328. scrollbar_mod_text
  5329. s_b_m_t_xy    dc.w    0
  5330. s_b_m_t_stop    dc.w    0
  5331.         blk.w    122,0
  5332.         
  5333. scrollbar_uga_text
  5334. s_b_t_t_xy    dc.w    0
  5335. s_b_t_t_stop    dc.w    0
  5336.         blk.w    122,0
  5337.  
  5338. dummy_sprite
  5339.     dc.l    0
  5340.     dc.w    0,0,0,0
  5341.     dc.w    0,0
  5342.