LLUCE/Config/MODEMS/SSC.S.A

388 lines
5.5 KiB
Plaintext

* Numeric SSC driver rewritten by Andy Nicholas
* October 27, 1988
*-------------------------------
rel
dsk rel/ssc
cr equ $0d
lf equ $0a
data equ $c088
status equ $c089
command equ $c08a
control equ $c08b
initstr equ $10d0
ansstr equ $10c0
cdbyte equ $10bf
*-------------------------------
ssc ent
org $b00
* jump table
*-------------------------------
slot hex 20 ;serial card slot*16
initspd hex 00
callspd dfb 0 ;speed of call
bytcnt dfb 0,0,0
jmp init
jmp ringset
jmp ring
jmp answerRing
jmp hangup
jmp inp
jmp out
jmp chkdcd
jmp setspd
jmp raisedtr
* init the serial card
*-------------------------------
init lda #0 ;reset bytes
ldx slot
sta status,x ;reset uart
sta command,x ;reset command
clc
txa
adc #<data
sta dataloc+1 ;make into absolute save
rts
* setup for call
*-------------------------------
ringset ldx slot ;get offset
lda #%00000000 ;kill DTR, RTS
sta command,x
lda #0 ;let modem reset
jsr wait
jsr wait
lda #%00001011 ;turn on DTR, RTS
sta command,x
sei
ldy initspd ;set init speed
jsr setspd
lda data,x ;clear data strobe
lda #0 ;slight delay (let modem do init)
jsr wait
ldx #0
:loop lda #$80
jsr wait
lda initstr,x ;get modem init string
beq rset3
jsr out ;output
inx
bne :loop
rset3 lda #6
sta countlo
sta counthi
rset4 ldy #$FF
rset5 dey
beq decount
jsr inp
bcc rset5
and #$7f
cmp #'0' ;check for "OK" (numeric)
beq leave
jmp rset5
decount dec countlo
bne rset4
dec counthi
bne rset4
jmp ringset
leave jsr inp ;grab the <cr> off the tail end of the "0"
bcc leave
lda #0
sta bytcnt ;reset byte counter
sta bytcnt+1
sta bytcnt+2
clc
rts return
jring jmp ringset ;extend branch to ringset
* scan for ring and handle it
*-------------------------------
ring jsr inp ;check for a char
bcc noRing ;nope...
and #$7f ;strip high
cmp #'2' ;is it a 'ring'? (numeric)
bne notRing ;nope, check for connect messages
********************************
grabCR jsr inp ;grab the <cr> off the tail end of the "2"
bcc grabCR
answerRing jsr answer ;the phone rang, so send 'ATA'
clc
rts
********************************
notRing
cmp #'1' ;is it a '1' or '10' or '11' or '12' or '14'?
beq gotCode ;yes, save it
cmp #'5' ;is it connect 1200?
bne noRing ;nope
gotCode sta code
secondChar jsr inp ;second character will ALWAYS be there
bcc secondChar
and #$7f ;strip high
cmp #cr ;but might be a <cr>
bne multiCode
********************************
singleCode ldy #0 ;connect 300?
lda code
cmp #'1'
beq ring3
iny
cmp #'5' ;connect 1200?
beq ring3 ;nope, unknown code, keep checking
jmp noRing
********************************
multiCode
sta code+1
ldy #2 ;def = 2400 baud
lda code ;get the first code char
cmp #'1' ;must be a one
bne noRing ;if not, then keep trying
lda code+1 ;is it 2400?
cmp #'0'
beq ring3
iny
cmp #'1' ;is it 4800?
beq ring3
iny
cmp #'2' ;is it 9600
beq ring3
iny
cmp #'4' ;is it 19200?
beq ring3
dey
cmp #'7' ;is it 9600/ARQ?
beq ring3
dey ;no 4800/arq
dey
cmp #'6'
beq ring3 ;2400/ARQ
dey
cmp #'5' ;1200/ARQ
beq ring3
jmp noRing
********************************
ring3 jsr setspd ;set the correct speed
ldy #5
ring4 lda #0 ;let carrier's settle
jsr wait
dey
bne ring4
sec ;we have a connection!
rts
noring clc
rts
* send ata to phone
*-------------------------------
answer lda #$80
jsr wait
ldx #0
answer2 lda ansstr,x ;get text
beq answer3 ;we are done
jsr out ;send it
lda #$80
jsr wait
inx
bne answer2 ;loop
answer3 rts
* hangup phone
*-------------------------------
hangup ldx slot ;get offset
lda #0
sta command,x ;hang up phone
rts
* input data
*-------------------------------
inp stx save_x ;save X
ldx slot ;get offset
lda status,x ;get status
and #%00001000
clc
beq inp2 ;no data
lda data,x
sec
inp2 ldx save_x ;restore & return
rts
* output data
*-------------------------------
out stx save_x ;save x
dec timecnt ;count down 1 section
bne out1
inc bytcnt ;1 second gone by
bit bytcnt
bvc out1
ldx #0 ;reset seconds
stx bytcnt
inc bytcnt+1 ;1 minute gone by
bit bytcnt+1
bvc out1
ldx #0 ;reset minutes
stx bytcnt+1
inc bytcnt+2 ;1 hour gone by
out1 ldx slot
pha
out2 lda status,x ;check status
and #%00010000
beq out2 ;loop until ready
pla
dataloc sta data ;self modified
ldx save_x
rts
* check for carrier
*-------------------------------
chkdcd stx save_x ;dont kill any reg's
pha
ldx slot ;get offset
lda status,x
and cdbyte ;check carrier
clc
bne chkdcd2
sec
chkdcd2 pla restore ;all & return
ldx save_x
rts
* set the rs-232 speed/speed in Y reg
*-------------------------------
setspd stx save_x
ldx slot ;get offset
lda speed,y ;get speed
sta control,x ;set speed
lda #1 ;find caller speed (x300)
sta callspd
cpy #0 ;at 300?
beq setspd3 ;yep
asl callspd ;speed = speed * 2
setspd2 asl callspd ;speed = speed * 2
dey
bne setspd2 ;loop until correct speed found
setspd3 ldx save_x ;restore & return
rts
*-------------------------------
* turn on dtr/rts
raisedtr stx save_x
ldx slot
lda #%00001011 ;turn on DTR, RTS
sta command,x
sei
ldx save_x
rts
* wait routine
*-------------------------------
wait sec
wait2 pha
wait3 sbc #1
bne wait3
pla
sbc #1
bne wait2
rts
* global data area
*-------------------------------
speed dfb %00010110 ;300
dfb %00011000 ;1200
dfb %00011010 ;2400
dfb %00011100 ;4800
dfb %00011110 ;9600
dfb %00011111 ;19200
timecnt dfb 0 ;1-second counter
save_x dfb 0
countlo dfb $FF
counthi dfb $FF
code ds 2 ;the code we got from the modem
asc 'SSC/Numeric'