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