Prev: Vic-20 joystick help needed!
Next: Q-Link Reloaded
From: JB on 20 Oct 2009 21:56 Here is a working Swiftlink/Turbo232 Driver. Most of the code is from the Novaterm Source which was released to the public. Thanks Nick. It was compiled using 64Tass. Should be self explanitory but feel free to ask questions. Please Note. I am not the greatest ML programmer. I am sure there are better ways of doing some of these routines. So please, don't be a hater. If you have a better way, contact me and we can correct the code. Thanks for looking --------------------------------------------------------------------------------------------------------------------------------------------- ; WORKING SWIFTLINK DRIVER 10/20/2009 JEFF BROWN ; OPEN MODEM CHANNEL [OPEN 5,2,2,CHR$(6)] ; SYS ORIG = TEST FOR SWIFTLINK ; SYS ORIG+3 = SETUP NMI AND OTHER VECTORS ; SYS ORIG+6 = ENABLE SWIFTLINK INTERRUPTS ; ; YOU CAN USE PRINT#5 AND GET#5 COMMANDS FROM BASIC WITH THIS ROUTINE ; ; THANKS TO NICK ROSSI FOR MOST OF THIS CODE FROM HIS NOVATERM SOURCE ; AUTHORS OF CNET, IMAGE, CBASE HAVE ALSO BEEN AN INSPIRATION ; ; 64TASS FORMAT *= $C000 STOP = 1 START = 0 RTAIL = $029B RHEAD = $029C RFREE = $029D RFLOW = $029E IBSOUT = $0326 DEFTO = $9A CHKOUT = $FFC9 CHKIN = $FFC6 CHROUT = $FFD2 SWIFT = $DE00 ; CAN BE CHANGED TO DF00 OR D700 DEPENDING ON YOUR APPLICATION SW_DATA = SWIFT ; SWIFTLINK REGISTERS SW_STAT = SWIFT+1 SW_CMD = SWIFT+2 SW_CTRL = SWIFT+3 SW_BAUD = SWIFT+7 JMP TEST ; (0) TEST FOR SWIFTLINK HARDWARE JMP INIT ; (3) SETUP VECTORS AND DEFAULT BAUD RATE JMP INABLE ; (6) ENABLE SWIFTLINK JMP DISABL ; (9) DISABLE SL INTERRUPTS JMP CARCHK ; (12) CHECK FOR CARRIER 1 = CARRIER 0 = NO CARRIER JMP RSGET ; (15) GET BYTE FROM SWIFTLINK JMP JBGET ; (18) SAME AS RSGET BUT RETURNS 0 IF NO CHAR DOES NOT SET CARRY FLAG JMP RSOUT ; (21) OUTPUT BYTE THROUGH SWIFTLINK JMP SETBAUD ; (24) SET BAUD RATE JMP DROPDTR ; (27) DROP DTR TO HANG UP JMP TERM ; (30) SIMPLE TERMINAL MODE. F1 EXITS NMI PHA TXA PHA TYA PHA LDA SW_STAT AND #%00001000 ; MASK OUT ALL BUT RECEIVE INTERRUPT REG BNE NMI1 SEC ; SET CARRY UPON RETURN BCS RECCH1 NMI1 LDA SW_CMD ORA #%00000010 ; DISABLE RECEIVE INTERRUPTS STA SW_CMD RECCHAR LDA SW_DATA JSR PUTREC ; PUT CHAR IN REC BUFFER RECCH0 LDA SW_CMD AND #%11111101 ; RE-ENABLE RECEIVE INTERRUPT STA SW_CMD CLC RECCH1 PLA TAY PLA TAX PLA RTI SWWAIT LDA SW_CMD ORA #%00001000 ; ENABLE TRANSMITTER STA SW_CMD LDA SW_STAT AND #%00110000 BEQ SWWAIT RTS RSOUT STA $9E LDA SW_CMD STA TEMP JSR SWWAIT LDA $9E STA SW_DATA JSR SWWAIT LDA TEMP ; RESTORE RTS STATE STA SW_CMD LDA $9E CLC RTS RSGET STY $9F LDY RHEAD CPY RTAIL BEQ RET2 LDA ($F7),Y ;LDA RECBUF,Y RSGET1 INC RHEAD INC RFREE LDY PAUSED ; ARE WE STOPPED? BEQ RET0 ; NO, DON'T BOTHER PHA LDA RFREE ; CHECK BUFFER FREE CMP #240 ; AGAINST RESTART LIMIT BCC RSG1 ; IS IT LARGER TXA PHA LDX #START STX PAUSED JSR FLOW PLA TAX RSG1 PLA RET0 STA $9E RET1 CLC RET2 LDY $9F LDA $9E RTS INABLE LDA SW_CMD AND #%11111101 ; ENABLE RECEIVE INTERRUPT STA SW_CMD RTS DISABL LDA SW_CMD ORA #%00000010 ; DISABLE RECEIVE INTERRUPT STA SW_CMD RTS FLOW LDA SW_CMD AND #%11110011 CPX #STOP BEQ FL1 ORA #%00001000 FL1 STA SW_CMD RTS SETBAUD TAX LDA SW_CTRL AND #$F0 ORA SWBAUD,X STA SW_CTRL RTS BREAK LDA SW_CMD PHA ORA #%00001100 ; SEND BREAK STA SW_CMD BKRWAIT LDX #240 STX $A2 BR1 BIT $A2 BMI BR1 PLA STA SW_CMD RTS PUTREC LDX RFREE BEQ PR1 LDY RTAIL STA ($F7),Y INC RTAIL DEC RFREE PR1 CPX #50 ; CHECK BYTE COUNT AGAINST TOLERANCE BCC PR2 ; IS IT OVER THE TOP? LDX #STOP STX PAUSED JSR FLOW PR2 RTS TEST LDA #$09 STA SW_CMD LDA #0 STA SW_STAT LDA #11 STA SW_CMD LDA SW_CMD CMP #11 BNE TEST11 DEC TESTED LDA #0 TEST11 RTS INIT SEI LDA $318 LDX $319 STA OLDNMI STX OLDNMI+1 LDA $326 LDX $327 STA OLDOUT STX OLDOUT+1 LDA #<NEWOUT LDX #>NEWOUT STA $326 STX $327 LDA $32A LDX $32B STA OLDIN STX OLDIN+1 LDA #<NEWIN LDX #>NEWIN STA $32A STX $32B LDA #<NMI LDX #>NMI STA $0318 STX $0319 CLI LDA #$FF STA RFREE LDA #4 ;0=300, 1=1200, 2=2400,3=4800,4=9600, 5=19200, 6=38400 JSR SETBAUD LDA #0 RTS CARCHK LDA SW_STAT AND #64 BNE CAR11 LDA #1 RTS CAR11 LDA #0 RTS DROPDTR LDA SW_CMD AND #%11111110 STA SW_CMD LDX #226 STX $A2 WAIT30 BIT $A2 BMI WAIT30 ORA #%00000001 STA SW_CMD RTS NEWOUT PHA ;DUPLICIATON OF ORIGINAL KERNAL ROUTINES LDA $9A ;TEST DFAULT OUTPUT DEVICE FOR CMP #$02 ;SCREEN, AND... BEQ + PLA ;IF SO, GO BACK TO ORIGINAL ROM ROUTINES JMP (OLDOUT) + PLA JMP RSOUT NEWIN LDA $99 CMP #2 ; SEE IF DEFAULT INPUT IS MODEM BEQ + JMP (OLDIN) ; NOPE, GO BACK TO ORIGINAL + JMP JBGET ; GET CHAR FROM MODEM TERM LDA #0 TERMA JSR $FFCC JSR CARCHK STA $0400 JSR $FFE4 BEQ TERM1 CMP #133 BNE TERM2 RTS TERM2 CMP #172 ; COMMODRE-D = DROPDTR BNE TERMZZ JSR DROPDTR JMP TERM TERMZZ PHA LDX #5 JSR CHKOUT PLA JSR $FFD2 JMP TERMA TERM1 LDX #5 JSR CHKIN JSR $FFE4 BEQ TERMA JSR $FFD2 ;OUTPUT JMP TERM JBGET JSR RSGET ; THIS EMULATES THE STANDARD $FFE4 ROUTINE BCS + ; IF NO CHARACTER, THEN RETURN 0 IN A RTS + CLC LDA #0 RTS OLDNMI .WORD 0 OLDIN .WORD 0 OLDOUT .WORD 0 TEMP .BYTE 0 TESTED .BYTE 0 PAUSED .BYTE 0 SWBAUD .BYTE $15,$17,$18,$1A,$1C,$1E,$1F,$10,$10,$10
From: rusure on 21 Oct 2009 00:10 >; OPEN MODEM CHANNEL [OPEN 5,2,2,CHR$(6)] >; YOU CAN USE PRINT#5 AND GET#5 > COMMANDS FROM BASIC WITH THIS ROUTINE I don't know about other peoples' SWIFTLinks but mine plugs into the GAME or CARTRIDGE port unlike a modem which ordinarily plugs into the USER port. Is any communication with deviice #2 transmitted to a SWIFTLink with this code?
From: JB on 21 Oct 2009 07:49 On Oct 21, 12:10 am, rusure <r_u_s...(a)mybluelight.com> wrote: > >; OPEN MODEM CHANNEL [OPEN 5,2,2,CHR$(6)] > >; YOU CAN USE PRINT#5 AND GET#5 > > COMMANDS FROM BASIC WITH THIS ROUTINE > > I don't know about other peoples' SWIFTLinks but mine plugs into the > GAME or CARTRIDGE port unlike a modem which ordinarily plugs into the > USER port. Is any communication with deviice #2 transmitted to a > SWIFTLink with this code? Yes it works. The ML Redirects the CHROUT and GETIN vectors and checks to see if you are trying to get in/out from the modem if so it goes to the modem routines, if not, it goes to the stock routines. I added this to help improve compatibility with standard modem I/O programs such as protocols, etc.
From: stiggity on 23 Oct 2009 09:35 On Oct 21, 7:49 am, JB <jbrown1...(a)gmail.com> wrote: > On Oct 21, 12:10 am, rusure <r_u_s...(a)mybluelight.com> wrote: > > > >; OPEN MODEM CHANNEL [OPEN 5,2,2,CHR$(6)] > > >; YOU CAN USE PRINT#5 AND GET#5 > > > COMMANDS FROM BASIC WITH THIS ROUTINE > > > I don't know about other peoples' SWIFTLinks but mine plugs into the > > GAME or CARTRIDGE port unlike a modem which ordinarily plugs into the > > USER port. Is any communication with deviice #2 transmitted to a > > SWIFTLink with this code? > > Yes it works. > > The ML Redirects the CHROUT and GETIN vectors and checks to see if you > are trying to get in/out from the modem if so it goes to the modem > routines, if not, it goes to the stock routines. I added this to help > improve compatibility with standard modem I/O programs such as > protocols, etc. Boy those swiftlink routines look very familiar.. ehehe thanks novaterm!! eheheh
|
Pages: 1 Prev: Vic-20 joystick help needed! Next: Q-Link Reloaded |