home *** CD-ROM | disk | FTP | other *** search
-
- ; notetable
-
- a02 equ 508
- Bb02 equ 480
- b02 equ 453
- c02 equ 428
- Db02 equ 404
- d02 equ 381
- eb02 equ 360
- e02 equ 339
- f02 equ 320
- gb02 equ 302
- g02 equ 285
-
- a01 equ 254
- Bb01 equ 240
- b01 equ 226
- c01 equ 214
- Db01 equ 202
- d01 equ 190
- eb01 equ 180
- e01 equ 170
- f01 equ 160
- gb01 equ 151
- g01 equ 143
-
-
-
- chann1reg equ $dff0a0 ;start of ch1 registers
- dmacon equ $dff096
- int_bf_int equ $dff01e
- int_bf_w equ $dff09c
- in_line equ 0
- new_snd equ 4
- sreset equ 1
-
- end_patt equ 8
- cr equ 16
-
-
-
- move.w #1,d0
- andi.w #0,d0
-
-
-
-
-
-
-
- ; a0 points to channel vars
- ; a1 reads patt data/song data/envelope data
- ; a2 points to ch reg locations
- ; d0 used as general purpose register
- ; d1 holds bits set for dma control reg
-
-
-
-
-
- testloop: jsr driver
- jsr delay
- bra testloop
-
- tstop: nop
- nop
- nop
- nop
-
-
-
-
-
- delay:
- ddd: move.w $dff006,d0
- ; andi.w #%0000000011111111,d0
- ; cmpi #0,d0
- ; bne ddd
- ; rts
-
-
-
-
-
- move.l #$06ff,d7
- delloop: subq.l #$1,d7
- cmpi.l #50,d7
- bls findel
- bra delloop
- findel: rts
-
- driver:
- lea ch1vars,a0
- lea chann1reg,a2
- move.w #%1000001000000001,d1 ; enable ch 1
- move.w #%0000000000000000,d2
-
- ; *****************************
- ; this section checks channel current status
-
- sect1:
- cmpi.w #0,(a0) ; for test disable
- beq sect1_j1
- rts
- sect1_j1 cmpi.w #0,2(a0) ;counter at zero
- beq sect3 ; get new note
- cmpi.w #1,2(a0)
- beq sect4
-
- cmpi.w #3,4(a0) ;is it looped data
- bhs sect2 ;branch if one shot
- ; data is looped data
- mode_switch: subq #1,2(a0) ;decrease counter
- move.l 18(a0),a1 ;envelope data needed ?
- cmpi.w #255,(a1)
- beq env_finished
- move.w (a1)+,8(a2) ;send vol data
- move.l a1,18(a0) ;store pointer
- env_finished: rts ; finish
-
- ; *****************************
- ; this section checks 4(a0) and if it is 2 then it sends the one shot
- ; data in the vars buffer and sets 4(a0) to 3
- ; when flag is 3 the program sends the loop data to the reg and sets
- ; the flag to 4
- ; when the flag is 4 it checks the block finished interrupt and when
- ; set it sets the flag to 1 and jumps to mode_switch where the loop
- ; data is processed normally
- ; new note must check the flag 4(a0) and if it is 1 then reset it 2
- ;
-
- ; flag must be 3 or 4
- sect2:
- cmpi.w #4,4(a0)
- beq part3 ;to check for block finished
- bra part2 ;flag is 3,send loop data
- ; part 1 send one shot data to chip
- one_shot_note: move.w #3,4(a0) ;set flag
- move.l 38(a0),(a2)
- move.w 42(a0),4(a2)
- move.w #64,8(a2)
- move.w d1,dmacon ;start dma
- rts
- ; part 2 send loop data to chip
- ; move loop data into register from vars store
- part2: notyet:
- ; move.w 8(a0),d0 ;int mask bit
- ; and int_bf_int,d0
- ; cmpi.w #0,d0
- ; beq notyet
- ; move.w d0,int_bf_w
-
- move.w #4,4(a0) ;flag to 4
- move.l 44(a0),(a2)
- move.w 48(a0),4(a2)
- subq #1,2(a0) ;decrease count
- rts
-
- part3: ; clr.l d0
- ; move.w 8(a0),d0
- ; and int_bf_int,d0
- ; cmpi #0,d0
-
- ; bset d0,int_bf_int ;test int set
- ; bne block_done
- ; block still playing
- subq #1,2(a0) ;dec count
- rts
-
-
- block_done: move.w #1,4(a0) ; flag to loop
- bra mode_switch
-
-
-
- ; *****************************
-
- ; this section gets new note data
-
- sect3:
- ; move.w 8(a0),d0
- ; move.w d0,int_bf_w
-
- move.l 22(a0),a1 ;get patt pointer
- control_ret: move.w (a1)+,d0 ;next data to d0/pointer inc
- cmpi.w #100,d0 ;control marker
- bls sect5 ;effects flags
- ;d1 holds next note pitch
- move.w d0,12(a0) ;store in curr pitch
- move.w d0,6(a2) ;pitch to reg
- move.w (a1)+,2(a0) ;store count
- subq.w #1,2(a0) ;and decrease
- move.l a1,22(a0) ;store patt pointer
- move.l 34(a0),18(a0) ; reset env pointer
- ; move.w #64,8(a2)
-
- cmpi.w #0,4(a0)
- beq do_loop
- bra one_shot_note ;jump there
-
- ; loop data trigger
- do_loop: move.w d1,dmacon ;start dma for current channel
- rts
-
-
- ; ***********************************
- sect4:
-
-
-
- move.w #%0000000000000001,dmacon ;dma off
- subq.w #1,2(a0)
- rts
-
- ; ***********************************
- ; effects flags d0 holds jump offset
- sect5: move.l #jump_table,a3
- move.l (a3,d0),a4
- jmp (a4)
-
-
- jump_table: defl in_line_data
- defl nsound
- defl patt_end
- nop
- nop
- in_line_data:
- ; data format = reg offset,data,etc....,end_data
- nop
- rts
-
-
-
- nsound: move.l (a1)+,a3 ;sound address to a3
- cmpi.w #0,(a3)
- bne one_shot_sound
- move.w (a3)+,4(a0) ;loop or one shot flag
- move.l (a3)+,(a2) ;data address
- move.w (a3),4(a2) ;length
- jmp control_ret
-
- one_shot_sound:
- move.w (a3)+,4(a0)
- move.l (a3)+,38(a0) ;store
- move.l (a3)+,42(a0)
- move.l (a3),46(a0)
- jmp control_ret
-
- patt_end:
- ; get next patt address from song part
- move.l 26(a0),a1 ;song pos to a1
- song_cont_ret: cmpi.l #0,(a1) ;song marker ??
- beq song_control
- addq.l #4,a1
- move.l a1,26(a0) ;store song pointer
- move.l (a1),a1 ;patt address to a1
- jmp control_ret
-
-
- song_control:
- ; reset song to start
- addq.l #4,a1
- cmpi.l #255,(a1)
- beq tstop
- move.l 30(a0),a1
- bra song_cont_ret
-
-
-
-
- ch1vars defw 0 ; test disable +0
- defw 0 ; interrupt counter +2
- defw 0 ; 1 = loop/one shot mode flag +4
- defw 0 ; current pitch + 6
-
- defw %0000000010000000 ;bit number for int read
- defw 0 ;
- defw 0 ;
- defw 0 ;
- defw 0 ;
-
- defl env1 ; env pointer +18
- defl p1 ; patt pointer +22
- defl s1 ; curr song pointer +26
- defl s1 ; reset song pointer +30
- defl env1 ; reset env pointer +34
- ; section used to store current sound data
-
- defl 0 ; one shot data address +38
- defw 0 ; one shot data length +42
- defl 0 ; loop data address +46
- defw 0 ; loop data length +50
-
-
-
-
-
-
-
-
-
- s1: defl p1,p1,p1,0,sreset
-
-
-
-
-
-
-
- p1: defw new_snd
- defl snd2
- defw d02,cr,d02,cr,d02,cr,d02,cr/2,d02,cr/2
- defw d02,cr,d02,cr,d02,cr,d02,cr/2,d02,cr/2
- defw b02,cr,d02,cr,a02,cr,b02,cr/2,d02,cr/2
- defw c02,cr,d02,cr,a02,cr,g02,cr/2,d02,cr/2
- defw end_patt
-
-
-
-
-
- snd1 defw 0 ;loop data
- defl sda ;data address
- defw 16 ;length
-
- snd2 defw 1 ;one_shot_flag
- defl koto1
- defw 1280 ;length
- defl rest_data ;data address
- defw 16 ;length
-
-
-
-
-
-
-
- sda: defb 0,90,127,-90,-127,-90
- defb 0,90,127,-90,-127,-90
- defb 0,90,127,-90,-127,-90
- defb 0,90,127,-90,-127,-90
- defb 0,90,127,-90,-127,-90
- defb 0,90,127,-90,-127,-90
- defb 0,90,127,-90,-127,-90
-
-
-
-
- rest_data:
- ; length=24 words
- 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
-
- env1: defw 64,64,64,64,22,20,20,20,20,20,10,10,0
- defw 12,20,24,26,30,40,50,60,255
-
- align.w
- koto1:
- ibytes koto1
-
-
-
-
- end
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-