home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Acorn User 7
/
AU_CD7.iso
/
aujun99
/
regulars
/
rtr
/
software
/
bassp1
Wrap
Text File
|
1999-03-29
|
11KB
|
344 lines
;MIDI Bass peddel
;For an 8 MHz clock
;A0 - MIDI out
;16 keys clocked in through shift register
LIST P=16C84
;
;
C EQU 0
PCL EQU 2
Z EQU 2
PORTB EQU 6
PORTA EQU 5
TRISB EQU 86H
TRISA EQU 85H
EECON1 EQU 88H
EEDATA EQU 8
EEADR EQU 9
STATUS EQU 3
RP0 EQU 5
INC EQU 1
Mch EQU 2 ;Midi transmit channel
H EQU 80h ;Hold drone note
Key EQU 0ch
Note EQU 0dh ;MIDI note value
Sbuf EQU 0eh
Scount EQU 0fh
Cdown EQU 10h
Drone EQU 11h ;Drone note indicator
Kbl EQU 12h ;Key debouncer inner
Kbh EQU 13h ;Key debouncer outer
KeyLim EQU 14h ;Key Limit for Nn routine
voice EQU 15h ;voice number store
bank EQU 16h ;bank number store
CC1 EQU 17h ;Control Change data 1
CC2 EQU 18h ;Control change data 2
PCd EQU 19h ;Programme change data
Lnote EQU 1Ah ;Last note sounded
;
ORG 0
GOTO Start
;7 seg lookup table for diffrent notes
Sseg
addwf PCL,f
retlw 39h ;C
retlw 0B9h ;C#
retlw 05Eh ;D
retlw 0DEh ;D#
retlw 79h ;E
retlw 71h ;F
retlw 0F1h ;F#
retlw 06Fh ;G
retlw 0EFh ;G#
retlw 77h ;A
retlw 0F7h ;A#
retlw 7Ch ;B
retlw 58h ;c
retlw 0 ;Unused switches
retlw 0
retlw 0
;Read the keys through the shift register
Kread bcf PORTA,2 ;Load shift low
clrf Key ;Clear the count
bsf PORTA,2 ;Load shift high
Kloop btfss PORTA,3 ;Look at data
goto found ;Jump out if find a zero
bcf PORTA,1 ;Clock Low
nop
nop
nop
bsf PORTA,1 ;Clock High
incf Key,f ;Counter
movf Key,w ;See if it's at the end
sublw 16
btfss STATUS,Z
goto Kloop
found return
Pres CALL Kread ;Look at the peddles
MOVF Key,w ;Get key value
movf Key,w ;See if anything pressed
sublw 16
btfsc STATUS,Z
goto Pres ;Look again if nothing pressed
return
Unpres
CALL Kread ;Look at the peddles
MOVF Key,w ;Get key value
movf Key,w ;See if anything pressed
sublw 16
btfss STATUS,Z
goto Unpres ;Look again until nothing pressed
return
;Send a serial byte
Send movlw 9 ;Number of data bits to send
movwf Scount
bcf PORTA,0 ;Start bit
call cDelay ;Extra delay compensation
Sloop call Delay
btfsc Sbuf,0 ;Set the next bit
bsf PORTA,0
btfss Sbuf,0
bcf PORTA,0
rrf Sbuf,f ;Shift for next time
decfsz Scount,f
goto Sloop ;Round until finished
bsf PORTA,0 ;Stop bit
call cDelay ;Extra delay compensation
call Delay
call Delay
call cDelay ;For good measure
return
Delay movlw 17 ;Delay for serial send
movwf Cdown
Dloop decfsz Cdown,f
goto Dloop
return
cDelay nop ;Extra delay for outside the loop
nop
nop
nop
nop
nop
nop
nop
nop
return
ProgC movlw 0C0h ;Program Change
iorlw Mch ;Mix in with MIDI channel number
movwf Sbuf ;Send buffer
call Send ;Send Program change message
movf PCd,w ;Data 1
movwf Sbuf
call Send
return
ContC movlw 0B0h ;Control Change
iorlw Mch ;Mix in with MIDI channel number
movwf Sbuf ;Send buffer
call Send ;Send control change message
movf CC1,w ;Data 1
movwf Sbuf
call Send
movf CC2,w ;Data 2
movwf Sbuf
call Send
return
NoteOn movf Key,w ;Get key number
addlw 24 ;Make into MIDI note
movwf Note ;Save in Note (key = 0 note C)
movlw 90h ;Note on
iorlw Mch ;Mix in with MIDI channel number
movwf Sbuf ;Send buffer
call Send ;Send note on
movf Note,w ;Get note number
movwf Sbuf
call Send ;Send note number
movlw 100 ;Velocity
movwf Sbuf
call Send ;Send Velocity
movf Key,w ;Display note
call Sseg ;Convert to 7 seg pattern
movwf PORTB ;Display it
return
NoteOff
movf Note,w ;Get last note
movwf Lnote ;Make a copy
movlw 80h ;Note off
iorlw Mch ;Mix in with MIDI channel number
movwf Sbuf ;Send buffer
call Send ;Send note off
movf Note,w ;Get note number
movwf Sbuf
call Send ;Send note number
movlw 0 ;Velocity
movwf Sbuf
call Send ;Send Velocity
movlw 0 ;Blank display
movwf PORTB
return
Nne call Unpres ;If not valid key wate for unpressed
call Bounce
Nn call Pres ;Get just a note
call Bounce
movf KeyLim,w
subwf Key,w ;See if under the limit
btfsc STATUS,C
goto Nne ;Look again if it is
return
Start
BSF STATUS,RP0 ;SELECT REGISTER BANK 1
MOVLW 18h ;Bits 4 & 3 inputs
MOVWF TRISA^80H ;SET PORT A TO ALL OUTPUTS
MOVLW 0 ;All port B to inputs
MOVWF TRISB^80H
BCF STATUS,RP0 ;SELECT REGISTER BANK 0
BSF PORTA,2 ;Shift / Load high
BSF PORTA,0 ;Midi at Mark
BSF PORTA,1 ;Clock high
clrf Drone ;Drone off
clrf PORTB ;Display off
clrf Lnote ;No note playing
Main
call Pres ;Hold until something pressed
movlw 13 ;Test for a voice change
subwf Key,w
btfsc STATUS,Z
goto Voice
movlw 14 ;Test for a effects change
subwf Key,w
btfsc STATUS,Z
goto Effects
movlw 15 ;Test for spair input
subwf Key,w
btfsc STATUS,Z
goto Main ;Just back if it is
; Must be a note then :- Sound a note
call NoteOff ;Turn previous note off
movf Key,w
addlw 24
subwf Lnote,w ;Is this the same note as last time
btfsc STATUS,Z ;If so skip playing
goto nPlay
Play call NoteOn ;Turn new note on
cPlay call Bounce
call Unpres ;Hold until key released
call Bounce
btfss Drone,0 ;Don't turn off if drone note
call NoteOff ;Turn previous note off
goto Main
nPlay btfss Drone,0 ;If drone notes not on then play again
goto Play
clrf Lnote ;Clear last note played
incf Lnote,f ;To make it diffrent from note
clrf Note ;Clear current note as we arn't going to play it
goto cPlay
Voice movlw 69h ;Display an c underline
movwf PORTB
call Bounce ;Remove voice change switch
call Unpres
call Bounce
movlw 13 ;Limit key to return
movwf KeyLim
call Nn ;Get voice change number
bcf STATUS,C
rlf Key,f ;Multiply number by 2
movf Key,w
movwf EEADR ;Look up voice parameters
BSF STATUS,RP0 ;Select bank 1
bsf EECON1^80h,0 ;initiate EPROM read
BCF STATUS,RP0 ;Back to bank 0
movf EEDATA,w ;Get Voice number
movwf voice
incf EEADR,f ;Get bank Number
BSF STATUS,RP0 ;Select bank 1
bsf EECON1^80h,0
BCF STATUS,RP0 ;Back to bank 0
movf EEDATA,w
movwf bank
bcf Drone,0 ;Clear out any drone
btfsc bank,7 ;Test for Drone bit
bsf Drone,0 ;Set if should be drone
movlw 32 ;Control change data 1
movwf CC1
movf bank,w ;Control change data 2
andlw 7fh ;Blank out any drone bit
movwf CC2
call ContC ;Send first control change bank (LSB)
clrf CC1
clrf CC2
call ContC ;Send other bank (MSB)
movf voice,w ;Program change
movwf PCd
call ProgC
call Unpres
call Bounce
call Bounce
clrf PORTB ;Blank out display
goto Main
Effects
goto Main ;Not yet implemented
Bounce movlw 36
movwf Kbh ;Outer loop
B2 clrf Kbl ;inner loop
B1 decfsz Kbl,f
goto B1
decfsz Kbh,f
goto B2
return
;Voice change data in EEPROM
org 2100h ;Point at data memory
equb 81 ;Big Lead
equb 20+H
equb 81 ;Dir Lead
equb 41+H
equb 87 ;Big & Low
equb 16+H
equb 87 ;Fat & Porky
equb 64+H
equb 87 ;Bass Lead
equb 0+H
equb 88 ;Fantisy 2
equb 64
equb 95 ;Sweep
equb 0
equb 101 ;Goblins
equb 0+H
equb 96 ;Rain
equb 20
equb 91 ;CC
equb 67+H
equb 95 ;Celstia
equb 66+H
equb 95 ;Polar
equb 64+H
equb 95 ;Shimmer
equb 20+H
end