
SERI:
        PUSH ACC
        JB RI,LER
        JMP MidiEnd
LER:
        MOV A,SBUF
        MOV V0,A				;Buffers SBUF
        CLR RI

        CJNE A,#090h,VerMidiB	;Look for Note ON
        MOV MidiB,#1
        JMP MidiEnd
        
VerMidiB:
        MOV A,MidiB
        CJNE A,#1,VerMidiBVelocity
        ;MidiB=1 Receive Midi Note

RecMidiNote:
        MOV R0,V0				;Stores Midi Note in R0
        
        MOV MidiB,#2
        JMP MidiEnd


VerMidiBVelocity:
        MOV A,MidiB
        CJNE A,#2,MidiEnd
        ;MidiB=2 Receive Midi Velocity

        MOV A,R0
        ADD A,#127				;ADD 127 to store in upper ram
        MOV R0,A
        
        MOV @R0, V0				;Should store Velocity (V0) in addressed memory by Midi Note value


        MOV P2,@R0	;<<==== here, P2 dont receives the value back
        
        MOV MidiB,#3




MidiEnd:POP ACC
        RETI

