LIST p=16C84 ;Program to tx MIDI data with 10Mhz clock ;MIDI Drum-Pads ;PROGRAM: T. Scarff ;DATE: 03/12/97 ;FILENAME: drm_lee1.asm ;ITERATION: 1.1 ;NOTE: Channel 10 for drums is 09h ;******************************** ; Variable Assignment Addresses ;******************************** dlyreg equ 0C xcount equ 0D xmtreg equ 0E delay1 equ 0F count equ 10h timer equ 11h clkdown equ 12h drum equ 13h value1 equ 14h ;******************************** ; Constant Assignments ;******************************** CARRY equ 00 MSB equ 07 BORROW equ 00 LED equ 07 W equ 00 F equ 01 Z equ 02 C equ 00 dx equ 00 ;******************************** ; Port Assignments ;******************************** PCL equ 02 STATUS equ 03 PORTA equ 05 PORTB equ 06 ;********************************* ; Drum Assignments ;********************************* drum0 equ 00h ;dummy, never used drum1 equ .36 ;bass drum2 equ .38 ;snare drum3 equ .43 ;low tom drum4 equ .42 ;closed hh drum5 equ .45 ;high tom drum6 equ .46 ;open hh drum7 equ .49 ;crash drum8 equ .51 ;ride ;************************************ ; PROGRAMME Reset Point ;************************************ org 0 goto INIT ;************************************* ; Subroutines ;************************************* delay2 movwf dlyreg ;delay=1+(n-1)*3+3 cycles dly2 decfsz dlyreg ;where n is in W reg. goto dly2 ;n=18 for delay=55 cycles nop return bit_set nop nop bsf PORTA,dx return bit_clr bcf PORTA,dx nop nop return txmidi movlw .8 movwf xcount bcf PORTA,dx movlw .02 movwf delay1 dly1 decfsz delay1 goto dly1 xnext movlw .20 ;This loop has 25 cycles call delay2 ;Plus delay2 value. rrf xmtreg ;number of cycles to btfsc STATUS,CARRY ;bit set/clear =1+55+9=65. call bit_set ;number of cycles from btfss STATUS,CARRY ;bit set/clear =15. call bit_clr ;Total=80*0.4us=32uS decfsz xcount goto xnext movlw .22 ;This loop requires 65 cycles call delay2 ;61 +4 so if n=20 nop bsf PORTA,dx ;delay=4+(n-1)*3=61 movlw .25 ;This loop requires 80 cycles call delay2 ;75+5 so if n=25 return ;delay=4+(n-1)*3=76 ;************************************ ; Initialise Software ;************************************ INIT clrf PORTB movlw 0FFh TRIS PORTB ;MAKE PORTB all I/P'S clrf PORTA movlw 00h TRIS PORTA ;make porta all outputs ;************************************** ; Main Programme Start ;************************************** clrf PORTB main movf PORTB,W movwf value1 xorlw 00h btfsc STATUS,Z goto main movlw 00h movwf count drum? incf count,F rrf value1 btfss STATUS,C goto drum? movf count,W call convert movwf drum call noteon call noteoff goto main ;***************************************************** ;note-on subroutine ;***************************************************** noteon movlw 099h ;note-on channel 10 movwf xmtreg call txmidi movf drum,W ; drum note movwf xmtreg call txmidi movlw 07fh ;max velocity movwf xmtreg call txmidi return ;***************************************************** ;note-off subroutine ;***************************************************** noteoff movlw 089h ;note-off channel 10 movwf xmtreg call txmidi movf drum,W ; drum note movwf xmtreg call txmidi movlw 07fh ;max velocity movwf xmtreg call txmidi return ;***************************************************** ; Table to convert drum sound ;***************************************************** convert addwf PCL retlw drum0 retlw drum1 retlw drum2 retlw drum3 retlw drum4 retlw drum5 retlw drum6 retlw drum7 retlw drum8 end