home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-07-11 | 6.9 KB | 300 lines | [04] ASCII Text (0x0000) |
- ; *****************************
- ; * MULTI.SC1 *
- ; * (C) 1992, ERIC RANGELL *
- ; *****************************
- ;
- ;
- ; CHKEND - CHECK FOR END OF PART
- ;
- CHKEND LDX CURRTRK ;MOVE TO 1ST DATA BYTE
- LDA CURADRL,X
- STA DATAPTR
- LDA CURADRH,X
- STA DATAPTR+1
- LDY #$00
- FINDPOS LDA (DATAPTR),Y ;SKIP OVER THE DELAY
- BPL POSBYTE
- JSR INCDATAP
- CLV
- BVC FINDPOS
- POSBYTE JSR INCDATAP
- LDA DATAPTR ;NOW POINTING TO MIDI INSTRUCTION
- STA CURADRL,X
- LDA DATAPTR+1
- STA CURADRH,X
- LDA #$00 ;ASSUME NOT EOF
- STA EOFFLAG
- ; LDX CURRTRK ;(REDUNDANT CODE)
- ; LDA CURADRL,X
- ; STA DATAPTR
- ; LDA CURADRH,X
- ; STA DATAPTR+1
- LDY #$00
- LDA (DATAPTR),Y ; GET MIDI BYTE
- BPL RUNNING ; IF POSITIVE -> RUNNING STATUS
- STA CURRSTS ; ELSE WE GOT A STATUS BYTE
- AND #$7F ;
- TAX ; MASK HI BIT AND TRANSFER TO X
- LDA DBTABLE,X ; LOOK UP # DATA BYTES
- BMI SPECIAL ; IF SPECIAL CASE PROCESS F0 OR FF
- STA CURRDB ; STORE # DATABYTES
- LDX CURRTRK
- STA DBYTES,X
- LDA CURRSTS ; AND STATUS
- STA LASTSTAT,X
- RUNNING LDA DBYTES,X ; ADD NUMBER OF DATABYTES...
- STA CONVOUT+3
- LDA #$00
- STA CONVOUT+2
- STA CONVOUT+1
- STA CONVOUT
- CLC
- ADDIT LDA DATAPTR ; TO CURRENT DATA POINTER
- ADC CONVOUT+3
- STA ENDPTR
- LDA DATAPTR+1
- ADC CONVOUT+2
- STA ENDPTR+1
- LDA ENDPTR+1 ; COMPARE NEW ADRS TO UPPER LIMIT
- LDX CURRTRK
- CMP UPLIMH,X
- BNE ALLOK
- LDA ENDPTR
- CMP UPLIML,X
- BCC ALLOK
- SEC ;SIGNAL THAT NEED MORE DATA
- RTS ; OR
- ALLOK CLC ;EVERYTHINGS FINE
- RTS
- ;
- ; SPECIAL LOGIC HANDLES META EVENTS AND SYSEX EVENTS
- ; (CURRENTLY IGNORES ALL SYSEX AND META, EXCEPT END OF TRACK EVENT)
- ;
- CLC
- SPECIAL CMP #$FF ; IS IT A META EVENT?
- BNE SYSEX
- INY ; YES- GET NEXT BYTE (TYPE OF EVENT)
- LDA (DATAPTR),Y
- CMP #$2F ; IS IT END OF TRACK?
- BNE IGNORE ; NO - IGNORE THE EVENT
- LDA #$01 ; YES - SIGNAL EOF
- STA EOFFLAG
- SEC
- RTS
- IGNORE JSR INCDATAP ; SKIP OVER THE FF
- SYSEX JSR INCDATAP ; SKIP OVER THE F0 OR META EVENT TYPE
- JSR DELTA ; CONVERT THE VLQ FOR THE LENGTH
- LDA #$01
- STA METAFLAG ; SIGNAL PROCESSES NOT TO XMIT
- SEC
- BCS ADDIT ; RESUME PROCESSING ABOVE
- ; ; ADDS LENGTH TO CURRENT ADRS
- ;>>>> WE MAY HAVE PROBLEMS WITH SYSEX/META BOUNDARY TESTING AT END OF PAGE
- ;
- ;
- ; INCDATAP - ADD 1 TO DATA POINTER
- ;
- INCDATAP INC DATAPTR
- BNE INCDEXIT
- INC DATAPTR+1
- INCDEXIT RTS
- ;
- ; ENABLE ANY TRANSMISSIONS DISABLED BY METAFLAG
- ;
- ENBLXMIT LDA #$00
- STA METAFLAG
- RTS
- ;
- ; TIMER DELAY ROUTINE - SET UP DURATION
- ; AND CALL CNTLPANL REPEATEDLY UNTIL DURATION FINISHED
- ;
- DURHI DFB $00
- DURLO DFB $00
- READBYTE DFB $00
- ;
- TIMERDLY LDA SMALLEST+2
- STA DURHI
- LDA SMALLEST+3
- STA DURLO
- ;
- LDA DURHI
- BNE DOIT
- LDA DURLO
- BNE DOIT
- RTS
- ;
- DOIT LDX DURHI
- LDY DURLO
- LDA #'D'
- JSR TIMER
- ;
- DURLOOP JSR CNTLPANL
- ;
- LDA #'R'
- JSR TIMER
- STA READBYTE
- ;
- LDA KRETCODE ;GET OUT IF USER PRESSED SPACE
- BNE DUROUT
- LDA READBYTE
- BEQ DURLOOP
- DUROUT RTS
- ;
- ;=========
- ; APPLE DELAY ROUTINE
- ;
- APPLEDLY LDY SMALLEST+2
- LDX SMALLEST+3
- DONEYET CPY #$00
- BNE APPLED1
- CPX #$00
- BNE APPLED1
- RTS
- ;
- APPLED1 LDA SPEED
- JSR WAIT
- DEX
- CPX #$FF
- BNE DONEYET
- DEY
- CLV
- BVC DONEYET
- ;
- ;
- APPLSEND STA $C0A9
- WAITXMIT LDA $C0A8
- AND #$02
- BEQ WAITXMIT
- RTS
- ;
- ASAVE DFB $00
- XSAVE DFB $00
- YSAVE DFB $00
- PREVSTAT DFB $00
- ;
- ; QUEUEIT - IF ONE BYTE DELAY USE $FD XX, IF TWO USE $FF HI LO
- ;
- QUEUEIT STA ASAVE
- STX XSAVE
- STY YSAVE
- LDA SMALLEST+2
- BNE TWODUR
- LDA SMALLEST+3
- BNE ONEDUR
- RTS ;DON'T WRITE ZERO DURS
- ;
- TWODUR LDA #$FF
- JSR WRITEQ
- LDA SMALLEST+2
- JSR WRITEQ
- LODUR LDA SMALLEST+3
- JSR WRITEQ
- LDA ASAVE
- LDX XSAVE
- LDY YSAVE
- RTS
- ONEDUR LDA #$FD
- JSR WRITEQ
- CLV
- BVC LODUR
- ;
- WRITEQ STA QBYTE
- LDA #AUXQUEUE
- STA RECEIVER
- LDA #>QMSG
- STA MSG
- LDA #<QMSG
- STA MSG+1
- JSR USRVECT
- RTS
- ;
- ;
- PRCSDLY LDA FUNCTION
- AND #$7F ;STRIP OFF HI BIT
- CMP #$02
- BNE NOQUEUE
- JSR QUEUEIT
- RTS
- NOQUEUE JSR TIMERDLY
- ;;;;;;;; JSR APPLEDLY ;(OLD ROUTINE USED APPLE FCA8)
- RTS
- ;
- QMSG ASC 'E'
- QBYTE DFB $00
- XMSG ASC 'X'
- XBYTE DFB $00
- DFB $FF
- ;
- SENDIT STA ASAVE
- STX XSAVE
- STY YSAVE
- LDA FUNCTION
- AND #$7F
- CMP #$01 ;FUNCTION 1
- BNE FUNC02
- ;
- AUXQUEUE EQU 8
- MIDIFILT EQU 15
- RECEIVER EQU $FA
- MSG EQU $FB
- ;
- LDA ASAVE
- STA XBYTE
- ;
- LDA #MIDIFILT
- STA RECEIVER
- LDA #>XMSG
- STA MSG
- LDA #<XMSG
- STA MSG+1
- JSR USRVECT
- ;
- LDA ASAVE
- LDX XSAVE
- LDY YSAVE
- RTS
- ;
- FUNC02 CMP #$02 ;WHEN INSERTING INTO Q, CHECK FOR RUNNING STS
- BNE FUNC0
- LDA ASAVE
- BPL OUTQ
- CMP PREVSTAT
- BEQ RESTORE
- STA PREVSTAT
- ;
- OUTQ JSR WRITEQ
- ;
- RESTORE LDA ASAVE
- LDX XSAVE
- LDY YSAVE
- RTS
- ;
- FUNC0 LDA ASAVE
- JSR APPLSEND
- LDA ASAVE
- LDX XSAVE
- LDY YSAVE
- RTS
- ;
- PRCSMIDI LDA METAFLAG
- CMP #$01
- BNE NOTMETA
- JMP METAHNDL
- NOTMETA LDY #$00
- LDA (DATAPTR),Y
- BPL RUNNSTAT
- JSR INCDATAP ;SKIP STATUS BYTE
- RUNNSTAT LDX CURRTRK
- LDA LASTSTAT,X
- JSR SENDIT
- LDA DBYTES,X ;GET # DATABYTES IN X
- TAX
- SLOOP LDY #$00
- LDA (DATAPTR),Y
- JSR SENDIT ;SEND EACH DATA BYTE
- JSR INCDATAP
- DEX
- BNE SLOOP
- ;
- CHN MULTI.SC2
-