home *** CD-ROM | disk | FTP | other *** search
- ; MED - by Teijo Kinnunen, 1989, 1990
- ; Player2.a, version 2.30
- ; Use A68k (Fish #186) to assemble.
- custom EQU $dff000
- dmacon EQU $dff096
- aud0 EQU $0A0
- aud1 EQU $0B0
- aud2 EQU $0C0
- aud3 EQU $0D0
- ac_ptr EQU $00
- ac_len EQU $04
- ac_per EQU $06
- ac_vol EQU $08
- xref _song
- xref _samples
- xref _blocks
- xref _zeroptr
-
- section "text",code
- EVEN
- dc.b ' MEDPlayer is here!!!:' ;please, don't remove this
- waithwnum: dc.l 500
- newaptr: dc.l 0,0,0,0
- newalen: dc.w 0,0,0,0
- audaddr: dc.l custom+aud0,custom+aud1,custom+aud2,custom+aud3
-
- TrackOff: ;d0 = channel #
- moveq.l #1,d1
- lsl.w d0,d1
- move.w d1,dmacon
- notamigatrk: rts
- PlayNote: ;d0 = trk #, d1 = note #, d2 = vol, d3 = instr #
- movem.l a2-a3/d3-d7,-(sp) ;All right, let's start!!
- move.w d2,-(sp)
- clr.l d4
- bset d0,d4 ;d4 is mask for this channel
- lea _samples,a0 ;Is this instrument in mem?
- lsl.w #2,d3 ;d3 = instr.num << 2
- tst.l 0(a0,d3.w)
- beq.w retsn2
- add.b _song+264,d1 ;add play transpose
- bgt.s notenot2low
- add.b #12,d1 ;note was too low, octave up
- bra.s endpttest
- notenot2low: cmp.b #72,d1
- ble.s endpttest
- sub.b #12,d1 ;note was too high, octave down
- endpttest: move.w d4,dmacon ;stop this channel
- lea _song+268,a1
- or.w d4,dmaonmsk
- subq.b #1,d1
- lsl.w #1,d0
- lsr.w #1,d3
- lea newalen(pc),a2
- clr.w 0(a2,d0.w)
- move.w d0,d6
- lsl.w #1,d6 ;d6 = channel num << 2
- move.w d3,d7
- lsl.w #1,d7 ;d7 = instr. num << 2
- lea audaddr,a1
- movea.l 0(a1,d6.w),a1 ;base of this channel's regs
- lea newaptr(pc),a3 ;a3 = address of newaptr
- lea _samples,a2 ;get the address of...
- move.l 0(a2,d7.w),d5 ;...this instrument
- move.l d5,a0
- bsr.w getinsdata
- move.l d0,ac_ptr(a1) ;put start offs to ac_ptr
- cmp.w #2,d3
- bls.s norepeat
-
- add.l d2,d0 ;d0 = starting address of repeat
- move.l d0,0(a3,d6.w) ;remember!! (move to newaptr)
- lsr.w #1,d3 ;shift right
- lsr.w #1,d6
- move.w d3,16(a3,d6.w) ;remember too (newalen)
- lsr.w #1,d2 ;shift
- beq.s begin0 ;rep. start < 2
- move.w d2,ac_len(a1) ;move repeat to hardware
- bra.s retsn1
- begin0: move.w d3,ac_len(a1)
- bra.s retsn1
-
- norepeat: move.l zeroptr,0(a3,d6.w) ;pointer of zero word
- lea newalen(pc),a3
- lsr.w #1,d6
- move.w #1,0(a3,d6.w) ;length: 1 word
- lsr.l #1,d1 ;shift length right
- move.w d1,ac_len(a1) ;and put to custom chip
-
- retsn1: move.w d5,ac_per(a1)
- lea prevper(pc),a0
- move.w d5,0(a0,d6.w)
- move.w (sp),ac_vol(a1) ;volume
- retsn2: addq.l #2,sp ;forget volume
- movem.l (sp)+,a2-a3/d3-d7
- rts
-
- StartDMA: ;This small routine turns on audio DMA
- move.w dmaonmsk,d0 ;dmaonmsk contains the mask of
- beq.s retsdma ;the channels that must be turned on
- bset #15,d0 ;DMAF_SETCLR: set these bits in dmacon
- move.l waithwnum,d1
- waithw0: dbf d1,waithw0
- move.w d0,dmacon ;do that!!!
- move.l waithwnum,d1
- waithw1: dbf d1,waithw1
- lsr.b #1,d0 ;finally, push new ptrs to audio hw regs
- bcc.s pushch1
- move.l newaptr(pc),custom+aud0+ac_ptr
- move.w newalen(pc),custom+aud0+ac_len
- pushch1: lsr.b #1,d0
- bcc.s pushch2
- move.l newaptr+4(pc),custom+aud1+ac_ptr
- move.w newalen+2(pc),custom+aud1+ac_len
- pushch2: lsr.b #1,d0
- bcc.s pushch3
- move.l newaptr+8(pc),custom+aud2+ac_ptr
- move.w newalen+4(pc),custom+aud2+ac_len
- pushch3: lsr.b #1,d0
- bcc.s retsdma
- move.l newaptr+12(pc),custom+aud3+ac_ptr
- move.w newalen+6(pc),custom+aud3+ac_len
- retsdma: rts
-
- dmaonmsk: dc.w 0
- prevper: dc.w 0,0,0,0
- prevnote: dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- previnstr: dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- prevvol: dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- effect: dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- effectqual: dc.b 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
- nextblock: dc.b 0
- counter: dc.b 5
- numtracks: dc.b 0,0
- playstate: dc.w 0
- playblock: dc.w 0
- playline: dc.w 0
- playblocknum dc.w 0
-
- IntHandler:
- movem.l d2-d7/a2-a4,-(sp)
- tst.w playstate ;are we playing
- bne.s playing ;yes, we are
- and.b #$fe,$bfee01 ;no...stop the timer
- move.b #$05,counter
- movem.l (sp)+,d2-d7/a2-a4 ;exit interrupt
- rts
- playing: clr.w dmaonmsk
- add.b #1,counter
- cmp.b #6,counter ;if counter = 6: new note and fx
- bne.w nonewnote ;if counter is not 6: just do fx
- clr.b counter ;new note!!!
- clr.l d7 ;number of track
- lea _blocks,a2 ;a2 = address of 1st block's address
- move.w playblock,d2
- lsl.w #2,d2 ;shift to longword index
- movea.l 0(a2,d2.w),a2 ;get the pointer of the block
- move.b (a2),numtracks+1 ;save #áof tracks
- addq.l #4,a2 ;skip...
- move.w numtracks,d3
- mulu #3,d3
- move.w playline,d2
- mulu d2,d3
- adda.l d3,a2 ;a2 = address of this line
- lea prevnote(pc),a3
- lea _song,a4
- trloop0: clr.w d5
- move.b (a2)+,d5 ;get the number of this note
- move.b (a2)+,d6 ;and the 4 numbers containing fx
- lsl.w #8,d6
- move.b (a2)+,d6
- lea effectqual(pc),a1
- move.b d6,0(a1,d7.w) ;save the fx numbers
- clr.b d4 ;d4 is a flag: if set, instr. is
- btst #7,d5 ;in range G-V. If clr, it's 1-F.
- beq.s nogtov ;In the song, if bit #7 is set in
- bclr #7,d5 ;note number byte, it's G-V
- st.b d4 ;this instrument is in range G-V
- nogtov: move.w #$f000,d0
- and.w d6,d0 ;d0 now contains only the # of instr
- bne.s instnum ;instrument number is not 0
- tst.b d4 ;maybe it's G (instr. #0, d4 set)
- beq.s noinstnum ;no. It's 0!!!
- instnum: lsr.w #8,d0 ;shift it right to get number 0-F
- lsr.b #4,d0
- tst.b d4
- beq.s nogtov2
- add.w #16,d0 ;if G-V, add 16 to the number
- nogtov2: lea previnstr(pc),a1
- move.b d0,0(a1,d7.w) ;remember instr. number!
- lea prevvol(pc),a1
- move.b 0(a4,d0.w),0(a1,d7.w) ;vol of this instr to prevvol
- noinstnum: move.w d6,d0 ;effect again...
- lsr.w #8,d0
- and.b #$0f,d0 ;now check only the effect part
- lea effect(pc),a1
- move.b d0,0(a1,d7.w) ;save the effect number
- beq.s noeffect ;no effect
- cmp.b #$0f,d0 ;yes effect...is it Tempo???
- bne.s not0f ;not Tempo
- tst.b d6 ;Tempo !!!
- beq.s fx0fchgblck ;if effect qualifier (last 2 #'s)..
- cmp.b #$f0,d6 ;..is zero, go to next block
- bhi.s fx0fspecial ;if it's F1-FF something special
- clr.l d0 ;will happen!!!
- move.b d6,d0
- bsr SetTempo ;change The Tempo
- bra.s noeffect
- fx0fspecial: cmp.b #$f2,d6 ; | rest - play | SpecialFX#2: no note..yet
- bne.s isfxfe ;not SpecFX2
- move.b d5,(a3) ;Yes!!! Save the note number
- clr.w d5 ; clear the number for awhile
- bra.s noeffect
- isfxfe: cmp.b #$fe,d6
- bne.s noeffect
- clr.w playstate
- bra.s noeffect
- fx0fchgblck: st.b nextblock ;next block????...YES!!!! (F00)
- bra.s noeffect
- not0f: cmp.b #$0c,d0 ;new volume???
- bne.s noeffect ;NO!!!!!!!!!!!!!!!!!!!!!!
- move.b d6,d0
- lsr.b #4,d0 ;Strange code begins now
- mulu #10,d0
- move.b d6,d1
- and.b #$0f,d1
- add.b d1,d0 ;strange code ends now: d0 is vol
- cmp.b #64,d0
- bls.s novolov64
- moveq.l #64,d0
- novolov64 lea prevvol(pc),a1
- move.b d0,0(a1,d7.w) ;and save it....
- noeffect: tst.b d5 ;Now we'll check if we have to play a note
- beq.s endtrkloop ;no.
- move.b d5,(a3)
- move.w d7,d0
- move.w d5,d1
- clr.w d2
- clr.w d3
- lea previnstr(pc),a1
- move.b 0(a1,d7.w),d3
- lea prevvol(pc),a1
- move.b 0(a1,d7.w),d2 ;get volume
- bsr PlayNote ;play it!!!!!!!!!!!
- endtrkloop: addq.l #1,a3 ;a3 = pointer to prev. note #
- addq.l #1,d7
- cmp.w numtracks,d7
- blt.w trloop0
-
- add.w #1,playline ;very important!!! advance line!!
- cmp.w #63,playline ;important too!!! advance block??
- bgt.s chgblock ;yes!!!
- tst.b nextblock ;command F00 ??
- beq.s nochgblock ;no, don't change block
- chgblock: clr.w playline ;clear line number
- cmp.w #2,playstate ;play block or play song
- bne.s nonewseq ;play block only...
- add.w #1,playblocknum ;advance sequence number
- move.w 262(a4),d0 ;get the highest seq number
- move.w playblocknum,d1 ;and current seq number
- cmp.w d0,d1 ;is this the highest seq number
- blt.s nostartagain ;no
- clr.w playblocknum ;yes: play song again
- clr.w d1 ;...forever!!!
- nostartagain: clr.w d0
- lea 162(a4),a1 ;offset of sequence table
- move.b 0(a1,d1.w),d0 ;get number of the block
- move.w d0,playblock ;and put it to block number var
- move.w 160(a4),d1 ;get number of blocks
- subq.w #1,d1 ;# of blocks-1 = # of highest block
- cmp.w d1,d0 ;is this block number too big
- blt.s nonewseq ;no
- move.w d1,playblock ;yes..then play just the last block
- nonewseq: clr.b nextblock ;clear this if F00 set it
- nochgblock:
- nonewnote:
- ; *********************** This code produces the effects **
- clr.l d7 ;clear channel count
- lea prevper(pc),a3
- lea prevvol(pc),a4
- trloop1: clr.w d5
- lea effect,a1
- clr.w d4
- move.b 0(a1,d7.w),d6 ;get the fx number
- lea effectqual,a1
- move.b 0(a1,d7.w),d4 ;and the last 2 #'s
- cmp.b #1,d6 ;effect #1
- bne.s nofx01
- ; **************************************** Effect 01 ******
- cmp.w #5,_song+266
- bne.s nost1
- tst.b counter
- beq newvals
- nost1: sub.w d4,(a3) ;slide it up!!!
- cmp.w #113,(a3) ;too high???
- bge newvals
- move.w #113,(a3) ;yes, too high!!!
- bra newvals
- ; *********************************************************
- nofx01: cmp.b #2,d6
- bne.s nofx02
- ; **************************************** Effect 02 ******
- cmp.w #5,_song+266
- bne.s nost2
- tst.b counter
- beq newvals
- nost2: add.w d4,(a3) ;slide it down!!!!!!!!!
- cmp.w #856,(a3) ;too low??
- ble newvals
- move.w #856,(a3) ;too low.
- bra newvals
- ; *********************************************************
- nofx02: tst.b d6
- bne.s nofx00
- ; **************************************** Effect 00 ******
- tst.b d4 ;both fxqualifiers are 0s: no arpeggio!!
- beq.w endl
- lea prevnote,a1
- bsr.w DoArpeggio
- subq.b #1,d4 ;-1 to make it 0 - 127
- add.b _song+264,d4 ;add play transpose
- lsl.b #1,d4 ;shift to make index for UWORD
- lea periods,a1
- move.w 0(a1,d4.w),d5
- bra.w newvals
- ; *********************************************************
- nofx00: cmp.b #$0d,d6
- bne.s nofx0d
- ; **************************************** Effect 0D ******
- move.b d4,d1
- move.b (a4),d0 ;move previous vol to d0
- and.b #$f0,d1
- bne.s crescendo
- sub.b d4,d0 ;sub from prev. vol
- bpl.s novolund0
- clr.b d0 ;volumes under zero not accepted!!!
- novolund0: move.b d0,(a4) ;put new vol back
- bra newvals
- crescendo: lsr.b #4,d1
- add.b d1,d0
- cmp.b #64,d0
- ble.s novolover64
- moveq.l #64,d0
- novolover64: move.b d0,(a4)
- bra newvals
- ; *********************************************************
- nofx0d: cmp.b #3,d6
- bne.s nofx03
- ; **************************************** Effect 03 ******
- move.w (a3),d5 ;this is very simple: get the old period
- cmp.b #3,counter ;and..
- bge.w newvals ;if counter < 3
- sub.w d4,d5 ;subtract effect qualifier
- bra.w newvals
- ; *********************************************************
- nofx03: cmp.b #$0f,d6
- bne.s nofx0f
- ; **************************************** Effect 0F ******
- fx0f: cmp.b #$ff,d4
- bne.s no0fff
- move.w d7,d0
- bsr.w TrackOff
- bra.w endl
- no0fff: cmp.b #$f1,d4
- bne.s no0ff1
- cmp.b #3,counter
- bne.s newvals
- bra.s playfxnote
- no0ff1: cmp.b #$f2,d4
- bne.s no0ff2
- cmp.b #3,counter
- bne.s newvals
- bra.s playfxnote
- no0ff2: cmp.b #$f3,d4
- bne.s endl
- move.b counter,d0
- and.b #2+4,d0 ;is 2 or 4
- beq.s newvals
- playfxnote: move.w d7,d0 ;track # to d0...
- lea prevnote(pc),a1
- clr.w d1
- move.b 0(a1,d7.w),d1 ;get note # of previous note
- clr.w d2
- move.b (a4),d2 ;get previous volume
- lea previnstr(pc),a1
- clr.w d3
- move.b 0(a1,d7.w),d3
- bsr PlayNote
- bra.s endl
- ; *********************************************************
- nofx0f: cmp.b #$0e,d6
- bne.s nofx0e
- ; **************************************** Effect 0E ******
- fx0e: tst.b d4
- bne.s filteroff
- bclr #1,$bfe001
- bra.s endl
- filteroff: bset #1,$bfe001
- bra.s endl
- ; *********************************************************
- nofx0e: cmp.b #$0c,d6
- bne.s endl
- newvals: tst.w d5 ;now: do the effects!!!
- bne.s nonewper
- move.w (a3),d5 ;no new period specified: get the old
- nonewper: move.w d7,d4 ;channel number to d4
- lsl.w #2,d4 ;and shift it to make it a longword index
- lea audaddr,a1
- movea.l 0(a1,d4.w),a1
- move.w d5,ac_per(a1)
- clr.w d5
- move.b (a4),d5
- move.w d5,ac_vol(a1)
- endl: addq.l #2,a3 ;inc pointer to previous period value
- addq.l #1,a4 ;and previous volume
- addq.l #1,d7 ;increment channel number
- cmp.w numtracks,d7 ;all channels done???
- blt.w trloop1 ;not yet!!!
-
- bsr StartDMA ;turn on DMA
- exitint: movem.l (sp)+,d2-d7/a2-a4
- rts
- SetTempo: tst.b timeropen
- beq.s exitsettempo
- cmp.b #10,d0 ;If tempo <= 10, use SoundTracker tempo
- bhi.s calctempo
- lea sttempo(pc),a1
- lsl.w #1,d0
- move.w 0(a1,d0.w),d1
- bra.s pushtempo
- calctempo: move.l #470000,d1
- divu d0,d1
- pushtempo: move.b d1,$bfe401 ;and set the CIA timer
- lsr.w #8,d1
- move.b d1,$bfe501
- exitsettempo: rts ; vv-- These values are the SoundTracker tempos (approx.)
- sttempo: dc.w $0f00,2417,4833,7250,9666,12083,14500,16916,19332,21436,24163
-
- DoArpeggio: ; beginning note table in a1, note num returned in d4
- move.b 0(a1,d7.w),d1 ;d1 = # of previous note played
- move.b counter,d0
- tst.b d0
- beq.s arpg03
- cmp.b #3,d0
- bne.s arpgn03
- arpg03: and.b #$0f,d4 ;counter = 0 or 3: get last number
- add.b d1,d4 ;add it to note number
- rts
- arpgn03: cmp.b #1,d0
- beq.s arpg14
- cmp.b #4,d0
- bne.s arpgn14
- arpg14: lsr.b #4,d4 ;counter = 1 or 4: get the first number
- add.b d1,d4 ;add to prev. note
- rts
- arpgn14: move.b d1,d4 ;2 or 5: the previous note
- rts
-
- getinsdata: clr.l d2
- move.w 4(a0),d0 ;Soitin-struct in a0, instr#<<1: d3
- bne.s iff5or3oct ;note # in d1 (0 - ...)
- move.l a0,d0
- lea periods,a0
- lsl.b #1,d1
- move.w 0(a0,d1.w),d5 ;put period to d5
- move.l d0,a0
- addq.l #6,d0 ;Skip structure
- move.l (a0),d1 ;length
- lea _song+32,a0
- move.w 0(a0,d3.w),d2
- move.w 64(a0,d3.w),d3
- rts
- iff5or3oct: movem.l a1/d6-d7,-(sp)
- clr.l d7
- move.w d1,d7
- divu #12,d7 ;octave #
- move.l d7,d5
- swap d5 ;note number (0-11) in this oct to d5
- move.l (a0),d1
- cmp.b #2,d0
- bne.s no3oct
- addq.l #6,d7
- divu #7,d1 ;get length of the 1st octave
- bra.s no5oct
- no3oct: divu #31,d1 ;get length of the 1st octave (5 octaves)
- no5oct: move.l d1,d0 ;d0 and d1 = length of the 1st oct
- lea _song+32,a1
- move.w 0(a1,d3.w),d2
- move.w 64(a1,d3.w),d3
- clr.w d6
- move.b shiftcnt(pc,d7.w),d6
- lsl.w d6,d2
- lsl.w d6,d3
- lsl.w d6,d1
- move.b mullencnt(pc,d7.w),d6
- mulu d6,d0 ;offset of this oct from 1st oct
- add.l a0,d0 ;add base address to offset
- addq.l #6,d0 ;skip structure
- lea periods,a1
- add.b octstart(pc,d7.w),d5
- lsl.b #1,d5
- move.w 0(a1,d5.w),d5
- movem.l (sp)+,a1/d6-d7
- rts
- shiftcnt: dc.b 4,3,2,1,1,0,2,2,1,1,0,0
- mullencnt: dc.b 15,7,3,1,1,0,3,3,1,1,0,0
- octstart: dc.b 12,12,12,12,24,24,0,12,12,24,24,36
-
- _AudioInit: movem.l a6/d2,-(sp)
- clr.l d2
- movea.l 4,a6
- ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ alloc signal bit
- addq.l #1,d2
- st.l d0 ; -1
- jsr -$14a(a6) ;AllocSignal()
- tst.b d0
- bmi.w initerr
- move.b d0,sigbitnum
- ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ prepare IORequest
- suba.l a1,a1
- jsr -$126(a6) ;FindTask(0)
- lea allocport(pc),a1
- move.b sigbitnum,15(a1) ;set mp_SigBit
- move.l d0,16(a1) ;set mp_SigTask
- lea reqlist(pc),a0
- move.l a0,(a0) ;NEWLIST begins...
- addq.l #4,(a0)
- clr.l 4(a0)
- move.l a0,8(a0) ;NEWLIST ends...
- ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ open audio.device
- addq.l #1,d2
- lea allocreq(pc),a1
- lea audiodevname(pc),a0
- clr.l d0
- clr.l d1
- movea.l 4,a6
- jsr -$1bc(a6) ;OpenDevice()
- tst.b d0
- bne.s initerr
- st.b audiodevopen
- ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ open ciaa.resource
- addq.l #1,d2
- clr.l d0
- lea ciaaname(pc),a1
- jsr -$1f2(a6) ;OpenResource()
- tst.l d0
- beq.s initerr
- move.l d0,ciaaresource
- ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ attach interrupt
- addq.l #1,d2
- move.l d0,a6
- lea timerinterrupt(pc),a1
- clr.l d0 ;Bit number 0: Timer A
- jsr -$6(a6) ;AddICRVector
- tst.l d0
- bne.s initerr
- and.b #%10000000,$bfee01
- move.l #%10000001,d0
- jsr -$12(a6) ;AbleICR()
- st.b timeropen
- clr.w playstate
- clr.l d0
- initret: movem.l (sp)+,a6/d2
- rts
- initerr: move.l d2,d0
- bra.s initret
-
- _AudioRem: move.l a6,-(sp)
- tst.b timeropen
- beq.s rem1
- ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ remove interrupt
- move.l ciaaresource,a6
- lea timerinterrupt(pc),a1
- clr.l d0 ;Bit number 0: Timer A
- jsr -$c(a6) ;RemICRVector
- ;There is no CloseResource(). I'm not sure if I should use CloseLibrary()??
- rem1: movea.l 4,a6
- tst.b audiodevopen
- beq.s rem2
- move.w #$000f,dmacon ;stop audio DMA
- ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ close audio.device
- lea allocreq(pc),a1
- jsr -$1c2(a6) ;CloseDevice()
- rem2: clr.l d0
- move.b sigbitnum,d0
- bmi.s rem3
- ; +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ free signal bit
- jsr -$150(a6) ;FreeSignal()
- rem3: move.l (sp)+,a6
- rts
-
- xdef _InitPlayer
- xdef _StartPlayer
- xdef _StopPlayer
- xdef _RemPlayer
- xdef SetTempo ;for assembly programmers
- xdef _SetTempo ;for C programmers
-
- _InitPlayer: bsr.w _AudioInit
- tst.b d0
- bne.s iperror
- moveq.l #6,d0
- bsr.w SetTempo ;default tempo
- clr.l d0 ;Init OK
- iperror: rts
-
- _RemPlayer: bclr #1,$bfe001 ;filter back on
- tst.w playstate
- beq.s nostop
- bsr.s _StopPlayer
- nostop: bsr.w _AudioRem
- rts
-
- _StartPlayer: tst.b timeropen
- beq.s exitsplr
- clr.w playblocknum ;play from the beginning
- move.b _song+162,playblock+1 ;get the first block
- clr.w playline
- move.w #2,playstate
- move.b _song+265,d0
- btst #0,d0
- bne.s nofiloff
- or.b #2,$bfe001 ;set filter
- nofiloff: or.b #$01,$bfee01 ;start timer
- exitsplr: rts
-
- _StopPlayer: clr.w playstate ;the interrupt will stop the timer
- tst.b audiodevopen
- beq.s exitstpplr
- move.w #$000f,dmacon ;stop audio DMA
- exitstpplr: rts
-
- _SetTempo: move.l 4(sp),d0
- bra.w SetTempo
-
- ciaaresource: dc.l 0
- zeroptr: dc.l _zeroptr ;_zeroptr is not really a pointer
- audiodevopen: dc.b 0
- timeropen: dc.b 0
- sigbitnum: dc.b -1
- timerinterrupt: dc.w 0,0,0,0,0
- dc.l timerintname,0,IntHandler
- allocport: dc.l 0,0 ;succ, pred
- dc.b 4,0 ;NT_MSGPORT
- dc.l 0 ;name
- dc.b 0,0 ;flags = PA_SIGNAL
- dc.l 0 ;task
- reqlist: dc.l 0,0,0 ;list head, tail and tailpred
- dc.b 5,0
- allocreq: dc.l 0,0
- dc.b 5,127 ;NT_MESSAGE, maximum priority (127)
- dc.l 0,allocport ;name, replyport
- dc.w 68 ;length
- dc.l 0 ;io_Device
- dc.l 0 ;io_Unit
- dc.w 0 ;io_Command
- dc.b 0,0 ;io_Flags, io_Error
- dc.w 0 ;ioa_AllocKey
- dc.l sttempo ;ioa_Data
- dc.l 1 ;ioa_Length
- dc.w 0,0,0 ;ioa_Period, Volume, Cycles
- dc.w 0,0,0,0,0,0,0,0,0,0 ;ioa_WriteMsg
- periods: dc.w 856,808,762,720,678,640,604,570,538,508,480,453
- dc.w 428,404,381,360,339,320,302,285,269,254,240,226
- dc.w 214,202,190,180,170,160,151,143,135,127,120,113
- dc.w 214,202,190,180,170,160,151,143,135,127,120,113
- dc.w 214,202,190,180,170,160,151,143,135,127,120,113
- dc.w 214,202,190,180,170,160,151,143,135,127,120,113
- ciaaname: dc.b 'ciaa.resource',0
- timerintname: dc.b 'Player: TimerInterrupt',0
- audiodevname: dc.b 'audio.device',0
- medname: dc.b 'MED',0 ;yeah, our name
- end
-