home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_26_1988_Transactor_Publishing.d64
/
newmodem.src
< prev
next >
Wrap
Text File
|
2023-02-26
|
9KB
|
249 lines
1100 ;---------------------------------------------
1110 ; "newmodem.src" - 64 mode.
1120 ; @128 = changes for 128 mode.
1130 ;---------------------------------------------
1140 ribuf =$f7 ;@128 $c8
1150 robuf =$f9 ;@128 $ca
1160 baudof =$0299 ;@128 $0a16
1170 ridbe =$029b ;@128 $0a18
1180 ridbs =$029c ;@128 $0a19
1190 rodbs =$029d ;@128 $0a1a
1200 rodbe =$029e ;@128 $0a1b
1210 enabl =$02a1 ;@128 $0a0f
1220 rstkey =$fe56 ;@128 $fa4b
1230 norest =$fe72 ;@128 $fa5f
1240 return =$febc ;@128 $ff33
1250 oldout =$f1ca ;@128 $ef79
1260 oldchk =$f21b ;@128 $f10e
1270 findfn =$f30f ;@128 $f202
1280 devnum =$f31f ;@128 $f212
1290 nofile =$f701 ;@128 $f682
1500 ;---------------------------------------------
1510 * =$ce00 ;@128 $1a00
1520 ;---------------------------------------------
1530 xx00 jmp setup
1540 xx03 jmp inable
1550 xx06 jmp disabl
1560 xx09 jmp rsget
1570 xx0c jmp rsout
1580 nop
1590 strt24 .word $01cb ; 459 start-bit times
1600 strt12 .word $0442 ;1090
1610 strt03 .word $1333 ;4915
1620 full24 .word $01a5 ; 421 full-bit times
1630 full12 .word $034d ; 845
1640 full03 .word $0d52 ;3410
1650 ;---------------------------------------------
2000 setup lda #<nmi64 ;@128 #<nmi128
2010 ldy #>nmi64 ;@128 #>nmi128
2020 sta $0318
2030 sty $0319
2040 lda #<nchkin
2050 ldy #>nchkin
2060 sta $031e
2070 sty $031f
2080 lda #<nbsout
2090 ldy #>nbsout
2100 sta $0326
2110 sty $0327
2120 rts
2130 ;---------------------------------------------
3000 nmi64 pha ;new nmi handler
3010 txa
3020 pha
3030 tya
3040 pha
3050 nmi128 cld
3060 ldx $dd07 ;sample timer b hi byte
3070 lda #$7f ;disable cia nmi's
3080 sta $dd0d
3090 lda $dd0d ;read/clear flags
3100 bpl notcia ;(restore key)
3110 cpx $dd07 ;tb timeout since 3060?
3120 ldy $dd01 ;(sample pin c)
3130 bcs mask ;no
3140 ora #$02 ;yes, set flag in acc.
3150 ora $dd0d ;read/clear flags again
3160 mask and enabl ;mask out non-enabled
3170 tax ;these must be serviced
3180 lsr ;timer a? (bit 0)
3190 bcc ckflag ;no
3200 lda $dd00 ;yes, put bit on pin m
3210 and #$fb
3220 ora $b5
3230 sta $dd00
3240 ckflag txa
3250 and #$10 ;*flag nmi? (bit 4)
3260 beq nmion ;no
3270 strtlo lda #$42 ;yes, start-bit to tb
3280 sta $dd06
3290 strthi lda #$04
3300 sta $dd07
3310 lda #$11 ;start tb counting
3320 sta $dd0f
3330 lda #$12 ;*flag nmi off, tb on
3340 eor enabl ;update mask
3350 sta enabl
3360 sta $dd0d ;enable new config.
3370 fulllo lda #$4d ;change reload latch
3380 sta $dd06 ; to full-bit time
3390 fullhi lda #$03
3400 sta $dd07
3410 lda #$08 ;# of bits to receive
3420 sta $a8
3430 bne chktxd ;branch always
3440 notcia ldy #$00
3450 jmp rstkey ;or jmp norest
3460 nmion lda enabl ;re-enable nmi's
3470 sta $dd0d
3480 txa
3490 and #$02 ;timer b? (bit 1)
3500 beq chktxd ;no
3510 tya ;yes, sample from 3120
3520 lsr
3530 ror $aa ;rs232 is lsb first
3540 dec $a8 ;byte finished?
3550 bne txd ;no
3560 ldy ridbe ;yes, byte to buffer
3570 lda $aa
3580 sta (ribuf),y ;(no overrun test)
3590 inc ridbe
3600 lda #$00 ;stop timer b
3610 sta $dd0f
3620 lda #$12 ;tb nmi off, *flag on
3630 switch ldy #$7f ;disable nmi's
3640 sty $dd0d ;twice
3650 sty $dd0d
3660 eor enabl ;update mask
3670 sta enabl
3680 sta $dd0d ;enable new config.
3690 txd txa
3700 lsr ;timer a?
3710 chktxd bcc exit ;no
3720 dec $b4 ;yes, byte finished?
3730 bmi char ;yes
3740 lda #$04 ;no, prep next bit
3750 ror $b6 ;(fill with stop bits)
3760 bcs store
3770 low lda #$00
3780 store sta $b5
3790 exit jmp return ;restore regs, rti
3800 char ldy rodbs
3810 cpy rodbe ;buffer empty?
3820 beq txoff ;yes
3830 getbuf lda (robuf),y ;no, prep next byte
3840 inc rodbs
3850 sta $b6
3860 lda #$09 ;# bits to send
3870 sta $b4
3880 bne low ;always - do start bit
3890 txoff ldx #$00 ;stop timer a
3900 stx $dd0e
3910 lda #$01 ;disable ta nmi
3920 bne switch ;always
3930 ;---------------------------------------------
4000 disabl pha ;turns off modem port
4010 test lda enabl
4020 and #$03 ;any current activity?
4030 bne test ;yes, test again
4040 lda #$10 ;no, disable *flag nmi
4050 sta $dd0d
4060 lda #$02
4070 and enabl ;currently receiving?
4080 bne test ;yes, start over
4090 sta enabl ;all off, update mask
4100 pla
4110 rts
4120 ;---------------------------------------------
5000 nbsout pha ;new bsout
5010 lda $9a
5020 cmp #$02
5030 bne notmod
5040 pla
5050 rsout sta $9e ;output to modem
5060 sty $97
5070 point ldy rodbe
5080 sta (robuf),y ;not official till 5120
5090 iny
5100 cpy rodbs ;buffer full?
5110 beq fulbuf ;yes
5120 sty rodbe ;no, bump pointer
5130 strtup lda enabl
5140 and #$01 ;transmitting now?
5150 bne ret3 ;yes
5160 sta $b5 ;no, prep start bit,
5170 lda #$09
5180 sta $b4 ; # bits to send,
5190 ldy rodbs
5200 lda (robuf),y
5210 sta $b6 ; and next byte
5220 inc rodbs
5230 lda baudof ;full tx bit time to ta
5240 sta $dd04
5250 lda baudof+1
5260 sta $dd05
5270 lda #$11 ;start timer a
5280 sta $dd0e
5290 lda #$81 ;enable ta nmi
5300 change sta $dd0d ;nmi clears flag if set
5310 php ;save irq status
5320 sei ;disable irq's
5330 ldy #$7f ;disable nmi's
5340 sty $dd0d ;twice
5350 sty $dd0d
5360 ora enabl ;update mask
5370 sta enabl
5380 sta $dd0d ;enable new config.
5390 plp ;restore irq status
5400 ret3 clc
5410 ldy $97
5420 lda $9e
5430 rts
5440 fulbuf jsr strtup
5450 jmp point
5460 notmod pla ;back to old bsout
5470 jmp oldout
5480 ;---------------------------------------------
6000 nchkin jsr findfn ;new chkin
6010 bne nosuch
6020 jsr devnum
6030 lda $ba
6040 cmp #$02
6050 bne back
6060 sta $99
6070 inable sta $9e ;enable rs232 input
6080 sty $97
6090 baud lda baudof+1 ;set receive to same
6100 and #$06 ; baud rate as xmit
6110 tay
6120 lda strt24,y
6130 sta strtlo+1 ;overwrite value @ 3270
6140 lda strt24+1,y
6150 sta strthi+1
6160 lda full24,y
6170 sta fulllo+1
6180 lda full24+1,y
6190 sta fullhi+1
6200 lda enabl
6210 and #$12 ;*flag or tb on?
6220 bne ret1 ;yes
6230 sta $dd0f ;no, stop tb
6240 lda #$90 ;turn on flag nmi
6250 jmp change
6260 nosuch jmp nofile
6270 back lda $ba
6280 jmp oldchk
6290 ;---------------------------------------------
7000 rsget sta $9e ;input from modem
7010 sty $97
7020 ldy ridbs
7030 cpy ridbe ;buffer empty?
7040 beq ret2 ;yes
7050 lda (ribuf),y ;no, fetch character
7060 sta $9e
7070 inc ridbs
7080 ret1 clc ;cc = char in acc.
7090 ret2 ldy $97
7100 lda $9e
7110 last rts ;cs = buffer was empty