;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;; MIDI sw data Receive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; rx_data_receive: cmp.w r5,e5 ;r5: rx1_top, e5: rx1_end bne initialize rts initialize: sub.l er1,er1 mov.w e5,r1 ;rx data address data_Read: mov.b @(rx_fifo,er1),r0h ; rx data -> [r0h] inc.w #1,r1 bclr #1,r1h ; rx buffer 512 mov.w r1,e5 ; reWrite rx data address cmp.b #h'F0,r0h ; sysex data thru bls ditector rts ditector: btst #3,r4h ; detecting 4th data flag =>r4h bne data_store2 btst #2,r4h ; detecting 3rd data flag bne detector_2 btst #1,r4h ; detecting 2nd data flag bne data_store btst #0,r4h ; detecting 1st data flag bne next_flag cmp.b #h'B0,r0h ; data header reading from MotorMix beq data_set1 rts detector_2: cmp.b #h'2C,r0h ; detecting the 4th flag beq data_set4 mov.b #0,r4h rts data_set4: bset #3,r4h rts data_store: cmp.b #h'08,r0h ; detecting sw data blt data_set3 sub.b r4h,r4h rts data_set3: mov.b r0h,r0l ; loading the sw line data bset #2,r4h ; setting the 3rd flag rts next_flag: cmp.b #h'0C,r0h ; second data detector beq data_set2 sub.b r4h,r4h rts data_set2: bset #1,r4h rts data_set1: bset #0,r4h rts data_store2: and.b #b'01100000,r4h ; erase the flags cmp.b #h'42,r0h beq line_04_on cmp.b #h'02,r0h beq line_04_off cmp.b #h'43,r0h beq line_03_on cmp.b #h'03,r0h beq line_03_off cmp.b #h'44,r0h beq line_02_on cmp.b #h'04,r0h beq line_02_off cmp.b #h'45,r0h beq line_01_on cmp.b #h'05,r0h beq line_01_off rts line_04_on: mov.b @outputs_4,r3h bset r0l,r3h mov.b r3h,@outputs_4 rts line_04_off: mov.b @outputs_4,r3h bclr r0l,r3h mov.b r3h,@outputs_4 rts line_03_on: mov.b @outputs_3,r3l bset r0l,r3l mov.b r3l,@outputs_3 rts line_03_off: mov.b @outputs_3,r3l bclr r0l,r3l mov.b r3l,@outputs_3 rts line_02_on: mov.b @outputs_2,r2h bset r0l,r2h mov.b r2h,@outputs_2 rts line_02_off: mov.b @outputs_2,r2h bclr r0l,r2h mov.b r2h,@outputs_2 rts line_01_on: mov.b @outputs_1,r2l bset r0l,r2l mov.b r2l,@outputs_1 rts line_01_off: mov.b @outputs_1,r2l bclr r0l,r2l mov.b r2l,@outputs_1 rts