home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI04.ARJ / ictari.04 / C / SOURCE.SEQ / SEQ_MC4.S < prev    next >
Text File  |  1997-09-17  |  19KB  |  726 lines

  1. ***********************************************************************
  2. *                                                                     *
  3. *                     STE Sample Music 25                             *
  4. *                                                                     *
  5. *                   by © Ian Hancock, August 1992                     *
  6. *                                                                     *
  7. ***********************************************************************
  8.     CSECT    name,code
  9.     XDEF        _Volume_tone,_Click,_TEST,_DELETE,_SIGN_IT
  10.     XDEF        _RECORD,_PLAY,_Vbl_Remove,_EDIT,_MERGE_BUFFER,_STOP
  11.  
  12. * system equates
  13.  
  14. gemdos        equ    $01
  15. print_line    equ    $09
  16. super        equ    $20
  17. gettime        equ    $2C
  18. vbl_queue        equ    $456
  19.  
  20. snd_cntl_DMA        equ    $FF8901
  21. snd_start_hi_DMA    equ    $FF8903
  22. snd_start_mid_DMA    equ    $FF8905
  23. snd_start_lo_DMA    equ    $FF8907
  24. snd_end_hi_DMA        equ    $FF890F
  25. snd_end_mid_DMA    equ    $FF8911
  26. snd_end_lo_DMA        equ    $FF8913
  27. snd_mode_DMA        equ    $FF8921
  28.  
  29. voltone_mask        equ    $ff8924
  30. voltone_data        equ    $ff8922
  31.  
  32. * main program
  33.  
  34. start
  35.     move.l    4(sp),sample_start
  36.     move.l    8(sp),sample_length
  37.     move.l    12(sp),type
  38.     move.b    19(sp),playmode
  39.     move.b    23(sp),frequency
  40.     move.b    27(sp),stereo_mono
  41. play_sample    
  42.     movem.l    d0-d7/a0-a6,-(sp)
  43.  
  44.     move.b    (supermode),d7
  45.     cmpi.b    #$ff,d7
  46.     beq        superon
  47.     
  48. * enter supervisor mode
  49.     clr.l    -(SP)
  50.     move.w    #super,-(SP)
  51.     trap        #gemdos
  52.     addq.l    #$06,SP
  53.     move.l    D0,-(SP)
  54. superon
  55. * do it
  56.     move.l    sample_start,D0
  57.     add.l    sample_length,D0
  58.     move.l    D0,sample_end
  59.  
  60. * write to sound DMA hardware
  61.     clr.b    snd_cntl_DMA
  62.  
  63. * set  sampling freq and stereo/mono
  64.     move.b    stereo_mono,d0
  65.     lsl.b    #$7,d0
  66.     or.b        frequency,d0
  67.     move.b    d0,snd_mode_DMA
  68.  
  69. * set start sample location
  70.     move.l    sample_start,D0
  71.     move.b    D0,snd_start_lo_DMA
  72.     lsr.l    #$08,D0
  73.     move.b    D0,snd_start_mid_DMA
  74.     lsr.l    #$08,D0
  75.     move.b    D0,snd_start_hi_DMA
  76.  
  77. * set end sample location
  78.     move.l    sample_end,D0
  79.     move.b    D0,snd_end_lo_DMA
  80.     lsr.l    #$08,D0
  81.     move.b    D0,snd_end_mid_DMA
  82.     lsr.l    #$08,D0
  83.     move.b    D0,snd_end_hi_DMA
  84.  
  85. * start DMA sound, repeating at end
  86.     move.b    playmode,snd_cntl_DMA
  87.  
  88. * abort sampling
  89. abort_samples
  90.     cmpi.b    #$ff,d7
  91.     beq        superoff
  92.     
  93. * exit supervisor mode
  94.     move.w    #super,-(SP)
  95.     trap        #gemdos
  96.     addq.w    #$06,SP
  97. superoff
  98.  
  99.     movem.l    (sp)+,d0-d7/a0-a6
  100.     rts
  101.  
  102. *************************************************************************
  103. * convert 2 Bit System Replay samples into STE format
  104. _SIGN_IT
  105.     move.l    4(sp),(sample_start)    *send passed params to memory variables
  106.  
  107.     move.l    (sample_start),A0
  108.     move.w    #$ffff,16(a0)            *write signed to header
  109.     move.l    26(a0),(sample_length)    *offsets from a0 for AVR header
  110.     add.l    #128,a0
  111.     
  112.     move.l    a0,D0
  113.     add.l    (sample_length),D0
  114.     move.l    D0,sample_end
  115.     
  116. convert_sample
  117.     move.b    (A0),D0
  118.     sub.b    #$80,D0
  119.     move.b    D0,(A0)+
  120.     cmp.l    sample_end,A0
  121.     bne.s    convert_sample
  122.  
  123.     rts
  124.  
  125. *************************************************************************
  126. _STOP
  127. * enter supervisor mode
  128.     clr.l    -(SP)
  129.     move.w    #super,-(SP)
  130.     trap        #gemdos
  131.     addq.l    #$06,SP
  132.     move.l    D0,-(SP)
  133.  
  134. * set DMA sound, stop
  135.     move.b    #0,snd_cntl_DMA
  136.  
  137. * exit supervisor mode
  138.     move.w    #super,-(SP)
  139.     trap        #gemdos
  140.     addq.w    #$06,SP
  141.  
  142.     rts
  143.  
  144. *************************************************************************
  145.  
  146. *Install V_blank counter for RECORD
  147.  
  148. Vbl_Install
  149.     move.l    4(sp),d0        *get stack passed param
  150.     move.l    d2,-(sp)        *store d2
  151.     move.l    d0,d2        *put it in d2
  152.  
  153. * enter super
  154.     clr.l    -(SP)
  155.     move.w    #super,-(SP)
  156.     trap        #gemdos
  157.     addq.l    #$06,SP
  158.     move.l    D0,-(SP)
  159.  
  160. * find a space in queue
  161.     move.l    vbl_queue,a0
  162.     move.w    #7,d0
  163.     
  164. find_entry
  165.     tst.l    (a0)+
  166.     beq.s    entry_found
  167.     dbra        d0,find_entry
  168.     bra.s    quit
  169.     
  170. entry_found
  171.     lea        vbl_RECORD(pc),a1
  172.  
  173.     cmpi.l    #0,d2            *if 0 install vbl_record
  174.     beq        rec
  175.                             *else install vbl_edit
  176.     lea        vbl_EDIT(pc),a1
  177.  
  178. rec    move.l    a1,-(a0)            *put address from a1 in list
  179.     move.l    a0,(vbl_current)    *remember position in list
  180.  
  181. quit    
  182. * exit supervisor mode
  183.     move.w    #super,-(SP)
  184.     trap        #gemdos
  185.     addq.w    #$06,SP
  186.  
  187.     move.l    (sp)+,d2        *restore d2
  188.     rts
  189. *************************************************************************
  190. *Remove current vbl
  191. _Vbl_Remove
  192.  
  193. * enter super
  194.     clr.l    -(SP)
  195.     move.w    #super,-(SP)
  196.     trap        #gemdos
  197.     addq.l    #$06,SP
  198.     move.l    D0,-(SP)
  199.  
  200.     move.l    (vbl_current),a1    *removes last vbl installed
  201.     move.l    #0,(a1)            *by my prog. puts 0 in list
  202.         
  203. * exit supervisor mode
  204.     move.w    #super,-(SP)
  205.     trap        #gemdos
  206.     addq.w    #$06,SP
  207.  
  208.     rts
  209.  
  210. *************************************************************************
  211. *Record interupt
  212. vbl_RECORD
  213.     move.w    (time),d1    *adds 1 to the timer
  214.     addq.w    #1,d1
  215.     move.w    d1,(time)
  216.     
  217.     cmpi.w    #$ffff,d1
  218.     beq        out_of_time *checks to make sure we ain't out a time
  219.     
  220.     rts
  221.     
  222. out_of_time
  223.     move.l    #1,(error)
  224.     rts
  225. *************************************************************************
  226. * vbl routine II for edit and playback
  227. vbl_EDIT
  228.     move.w    (time),d0        *put time in d0
  229.     addq.w    #1,d0        *add 1
  230.     move.w    d0,(time)        *replace new time
  231.     
  232.     cmpi.w    #$ffff,d0
  233.     beq        out_of_time    *check we isn't out of time
  234.     
  235.     move.w    (memo),d1
  236.     cmp.w    d0,d1        *if elapse time is reached
  237.     bls        next_samp        *get next sample
  238.     rts
  239.     
  240. next_samp
  241.     move.l    (sequence2),a0        *get current seq. addr.
  242.     add.l    #4,a0            *increment by a long word
  243.     move.l    a0,(sequence2)        *replace new position
  244.     move.w    (a0),(memo)        *set new elapse time
  245.     move.w    2(a0),d0            *put sample no in d0
  246.  
  247.     move.b    #$ff,(supermode)    *set super ok flag
  248.  
  249.     jsr        get_samp            *load samp. data and play it
  250.  
  251.     move.b    #0,(supermode)        *reset super ok flag to normal
  252.  
  253.     cmpi.b    #1,(editon)        *if 1 then we are editing
  254.     beq        yep
  255.     move.l    (finish),a0        *play finished
  256.     add.l    #1,(a0)
  257.  
  258. yep
  259.     cmpi.w    #$ffff,(memo)        *if = ffff
  260.     beq        finishedit        *then seq finished
  261.     rts
  262.  
  263. finishedit
  264.     move.l    (vbl_current),a1    * vbl EDIT list pos. to a1
  265.     
  266.     cmpi.b    #0,(editon)        *if 1 then we are editing
  267.     beq        nope
  268.  
  269.     lea        vbl_RECORD(pc),a0    *start rec interupt
  270.     move.l    a0,(a1)            *put address from a1 in list
  271.     rts
  272.     
  273. nope    
  274.     move.l    #0,(a1)            *de-install by putting 0 in list
  275.  
  276.     cmp.b    #3,snd_cntl_DMA
  277.     bne        not_loopy
  278.     
  279.     move.b    #0,snd_cntl_DMA
  280.     
  281. not_loopy
  282.     move.l    (finish),a0        *play finished
  283.     move.l    #0,(a0)
  284.     rts    
  285. *************************************************************************
  286. _PLAY
  287. *init sequencing
  288. * set up play params
  289.     move.l    4(sp),(sam_start)    *send passed params to memory variables
  290.     move.l    8(sp),(sequence2)
  291.     move.l    12(sp),(seq_bytes)
  292.     move.l    16(sp),(finish)
  293.     
  294.     move.b    #0,(editon)        *not editing
  295.     
  296.     move.l    (sequence2),a0
  297.     move.w    (a0),d0            *get first elapse time in d0
  298.     move.w    d0,(memo)            *put first elapse time in memo
  299.     subq.w    #1,d0            *put actual timer 1 count behind elapse
  300.     move.w    d0,(time)            *store in timer
  301.     
  302. * go (install the interupt)
  303.     move.l    #1,-(sp)            *pass 1 via stack to install
  304.     jsr        Vbl_Install        *EDIT vbl II
  305.     addq.l    #4,sp            *stack correction
  306. * it auto de-stalls
  307.     rts
  308.  
  309. *************************************************************************
  310. _RECORD
  311. *recording mode
  312. *init sequencing
  313.     move.l    4(sp),(sam_start)    *put passed params in memory
  314.     move.l    8(sp),(items)
  315.     move.l    12(sp),(sequence)
  316.     move.l    16(sp),(seq_bytes)
  317.     move.l    20(sp),(dubbing)
  318.     
  319.     move.l    (sequence),d0        *finds max end address of seq
  320.     add.l    (seq_bytes),d0        *less 16 safety margin
  321.     sub.l    #16,d0
  322.     move.l    d0,(seq_bytes)        *stores it back in seq-Bytes
  323.     move.l    #0,(error)        *clear error flag
  324.     
  325.     move.l    #0,-(sp)        *use stack to pass value to Vbl_Install
  326.     jsr        Vbl_Install    * recording interupt to be used =0
  327.     addq.l    #4,sp        *stack correction
  328.     
  329. *recording mode
  330.     move.l    d2,-(sp)                *store d2
  331.     
  332.     move.l    (sequence),(sequence2)    *put seq. start address in current.
  333.     move.w    #0,(time)
  334.  
  335.     cmpi.l    #0,(dubbing)    *if none zero then recording
  336.     bne        nodub
  337.     
  338.     move.l    (sequence),a0    * put sequence address in a0
  339.     move.w    #$ffff,(a0)    * in case it is last sample
  340.     subq.l    #4,a0        * go back to previous time
  341.  
  342.     cmpi.w    #$ffff,(a0)    *check to see if out a time
  343.     bne        leave_it_out    
  344.     move.l    #1,(error)    *better stop now
  345. leave_it_out                *it's ok carry on
  346.  
  347.     move.w    (a0)+,(time)    * put time in time variable
  348.     addq.l    #4,a0        * go forward to get prev sample
  349.     move.w    (a0),d0        * put sample no in d0
  350.     
  351.     jsr        get_samp       *load sample info and play it
  352. nodub
  353.  
  354. another        *do it again until a none sample key is pressed
  355. * wait for key
  356.     move.w    #2,-(sp)
  357.     move.w    #2,-(sp)
  358.     trap        #13
  359.     addq.l    #4,sp
  360.     move.w    (time),d1    * store time from record interupt in d1
  361.     
  362. * check error flag for time out.
  363.     cmpi.l    #1,(error)
  364.     beq        stop
  365.     
  366. * check input    
  367.     swap        d0            *put scancode in low word
  368.     cmp.w    #$63,d0        *compare with code for '(' on numeric
  369.     blo        stop            *if less then not a sample
  370.     move.l    (items),d2    *put no. of samps-1 in d2
  371.     add.w    #$63,d2        *add scancode for '(' to it
  372.     cmp.w    d2,d0        *compare keypressed with last key owning samp
  373.     bhi        stop            *if higher then not a sample
  374.     sub.w    #99,d0        *make keypress into sample no. (0-x)
  375.  
  376. * its all cool
  377. * get sample info
  378.     jsr        get_samp       *load sample info and play it
  379.  
  380.     move.l    (sequence2),a1        *get current seq. addr. in a1
  381.     move.w    d1,(a1)+            *put time in it
  382.     addq.l    #4,a1            *add a long word
  383.     move.w    d0,(a1)            *put sample no. in
  384.     subq.l    #2,a1            *go back a word
  385.     move.l    a1,(sequence2)        *store new current seq. addr.
  386.     move.w    #$ffff,(a1)        *put a one in it incase it is last samp
  387.     move.w    d1,(time)        *reset timer incase its incremented?!
  388.     cmp.l    (seq_bytes),a1
  389.     blo        another
  390.     move.l    #2,(error)
  391.  
  392. stop
  393.     move.l    (sequence2),a1        *store ffffffff after last sample in seq
  394.     addq.l    #4,a1
  395.     move.l    #$ffffffff,(a1)+
  396.     move.l    a1,songend        *put end of sequence addr. in songend
  397.     move.l    (sp)+,d2            *restore d2
  398.     jsr        _Vbl_Remove        *remove record interupt
  399.     move.l    (error),d0        *return error code
  400.     rts
  401.  
  402. *************************************************************************
  403. _TEST
  404. *testing mode
  405. *init sequencing
  406.     move.l    4(sp),(sam_start)    *put passed params in memory
  407.     move.l    8(sp),(items)
  408.     
  409. *test mode
  410.     move.l    d2,-(sp)                *store d2
  411.  
  412. test_another    *do it again until a none sample key is pressed
  413. * wait for key
  414.     move.w    #2,-(sp)
  415.     move.w    #2,-(sp)
  416.     trap        #13
  417.     addq.l    #4,sp
  418.  
  419. * check input    
  420.     swap        d0            *put scancode in low word
  421.     cmp.w    #$63,d0        *compare with code for '(' on numeric
  422.     blo        stop_test        *if less then not a sample
  423.     move.l    (items),d2    *put no. of samps-1 in d2
  424.     add.w    #$63,d2        *add scancode for '(' to it
  425.     cmp.w    d2,d0        *compare keypressed with last key owning samp
  426.     bhi        stop_test        *if higher then not a sample
  427.     sub.w    #99,d0        *make keypress into sample no. (0-x)
  428.  
  429. * its all cool
  430. * get sample info
  431.     jsr        get_samp       *load sample info and play it
  432.     jmp        test_another    * repeat until none samp key pressed
  433.  
  434. stop_test
  435.     move.l    (sp)+,d2            *restore d2
  436.  
  437.     rts
  438. **************************************************************************
  439. _EDIT
  440. *recording mode
  441. *init sequencing
  442.     move.l    4(sp),(sam_start)    *put passed params in memory
  443.     move.l    8(sp),(items)
  444.     move.l    12(sp),(sequence2)
  445.     move.l    16(sp),(seq_bytes)
  446.     move.l    20(sp),(bufferedit)
  447.     
  448.     move.l    (bufferedit),d0    *finds max end address of buffer
  449.     add.l    (seq_bytes),d0        *plus 16 safety margin
  450.     sub.l    #16,d0
  451.     move.l    d0,(seq_bytes)        *stores it back in seq-Bytes
  452.     move.l    #0,(error)        *clear error flag
  453.  
  454.     move.b    #1,(editon)
  455.     
  456.     move.l    (bufferedit),(bufstart)
  457.     move.l    (sequence2),a0
  458.     move.w    (a0),d0            *get first elapse time in d0
  459.     move.w    d0,(memo)            *put first elapse time in memo
  460.     subq.w    #1,d0            *put actual timer 1 count behind elapse
  461.     move.w    d0,(time)            *store in timer
  462.  
  463.     cmpi.w    #$ffff,d0        *check to see if out a time
  464.     bne        leave_it_out2    
  465.     move.l    #1,(error)    *better stop now
  466. leave_it_out2                *it's ok carry on
  467.  
  468. * go (install the interupt)
  469.     move.l    #1,-(sp)            *pass 1 via stack to install
  470.     jsr        Vbl_Install        *EDIT vbl II
  471.     addq.l    #4,sp            *stack correction
  472.  
  473. *editing mode
  474.     move.l    d2,-(sp)                *store d2
  475.  
  476. another2        *do it again until a none sample key is pressed
  477. * wait for key
  478.     move.w    #2,-(sp)
  479.     move.w    #2,-(sp)
  480.     trap        #13
  481.     addq.l    #4,sp
  482.     move.w    (time),d1    * store time from edit interupt in d1
  483.  
  484. * check error flag for time out.
  485.     cmpi.l    #1,(error)
  486.     beq        stop2
  487.  
  488. * check input    
  489.     swap        d0            *put scancode in low word
  490.     cmp.w    #$63,d0        *compare with code for '(' on numeric
  491.     blo        stop2        *if less then not a sample
  492.     move.l    (items),d2    *put no. of samps-1 in d2
  493.     add.w    #$63,d2        *add scancode for '(' to it
  494.     cmp.w    d2,d0        *compare keypressed with last key owning samp
  495.     bhi        stop2        *if higher then not a sample
  496.     sub.w    #99,d0        *make keypress into sample no. (0-x)
  497.  
  498. * its all cool
  499. * get sample info
  500.     jsr        get_samp       *load sample info and play it
  501.  
  502.     move.l    (bufferedit),a1    *get current buf. addr. in a1
  503.     move.w    d1,(a1)+            *put time in it
  504.     move.w    d0,(a1)+            *put sample no. in
  505.     move.l    a1,(bufferedit)    *store new current seq. addr.
  506.     cmp.l    (seq_bytes),a1
  507.     blo        another2            * repeat until none samp key pressed
  508.     move.l    #2,(error)
  509.  
  510. stop2
  511.     move.l    (bufferedit),a1    *store ffffffff after last sample in seq
  512.     move.l    #$ffffffff,(a1)+
  513.     move.l    (sp)+,d2            *restore d2
  514.     jsr        _Vbl_Remove        *remove record interupt
  515.     move.l    (error),d0        *return error code
  516.  
  517.     rts
  518. *************************************************************************
  519. _DELETE
  520. *remove current sample
  521.     move.l    4(sp),a0        *get position address in sequence
  522.     
  523.     move.w    4(a0),(a0)    *shift next time to current time
  524. del_loop
  525.     addq.l    #4,a0        *move to next item
  526.     move.l    4(a0),(a0)    *copy item to previous slot
  527.     cmpi.l    #$ffffffff,(a0)    *is it last item
  528.     bne        del_loop        * no then loop
  529.  
  530.     rts
  531.  
  532. *************************************************************************
  533. _MERGE_BUFFER
  534. *put passed params in memory
  535.     move.l    4(sp),(sequence)
  536.     move.l    8(sp),(seq_bytes)
  537.     move.l    12(sp),(bufferedit)
  538.     
  539.     move.l    (sequence),d0        *finds max end address of seq
  540.     add.l    (seq_bytes),d0        *plus 16 safety margin
  541.     sub.l    #16,d0
  542.     move.l    d0,(seq_bytes)        *stores it back in seq-Bytes
  543.     move.l    #0,(error)        *clear error flag
  544.  
  545.     move.l    (sequence),(sequence2)    *store sequence address in seq2
  546.     move.l    (sequence),a0        *move address to a0
  547.     move.l    (bufferedit),a1    *put buffer address in a1
  548.     
  549. mergeloop
  550.     move.w    (a1),d0        *put 1st merge item time in d0
  551.     cmpi.w    #$ffff,d0        *is it last item
  552.     beq        endmerge        *yes then end
  553.     
  554. find_place
  555.     cmp.w    (a0),d0    *compare merge time with time in sequence
  556.     bls        insert    *if lower or same then insert
  557.     addq.l    #4,a0    *go to next item time in sequence
  558.     jmp        find_place    *loop
  559.     
  560. insert
  561.     move.l    a0,d1    *move address of item in seq. to d0
  562.  
  563. find_end
  564.     cmpi.l    #$ffffffff,(a0)+    *is item last item & inc
  565.     bne        find_end            *no then loop
  566.  
  567.     addq.l    #4,a0        *inc seq one item past end
  568.     cmp.l    (seq_bytes),a0
  569.     blo        shuffle
  570.     move.l    #1,(error)
  571.     jmp        endmerge
  572.     
  573. shuffle
  574.     subq.l    #8,a0        *dec by 2 items seq
  575.     move.l    (a0)+,(a0)    *copy from current to next item
  576.     cmp.l    d1,a0        *keep counting down till we hit the 
  577.     bne        shuffle        *address of the insert item
  578.  
  579.     move.w    (a1)+,(a0)+    *insert the item
  580.     move.w    4(a0),(a0)
  581.     move.w    (a1)+,4(a0)
  582.     subq.w    #2,a0
  583.     jmp        mergeloop        *keep merging till all are merged
  584. endmerge
  585.     move.l    (error),d0    *return error code
  586.     rts
  587.  
  588. *************************************************************************
  589. * sort AVR info for sample to memory variables then call play sample.
  590. * d0 carries samp no.
  591. get_samp
  592.     move.l    (sam_start),a0        *get address of list
  593.     and.l    #$ffff,d0            *mask high word
  594.     lsl.l    #2,d0            * x4 for offset
  595.     add.l    d0,a0            *add offset to get address from list
  596.     lsr.l    #2,d0            * /2 return to original value
  597.     move.l    (a0),a0            *put samp. start address in a0
  598.  
  599. * get length
  600.     move.l    26(a0),(sample_length)    *offsets from a0 for AVR header
  601.     
  602. * get stereo or mono (0=mono and ffff= stereo. in playback s=0 and m=1)
  603.     move.w    12(a0),d2
  604.     move.b    #1,(stereo_mono)
  605.     cmpi.w    #0,d2
  606.     beq        mono
  607.     move.b    #0,(stereo_mono)
  608. mono    
  609.  
  610. * get unsigned or signed (un=0 and sn=ffff. in play un=1 and sn=0)
  611.     move.w    16(a0),d2
  612.     move.b    #1,(type)
  613.     cmpi.w    #0,d2
  614.     beq        unsigned
  615.     move.b    #0,(type)
  616. unsigned
  617.  
  618. * get loopy. (0=no and ffff=yes. in play 1=no and 3=yes)
  619.     move.w    18(a0),d2
  620.     move.b    #1,(playmode)
  621.     cmpi.w    #0,d2
  622.     beq        noloop
  623.     move.b    #3,(playmode)
  624. noloop
  625.  
  626. * get frequency (25600= 25.6khz in play = 2)
  627.     move.l    22(a0),d2
  628.     move.b    #3,(frequency)
  629.     cmp.w    #$c800,d2
  630.     beq        got_it
  631.     move.b    #2,(frequency)
  632.     cmp.w    #$6400,d2
  633.     beq        got_it
  634.     move.b    #1,(frequency)
  635.     cmp.w    #$30fa,d2
  636.     beq        got_it
  637.     move.b    #0,(frequency)
  638. got_it
  639.  
  640.     add.l    #128,a0        *set a0 past AVR header (raw sample follows)
  641.     move.l    a0,(sample_start)    * set start address
  642.     
  643.     jsr        play_sample        * do it
  644.     rts
  645. *************************************************************************
  646. _Volume_tone    
  647.     move.l    4(sp),d0        *get value to send to VTC
  648.     move.l    d2,-(sp)        *store d2
  649.     move.l    d0,d2        *use d2 because of supervisor
  650.  
  651. * enter super
  652.     clr.l    -(SP)
  653.     move.w    #super,-(SP)
  654.     trap        #gemdos
  655.     addq.l    #$06,SP
  656.     move.l    D0,-(SP)
  657.  
  658.     move.l    #$07ff,voltone_mask        *send data to VTC
  659.     or.l        #$400,d2
  660.     move.l    d2,voltone_data
  661.  
  662. * exit supervisor mode
  663.     move.w    #super,-(SP)
  664.     trap        #gemdos
  665.     addq.w    #$06,SP
  666.  
  667.     move.l    (sp)+,d2        *restore d2
  668.     rts
  669. *************************************************************************
  670. _Click
  671.     move.l    4(sp),d0        *get passed value from stack to d0
  672.                         *0=keyclick off,7=keyclick on
  673.     move.l    d2,-(sp)        *store d2
  674.     move.l    d0,d2        *use d2 because super wipes d0-d1,a0-a1
  675.  
  676. * enter super
  677.     clr.l    -(SP)
  678.     move.w    #super,-(SP)
  679.     trap        #gemdos
  680.     addq.l    #$06,SP
  681.     move.l    D0,-(SP)
  682.  
  683.     move.b    d2,$484        *set keyboard variable
  684.     
  685. * exit supervisor mode
  686.     move.w    #super,-(SP)
  687.     trap        #gemdos
  688.     addq.w    #$06,SP
  689.  
  690.     move.l    (sp)+,d2        *restore d2
  691.     rts
  692. *************************************************************************
  693.  
  694. * program equates
  695.  
  696.     cnop    0,2
  697.  
  698. sam_start        ds.l    $01    *address of (list containing sample st. address')
  699. items        ds.l    $01    *number of samples stored (-1) ie. 0= 1 sample
  700. sequence        ds.l    $01    *address of start of sequence memory
  701. sequence2        ds.l    $01    *current address in seq. either play or record
  702. bufferedit    ds.l    $01  *editing buffer address
  703. bufstart        ds.l    $01  *start of edit buffer address
  704. seq_bytes        ds.l    $01    *number of bytes available in seq. memory
  705. songend        ds.l    $01    *end address of song
  706. vbl_current    ds.l    $01    *address in vbl queue of last addition to the list
  707. time            ds.l    $01    *counter used by interupts
  708. memo            ds.l    $01    *next time elapse memory.
  709. finish        ds.l    $01  *holds address of finish variable
  710. dubbing        ds.l    $01    *0 if dubbing and 1 if record
  711. error        ds.l    $01    *0 if no probs, 1 if out of memory
  712.     
  713. * variables for sample playback
  714. sample_length    ds.l    $01    *obvious
  715. sample_end    ds.l    $01    * "
  716. sample_start    ds.l    $01    * "
  717. playmode        ds.l    $01    *0=off,1=once,3=looped
  718. type            ds.l    $01    *0=signed,1=unsigned
  719. frequency        ds.l    $01    *0=6khz,1=12khz,2=25khz,3=51khz
  720. stereo_mono    ds.l    $01    *1/0 for mono or stereo
  721.  
  722. * super mode set to 0 when in user and ff super.
  723. supermode        ds.b    $01    *used because edit vbl is already in super
  724. editon        ds.b    $01    *=0 if play mode / =1 if editing
  725.     end    
  726.