home *** CD-ROM | disk | FTP | other *** search
/ Dave Lowe: AssemPro For Development Amiga Driver / Lowe_AssemProForDevelopmentAmigaDriver.adf / Empty / amdriver.asm < prev    next >
Encoding:
Assembly Source File  |  1987-06-04  |  8.7 KB  |  382 lines

  1.  
  2. ;    notetable
  3.  
  4. a02    equ   508
  5. Bb02   equ   480
  6. b02    equ   453
  7. c02    equ   428
  8. Db02   equ   404
  9. d02    equ   381
  10. eb02   equ   360
  11. e02    equ   339
  12. f02    equ   320
  13. gb02   equ   302
  14. g02    equ   285
  15.  
  16. a01    equ   254
  17. Bb01   equ   240
  18. b01    equ   226
  19. c01    equ   214
  20. Db01   equ   202
  21. d01    equ   190
  22. eb01   equ   180
  23. e01    equ   170
  24. f01    equ   160
  25. gb01   equ   151
  26. g01    equ   143
  27.  
  28.  
  29.  
  30. chann1reg      equ  $dff0a0       ;start of ch1 registers
  31. dmacon         equ  $dff096
  32. int_bf_int     equ     $dff01e
  33. int_bf_w       equ     $dff09a
  34. in_line        equ     0
  35. new_snd        equ     4
  36. sreset          equ     1
  37.  
  38. end_patt       equ     8
  39. cr             equ     16
  40.  
  41.  
  42.                move.w #1,d1
  43.                move.w #1,d0
  44.                btst d1,d0
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. ;     a0 points to channel vars
  53. ;     a1 reads  patt data/song data/envelope data
  54. ;     a2 points to ch reg locations
  55. ;     d0 used as general purpose register
  56. ;     d1 holds bits set for dma control reg
  57.  
  58.  
  59.  
  60.  
  61.  
  62. testloop:      jsr driver
  63.                jsr delay
  64.                bra  testloop
  65.  
  66. tstop:          nop
  67.                nop
  68.                nop
  69.                nop
  70.  
  71.  
  72.  
  73.  
  74.  
  75. delay:
  76. ddd:               move.w $dff006,d0
  77. ;               andi.w #%0000000011111111,d0
  78. ;               cmpi #0,d0
  79. ;               bne ddd
  80. ;                rts
  81.  
  82.  
  83.  
  84.  
  85.  
  86.                move.l #$08ff,d7
  87. delloop:       subq.l #$1,d7
  88.                cmpi.l #50,d7
  89.                bls findel
  90.                bra delloop
  91. findel:        rts
  92.  
  93. driver:
  94.       lea ch1vars,a0
  95.       lea chann1reg,a2
  96.       move.w #%1000001000000001,d1  ; enable ch 1
  97.       move.w #%0000000000000000,d2
  98.  
  99. ;        *****************************
  100. ;  this section checks channel current status
  101.  
  102. sect1:
  103.                cmpi.w #0,(a0)        ; for test disable
  104.                beq sect1_j1
  105.                rts
  106. sect1_j1       cmpi.w #0,2(a0)      
  107.   ;counter at zero
  108.                beq sect3             ; get new note
  109.                cmpi.w #1,2(a0)
  110.                beq sect4
  111.  
  112.                cmpi.w #3,4(a0)        ;is it looped data
  113.                bhs sect2              ;branch if one shot
  114.         ; data is looped data
  115. mode_switch:   subq #1,2(a0)          ;decrease counter
  116.                move.l 18(a0),a1        ;envelope data needed ?
  117.                cmpi.w #255,(a1)
  118.                beq env_finished
  119.                move.w (a1)+,8(a2)     ;send vol data
  120.                move.l a1,18(a0)       ;store pointer
  121. env_finished:  rts                    ; finish
  122.  
  123. ;         *****************************
  124. ; this section  sends the one shot
  125. ; data in the vars buffer and sets 4(a0) to 3
  126. ; when flag is 3 the program sends the loop data to the reg and sets
  127. ; the flag to 4
  128. ; when the flag is 4 it checks the block finished interrupt and when
  129. ; set it sets the flag to 1 and jumps to mode_switch where the loop
  130. ; data is processed normally
  131. ;
  132.  
  133. ;      flag must be 3 or 4
  134. sect2:
  135.                cmpi.w #4,4(a0)
  136.                beq part3        ;to check for block finished
  137.                bra part2        ;flag is 3,send loop data
  138. ;    part 1 send one shot data to chip
  139. one_shot_note: move.w  #3,4(a0)         ;set flag
  140.                move.l 38(a0),(a2)
  141.                move.w 42(a0),4(a2)
  142.                move.w #64,8(a2)
  143.                move.w d1,dmacon         ;start dma
  144.                rts
  145. ;    part 2 send loop data to chip
  146.  ;  move loop  data into register  from vars store
  147. part2:                                                  
  148.                move.l 44(a0),(a2)
  149.                move.w 48(a0),4(a2)
  150.                subq #1,2(a0)           ;decrease count
  151.                move.w #4,4(a0)
  152.                rts
  153.  
  154.  
  155. part3:   ;      move.w 8(a0),d0
  156. ;               and.w  int_bf_int,d0
  157. ;               cmpi #0,d0
  158. ;               bne block_done
  159.                                   ;  block still playing
  160.                subq #1,2(a0)      ;dec count
  161.                rts
  162.  
  163.  
  164. block_done:    move.w #1,4(a0)   ;   flag to loop
  165.                rts
  166.  
  167.  
  168.  
  169. ;          *****************************
  170.  
  171. ; this section gets new note data
  172.  
  173. sect3:
  174. ;               move.w 8(a0),d0
  175. ;               move.w d0,int_bf_w
  176.  
  177.                move.l 22(a0),a1     ;get patt pointer
  178. control_ret:   move.w (a1)+,d0       ;next data to d0/pointer inc
  179.                cmpi.w #100,d0         ;control marker
  180.                bls  sect5            ;effects flags
  181.        ;d1 holds next note pitch
  182.                move.w d0,12(a0)     ;store in curr pitch
  183.               move.w d0,6(a2)      ;pitch to reg
  184.                move.w (a1)+,2(a0)   ;store count
  185.                subq.w #1,2(a0)      ;and decrease
  186.                move.l a1,22(a0)     ;store patt pointer
  187.                move.l 34(a0),18(a0) ; reset env pointer
  188. ;               move.w #64,8(a2)
  189.  
  190.                cmpi.w #0,4(a0)
  191.                beq do_loop
  192.                bra one_shot_note              ;jump there
  193.  
  194.  ;     loop data trigger
  195. do_loop:       move.w d1,dmacon     ;start dma for current channel
  196.                rts
  197.  
  198.  
  199.       ;      ***********************************
  200. sect4:
  201.                cmpi.w #0,4(a0)
  202.                beq noof
  203.                move.w #%0000000000000001,dmacon     ;dma off
  204. noof:          subq.w #1,2(a0)
  205.                rts
  206.  
  207.       ;      ***********************************
  208.       ;  effects flags  d0 holds jump offset
  209. sect5:          move.l #jump_table,a3
  210.                 move.l (a3,d0),a4
  211.                 jmp (a4)
  212.  
  213.  
  214. jump_table:     defl   in_line_data
  215.                 defl   nsound
  216.                 defl   patt_end
  217.                 nop
  218.                 nop
  219. in_line_data:
  220. ;             data format = reg offset,data,etc....,end_data
  221.                nop
  222.                rts
  223.  
  224.  
  225.  
  226. nsound:        move.l (a1)+,a3          ;sound address to a3
  227.                cmpi.w #0,(a3)
  228.                bne one_shot_sound
  229.                move.w (a3)+,4(a0)       ;loop or one shot flag
  230.                move.l (a3)+,(a2)          ;data address
  231.                move.w (a3),4(a2)       ;length
  232.                jmp control_ret
  233.  
  234. one_shot_sound:
  235.                move.w (a3)+,4(a0)
  236.                move.l (a3)+,38(a0)     ;store
  237.                move.l (a3)+,42(a0)
  238.                move.l (a3),46(a0)
  239.                jmp control_ret
  240.  
  241. patt_end:
  242. ;      get next patt address from song part
  243.                move.l 26(a0),a1        ;song pos to a1
  244. song_cont_ret:  cmpi.l #0,(a1)          ;song marker ??
  245.                beq song_control
  246.                addq.l  #4,a1
  247.                move.l a1,26(a0)        ;store song pointer
  248.                move.l (a1),a1          ;patt address to a1
  249.                jmp control_ret
  250.  
  251.  
  252. song_control:
  253. ;    reset song to start
  254.                 addq.l #4,a1
  255.                 cmpi.l #255,(a1)
  256.                 beq tstop
  257.                 move.l 30(a0),a1
  258.                 bra song_cont_ret
  259.  
  260.  
  261.  
  262.  
  263. ch1vars         defw 0         ; test disable           +0
  264.                 defw 0         ; interrupt counter      +2
  265.                 defw 0         ; 1 = loop/one shot mode flag +4
  266.                 defw 0         ; current pitch          + 6
  267.  
  268.                 defw %0000000010000000        ;bit number for int read
  269.                 defw 0        ;
  270.                 defw 0        ;
  271.                 defw 0        ;
  272.                 defw 0        ;
  273.  
  274.                 defl env1     ; env pointer            +18
  275.                 defl p1       ; patt pointer          +22
  276.                 defl s1        ; curr song pointer     +26
  277.                 defl s1        ; reset song pointer    +30
  278.                 defl env1      ; reset env pointer     +34
  279. ;  section used to store current sound data
  280.  
  281.                defl 0         ; one shot data  address  +38
  282.                 defw 0        ; one shot data length    +42
  283.                 defl 0        ; loop data address       +46
  284.                 defw 0        ; loop data length        +50
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294. s1:            defl p1,p1,p1,0,sreset
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302. p1:            defw new_snd
  303.                defl snd1
  304.                defw  d02,cr,d02,cr,d02,cr,d02,cr/4,d02,cr/4
  305.                defw a02,cr/4,a02,cr/4
  306.                defw  d02,cr,d02,cr,d02,cr,d02,cr/2,d02,cr/2
  307.                defw  b02,cr,d02,cr,a02,cr,b02,cr/2,d02,cr/2
  308.                defw  c02,cr,d02,cr,a02,cr,g02,cr/2,d02,cr/2
  309.                defw end_patt
  310.  
  311.  
  312.  
  313.  
  314.  
  315. snd1       defw 0   ;loop data
  316.            defl strg    ;data address
  317.            defw 1316/2  ;length
  318.  
  319. snd2       defw 1   ;one_shot_flag
  320.            defl strg
  321.            defw 1504/2  ;length
  322.            defl rest_data    ;data address
  323.            defw 16     ;length
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331. sda:       defb 0,90,127,-90,-127,-90
  332.            defb 0,90,127,-90,-127,-90
  333.            defb 0,90,127,-90,-127,-90
  334.            defb 0,90,127,-90,-127,-90
  335.            defb 0,90,127,-90,-127,-90
  336.            defb 0,90,127,-90,-127,-90
  337.            defb 0,90,127,-90,-127,-90
  338.  
  339.  
  340.  
  341.  
  342. rest_data:
  343. ;          length=24 words
  344.            defw 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
  345.  
  346. env1:      defw 64,64,64,64,64,64,255
  347.            defw 64,60,50,40,30,20,10,255
  348.  
  349.                align.w
  350. strg:
  351.                ibytes strg
  352.  
  353.  
  354.  
  355.  
  356.                            end
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.