A2osX/BIN/IRC.S.txt

1153 lines
20 KiB
Plaintext
Raw Permalink Normal View History

2020-06-18 15:13:56 +00:00
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/irc
*--------------------------------------
2023-10-18 05:41:12 +00:00
TLS .EQ 0
2020-06-18 15:13:56 +00:00
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
2020-06-23 06:19:11 +00:00
.INB inc/mli.i
2022-04-19 18:24:34 +00:00
.INB inc/mli.e.i
2020-06-18 15:13:56 +00:00
.INB inc/eth.i
.INB inc/libtcpip.i
.DO TLS=1
.INB inc/net.tls.i
.FIN
2020-06-18 15:13:56 +00:00
*--------------------------------------
2021-03-11 21:40:55 +00:00
TIMEOUT.MAX .EQ 250 25 sec.
2021-03-15 15:00:27 +00:00
MSGSIZE .EQ 4096
2020-06-24 14:39:11 +00:00
TEXTMAX .EQ 240
2020-06-18 15:13:56 +00:00
*--------------------------------------
* https://tools.ietf.org/html/rfc2812#section-3.3
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
2020-06-24 14:39:11 +00:00
ZPPtr1 .BS 2
ZPPtr2 .BS 2
2021-03-12 12:50:03 +00:00
bEscMode .BS 1
bJoin .BS 1
TimeOut .BS 1
2021-03-13 16:11:47 +00:00
hSocket .BS 1
2020-06-24 14:39:11 +00:00
2021-03-12 12:50:03 +00:00
ZPRespPtr .BS 2
2021-03-13 16:11:47 +00:00
ZPMsg .BS 2
2020-06-24 06:12:43 +00:00
ZPMsgPtr .BS 2
2021-03-13 16:11:47 +00:00
ZPOutputBufPtr .BS 2
2020-06-26 19:34:12 +00:00
2020-06-24 14:39:11 +00:00
ZPMsgPfxPtr .BS 2
ZPMsgCmdPtr .BS 2
ZPMsgArgPtr .BS 2
ZPMsgExtPtr .BS 2
2020-06-22 05:59:53 +00:00
2021-03-13 16:11:47 +00:00
BufPtr .BS 1
BufLen .BS 1
ZPBufPtr .BS 2
TextPtr .BS 1
TextLen .BS 1
2021-03-13 16:11:47 +00:00
bPendingMsg .BS 1
2021-03-11 21:40:55 +00:00
ZS.END .ED
2020-06-18 15:13:56 +00:00
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA #S.PS.F.EVENT S.PS.F
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #64 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.DA 0
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
2020-06-19 15:20:59 +00:00
.DA CS.DOEVENT
2020-06-18 15:13:56 +00:00
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.SA.LOCAL .DA SA.LOCAL
L.SA.REMOTE .DA SA.REMOTE
L.SA.REMOTE.AD .DA SA.REMOTE+S.SOCKADDR.ADDR
L.MSG.IPKO .DA MSG.IPKO
L.MSG.USAGE .DA MSG.USAGE
L.MSG.UNKNOWN .DA MSG.UNKNOWN
L.MSG.HOSTOK .DA MSG.HOSTOK
L.MSG.SKTKO .DA MSG.SKTKO
L.MSG.SKTOK .DA MSG.SKTOK
L.MSG.SKTERR .DA MSG.SKTERR
2021-03-12 12:50:03 +00:00
L.MSG.REGISTER .DA MSG.REGISTER
2020-06-22 05:59:53 +00:00
L.MSG.JOIN .DA MSG.JOIN
2020-06-18 15:13:56 +00:00
L.MSG.TOPBAR .DA MSG.TOPBAR
2020-06-19 15:20:59 +00:00
L.MSG.STATUSBAR .DA MSG.STATUSBAR
2020-06-25 15:39:51 +00:00
L.MSG.STATUSBARMSG .DA MSG.STATUSBARMSG
2021-03-12 12:50:03 +00:00
L.MSG.NULL .DA MSG.NULL
L.IRC.REGISTER .DA IRC.REGISTER
2020-06-18 15:13:56 +00:00
L.IRC.JOIN .DA IRC.JOIN
2020-06-19 06:33:47 +00:00
L.IRC.JOINKEY .DA IRC.JOINKEY
2020-06-24 06:12:43 +00:00
L.IRC.PONG .DA IRC.PONG
2020-06-29 05:49:24 +00:00
L.IRC.PART .DA IRC.PART
2020-07-10 20:38:49 +00:00
L.IRC.NAMES .DA IRC.NAMES
2020-07-09 19:45:51 +00:00
L.IRC.PRIVMSG .DA IRC.PRIVMSG
2020-06-18 15:13:56 +00:00
L.SEQ.INIT .DA SEQ.INIT
2020-06-19 06:33:47 +00:00
L.SEQ.BAR .DA SEQ.BAR
2020-06-19 15:20:59 +00:00
L.SEQ.TXTCLR .DA SEQ.TXTCLR
2020-06-24 14:39:11 +00:00
L.SEQ.PRIVMSG .DA SEQ.PRIVMSG
2020-06-26 19:34:12 +00:00
L.SEQ.INFOMSG .DA SEQ.INFOMSG
2020-06-24 14:39:11 +00:00
L.SEQ.DUMPMSG .DA SEQ.DUMPMSG
2020-06-19 06:33:47 +00:00
L.SEQ.RESET .DA SEQ.RESET
2020-06-24 14:39:11 +00:00
L.IRC.CMDS .DA IRC.CMDS
2021-03-12 12:50:03 +00:00
J.IRC.CMDS .DA CS.RUN.CMD.PING
.DA CS.RUN.CMD.JOIN
2020-07-10 20:38:49 +00:00
.DA CS.RUN.CMD.PART
2021-03-13 16:11:47 +00:00
.DA CS.RUN.CMD.QUIT
2020-06-24 14:39:11 +00:00
.DA CS.RUN.CMD.PRIVMSG
.DA CS.RUN.CMD.MODE
2021-03-12 12:50:03 +00:00
.DA CS.RUN.CMD.001
2020-06-25 21:20:22 +00:00
.DA CS.RUN.CMD.353
2020-06-26 19:34:12 +00:00
.DA CS.RUN.CMD.375
.DA CS.RUN.CMD.372
.DA CS.RUN.CMD.376
2020-06-19 15:20:59 +00:00
J.ESC .DA CS.RUN.CHARIN.LEFT
.DA CS.RUN.CHARIN.DOWN
.DA CS.RUN.CHARIN.UP
.DA CS.RUN.CHARIN.RIGHT
.DO TLS=1
L.MSG.TLS .DA MSG.TLS
2022-04-19 18:24:34 +00:00
L.MSG.TLS.HDR .DA MSG.TLS.HDR
2022-04-07 17:19:48 +00:00
L.MSG.TLSKO .DA MSG.TLSKO
L.TLS.CHELLO .DA TLS.CHELLO
L.TLS.CHELLO.UT .DA TLS.CHELLO.UT
.FIN
2020-06-18 15:13:56 +00:00
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib
bcs .9
2021-03-11 21:40:55 +00:00
2020-06-18 15:13:56 +00:00
sta hLIBTCPIP
2021-03-11 21:40:55 +00:00
.9
CS.INIT.RTS rts
2020-06-18 15:13:56 +00:00
*--------------------------------------
2021-03-11 21:40:55 +00:00
CS.RUN jsr CS.RUN.CheckTCPIP
bcs CS.INIT.RTS
2020-06-25 15:39:51 +00:00
2021-03-11 21:40:55 +00:00
jsr CS.RUN.CheckArgs
bcs CS.INIT.RTS
2021-03-12 12:50:03 +00:00
jsr CS.RUN.GetBuffers
bcs CS.INIT.RTS
2021-03-11 21:40:55 +00:00
jsr CS.RUN.Connect
bcs CS.INIT.RTS
2020-06-19 15:20:59 +00:00
.DO TLS=1
jsr CS.RUN.TLS
2021-03-11 21:40:55 +00:00
bcs CS.INIT.RTS
.FIN
2021-03-11 21:40:55 +00:00
jsr CS.RUN.SCRSETUP
bcs CS.INIT.RTS
2021-03-13 16:11:47 +00:00
jsr CS.RUN.Register
2021-03-11 21:40:55 +00:00
bcs CS.INIT.RTS
CS.RUN.LOOP >SLEEP
jsr CS.RUN.GetMsg
bcs .9
2021-03-13 16:11:47 +00:00
bne .2
jsr CS.RUN.SplitMsg
bcs .2
2021-03-11 21:40:55 +00:00
2021-03-13 16:11:47 +00:00
jsr CS.RUN.ProcessMsg
2021-03-11 21:40:55 +00:00
bcs .9
2021-03-12 12:50:03 +00:00
2021-03-11 21:40:55 +00:00
>SLEEP
2020-06-18 15:13:56 +00:00
2021-03-11 21:40:55 +00:00
.2 ldy #S.PS.hStdIn
2020-06-18 15:13:56 +00:00
lda (pPS),y
2021-03-11 21:40:55 +00:00
>SYSCALL FEOF
bcs .9
tay
bne CS.RUN.LOOP EOF = true, no char from STDIN
>SYSCALL GetChar
bcs .9
jsr CS.RUN.CHARIN
bcc CS.RUN.LOOP
.9 php
pha
>PUSHW L.SEQ.RESET
>PUSHBI 0
>SYSCALL PrintF
pla
plp
rts
*--------------------------------------
CS.RUN.CheckTCPIP
>LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ?
bcs .9
2021-03-12 12:50:03 +00:00
2021-03-11 21:40:55 +00:00
>STYA ZPPtr1
lda (ZPPtr1) Configured ?
bpl .99
2021-03-12 12:50:03 +00:00
2020-06-18 15:13:56 +00:00
ldy #S.IPCFG.IP+3
ldx #3
2020-06-24 14:39:11 +00:00
.1 lda (ZPPtr1),y
2020-06-18 15:13:56 +00:00
sta SA.LOCAL+S.SOCKADDR.ADDR,x
dey
dex
bpl .1
2021-03-12 12:50:03 +00:00
2021-03-11 21:40:55 +00:00
rts
2020-06-18 15:13:56 +00:00
2021-03-11 21:40:55 +00:00
.99 >LDYA L.MSG.IPKO
>SYSCALL PutS
lda #E.SYN
sec
.9 rts
*--------------------------------------
CS.RUN.CheckArgs
ldy #S.PS.ARGC
lda (pPS),y
cmp #3
bcs .1
2020-06-18 15:13:56 +00:00
2021-03-11 21:40:55 +00:00
>LDYA L.MSG.USAGE
>SYSCALL PutS
2020-06-19 15:20:59 +00:00
2021-03-11 21:40:55 +00:00
lda #E.SYN
sec
rts
.1 lda #TIMEOUT.MAX
sta TimeOut
.2 >PUSHW L.SA.REMOTE.AD
2020-06-18 15:13:56 +00:00
lda #1
>SYSCALL ArgV
>PUSHYA
2020-08-25 10:56:00 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GetByName
2021-03-11 21:40:55 +00:00
bcc .3
>SLEEP
2020-08-25 10:56:00 +00:00
lda TimeOut
2020-06-18 15:13:56 +00:00
bne .2
>PUSHW L.MSG.UNKNOWN
lda #1
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
>SYSCALL PrintF
2021-03-11 21:40:55 +00:00
lda #ERR.SKT.NOCONN
2020-06-18 15:13:56 +00:00
sec
2021-03-12 12:50:03 +00:00
rts
2020-06-18 15:13:56 +00:00
2021-03-11 21:40:55 +00:00
.3 lda #2
2020-06-18 15:13:56 +00:00
>SYSCALL ArgV
2020-08-25 10:56:00 +00:00
>SYSCALL AToI
2020-06-18 15:13:56 +00:00
>STYA SA.REMOTE+S.SOCKADDR.PORT
>PUSHW L.MSG.HOSTOK
ldx #0
2021-03-11 21:40:55 +00:00
.4 >PUSHB SA.REMOTE+S.SOCKADDR.ADDR,x
2020-06-18 15:13:56 +00:00
inx
cpx #4
2021-03-11 21:40:55 +00:00
bne .4
2020-06-18 15:13:56 +00:00
>PUSHW SA.REMOTE+S.SOCKADDR.PORT
lda #1
>SYSCALL ArgV
>PUSHYA
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
>PUSHBI 8
>SYSCALL PrintF
2021-03-11 21:40:55 +00:00
rts
*--------------------------------------
CS.RUN.GetBuffers
2022-04-19 18:24:34 +00:00
>LDYAI 5120
>SYSCALL GetMem
bcs .9
>STYA ZPBufPtr
txa
>STA.G hBufBuf
>LDYAI MSGSIZE
>SYSCALL GetMem
bcs .9
>STYA ZPMsg
txa
>STA.G hMsgBuf
>LDYAI 384
>SYSCALL GetMem
bcs .9
>STYA ZPRespPtr
txa
>STA.G hRespBuf
>LDYAI 256
>SYSCALL GetMem
bcs .9
>STYA ZPOutputBufPtr
txa
>STA.G hOutputBuf
.9 rts
*--------------------------------------
2021-05-19 12:44:47 +00:00
CS.RUN.Connect >PUSHBI S.SOCKET.T.STREAM
>PUSHBI 0 no protocol
2020-06-18 15:13:56 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket
bcs .9
sta hSocket
2021-05-19 12:44:47 +00:00
>PUSHA
2020-06-18 15:13:56 +00:00
>PUSHW L.SA.LOCAL
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind
2021-03-11 21:40:55 +00:00
bcs .9
2020-06-18 15:13:56 +00:00
2021-03-11 21:40:55 +00:00
lda #TIMEOUT.MAX
2020-06-18 15:13:56 +00:00
sta TimeOut
2021-03-11 21:40:55 +00:00
.1 >SLEEP
2021-03-12 12:50:03 +00:00
2021-05-19 12:44:47 +00:00
>PUSHB hSocket
2020-06-18 15:13:56 +00:00
>PUSHW L.SA.REMOTE
>LIBCALL hLIBTCPIP,LIBTCPIP.Connect
2021-03-11 21:40:55 +00:00
bcc .8
2020-06-18 15:13:56 +00:00
2021-03-11 21:40:55 +00:00
ldx TimeOut
bne .1
2020-06-19 15:20:59 +00:00
2021-03-11 21:40:55 +00:00
.9 pha
>LDYA L.MSG.SKTKO
>SYSCALL PutS
pla
sec
rts
2020-06-18 15:13:56 +00:00
2021-03-11 21:40:55 +00:00
.8 >PUSHW L.MSG.SKTOK
2020-06-18 15:13:56 +00:00
>PUSHBI 0
>SYSCALL PrintF
rts
2020-06-19 15:20:59 +00:00
*--------------------------------------
2021-03-13 16:11:47 +00:00
CS.RUN.Register >LDYA L.MSG.REGISTER
2020-06-25 15:39:51 +00:00
jsr CS.RUN.STATUSMSG
2020-06-22 05:59:53 +00:00
2021-03-11 21:40:55 +00:00
>PUSHW ZPRespPtr
2021-03-12 12:50:03 +00:00
>PUSHW L.IRC.REGISTER
2020-06-22 05:59:53 +00:00
lda #3 nickname
>SYSCALL ArgV
>PUSHYA
2020-06-18 15:13:56 +00:00
lda #3 nickname
>SYSCALL ArgV
>PUSHYA
lda #3 nickname
>SYSCALL ArgV
>PUSHYA
2021-03-12 12:50:03 +00:00
lda #3 nickname
>SYSCALL ArgV
>PUSHYA
>PUSHBI 8
2021-03-11 21:40:55 +00:00
>SYSCALL SPrintF
bcs .9
jsr CS.RUN.SendMsg
2020-06-18 15:13:56 +00:00
2020-06-24 06:12:43 +00:00
.9 rts
2020-06-22 05:59:53 +00:00
*--------------------------------------
2021-03-13 16:11:47 +00:00
CS.RUN.GetMsg bit bPendingMsg
bmi .10
2021-03-13 16:11:47 +00:00
>LDYA ZPMsg
>STYA ZPMsgPtr
.10 ldy BufLen
bne .2
2021-05-19 12:44:47 +00:00
.1 >PUSHB hSocket
2021-03-13 16:11:47 +00:00
>PUSHW ZPBufPtr
2021-05-19 12:44:47 +00:00
>PUSHWI 255
2021-03-13 16:11:47 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Read
bcs .7
sty BufLen
stz BufPtr
.2 ldy BufPtr
lda (ZPBufPtr),y
cmp #C.CR
2021-03-15 15:00:27 +00:00
beq .3
2021-03-13 16:11:47 +00:00
cmp #C.LF
2021-03-15 15:00:27 +00:00
beq .6
2021-03-13 16:11:47 +00:00
sta (ZPMsgPtr)
inc ZPMsgPtr
bne .3
2021-03-13 16:11:47 +00:00
inc ZPMsgPtr+1
.3 inc BufPtr
dec BufLen
bne .2
bra .1
2021-03-15 15:00:27 +00:00
.6 inc BufPtr Skip LF
2021-03-13 16:11:47 +00:00
dec BufLen
2020-06-25 15:39:51 +00:00
2021-03-13 16:11:47 +00:00
stz bPendingMsg
lda #0
sta (ZPMsgPtr) will exit with Z
clc
rts
.7 cmp #E.NODATA
bne .9
.8 lda #$80 will exit with NZ
sta bPendingMsg
clc
.9 rts
*--------------------------------------
CS.RUN.SplitMsg >LDYA L.MSG.NULL
>STYA ZPMsgPfxPtr
>STYA ZPMsgCmdPtr
>STYA ZPMsgArgPtr
>STYA ZPMsgExtPtr
ldy #0
ldx #0
lda (ZPMsg)
cmp #':' do we have a prefix ?
bne .2
lda ZPMsg
clc
adc #1
sta ZPMsgPfxPtr
lda ZPMsg+1
adc #0
sta ZPMsgPfxPtr+1
.1 iny
lda (ZPMsg),y
beq .9
cmp #C.SPACE
bne .1
lda #0
sta (ZPMsg),y End Of prefix
iny Skip blank
tya
tax Save CMD start pos
.2 iny
lda (ZPMsg),y
beq .4
.3 cmp #C.SPACE scan until end of CMD
bne .2
lda #0
sta (ZPMsg),y End of CMD
iny Skip blank
.4 php
txa
clc
adc ZPMsg
sta ZPMsgCmdPtr
lda #0
adc ZPMsg+1
sta ZPMsgCmdPtr+1
plp
beq .80
tya
tax Save Arg start pos
lda (ZPMsg),y
cmp #':'
beq .71 no arg....ext
.6 iny
lda (ZPMsg),y
beq .7
cmp #':' ARGS could be "ARG1 ARG2 ARG3"
bne .6
lda #0
sta (ZPMsg),y
iny Skip :
.7 php
txa
clc
adc ZPMsg
sta ZPMsgArgPtr
lda #0
adc ZPMsg+1
sta ZPMsgArgPtr+1
plp
beq .80
lda (ZPMsg),y
cmp #':'
bne .8
.71 iny Skip blank
.8 tya
clc
adc ZPMsg
sta ZPMsgExtPtr
lda #0
adc ZPMsg+1
sta ZPMsgExtPtr+1
.80 clc
rts
.9 sec
rts
**--------------------------------------
CS.RUN.ProcessMsg
2021-03-12 12:50:03 +00:00
>LDYA L.IRC.CMDS
2020-06-24 14:39:11 +00:00
>STYA ZPPtr1
2020-06-19 15:20:59 +00:00
2020-06-24 14:39:11 +00:00
ldx #0
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
.1 lda (ZPPtr1)
2020-06-24 06:12:43 +00:00
beq .8
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
ldy #$ff
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
.2 iny
lda (ZPPtr1),y
cmp (ZPMsgCmdPtr),y
bne .3
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
ora #0
bne .2
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
jmp (J.IRC.CMDS,x)
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
.3 ora #0
beq .5
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
.4 iny
lda (ZPPtr1),y
bne .4
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
.5 inx
inx
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
tya
sec
adc ZPPtr1
sta ZPPtr1
bcc .1
inc ZPPtr1+1
bra .1
2020-06-24 06:12:43 +00:00
.8 clc
.9 rts
2020-06-18 15:13:56 +00:00
*--------------------------------------
2021-03-12 12:50:03 +00:00
CS.RUN.CMD.PING >PUSHW ZPRespPtr
>PUSHW L.IRC.PONG
>PUSHW ZPMsgExtPtr
2020-07-10 20:38:49 +00:00
>PUSHBI 2
2021-03-11 21:40:55 +00:00
>SYSCALL SPrintF
bcs .9
jsr CS.RUN.SendMsg
2021-03-12 12:50:03 +00:00
2021-03-11 21:40:55 +00:00
.9 rts
2020-06-26 19:34:12 +00:00
*--------------------------------------
2021-03-12 12:50:03 +00:00
CS.RUN.CMD.JOIN sec
ror bJoin
2021-03-12 12:50:03 +00:00
>LDYA L.MSG.NULL
jsr CS.RUN.STATUSPDATE
*--------------------------------------
2021-03-13 16:11:47 +00:00
CS.RUN.CMD.PART
CS.RUN.CMD.QUIT >PUSHW ZPRespPtr
2021-03-12 12:50:03 +00:00
>PUSHW L.IRC.NAMES
lda #4 channel
>SYSCALL ArgV
>PUSHYA
2021-03-11 21:40:55 +00:00
>PUSHBI 2
>SYSCALL SPrintF
bcs .9
jsr CS.RUN.SendMsg
.9 rts
2020-06-24 14:39:11 +00:00
*--------------------------------------
CS.RUN.CMD.PRIVMSG
2020-06-26 19:34:12 +00:00
ldy #0
2021-03-12 12:50:03 +00:00
2020-06-26 19:34:12 +00:00
.1 iny
lda (ZPMsgPfxPtr),y
beq .2
2023-10-18 05:41:12 +00:00
2020-06-26 19:34:12 +00:00
eor #'!'
bne .1
2021-03-12 12:50:03 +00:00
2023-10-18 05:41:12 +00:00
.2 sta (ZPMsgPfxPtr),y
2020-06-26 19:34:12 +00:00
2023-10-18 05:41:12 +00:00
>PUSHW L.SEQ.PRIVMSG
2020-06-25 15:39:51 +00:00
2020-06-25 21:20:22 +00:00
>PUSHW ZPMsgPfxPtr
2020-06-24 14:39:11 +00:00
>PUSHW ZPMsgExtPtr
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
>PUSHBI 4
>SYSCALL PrintF
2023-10-18 05:41:12 +00:00
2020-06-24 14:39:11 +00:00
rts
*--------------------------------------
2020-06-25 15:39:51 +00:00
CS.RUN.CMD.MODE
2020-06-24 14:39:11 +00:00
clc
rts
*--------------------------------------
2021-03-12 12:50:03 +00:00
CS.RUN.CMD.001 jsr CS.RUN.CMD.INFO
>LDYA L.MSG.JOIN
jsr CS.RUN.STATUSMSG
>PUSHW ZPRespPtr
lda #5 key
>SYSCALL ArgV
bcs .1
>PUSHW L.IRC.JOINKEY
lda #4 channel
>SYSCALL ArgV
>PUSHYA
lda #5 key
>SYSCALL ArgV
>PUSHYA
>PUSHBI 4
bra .2
.1 >PUSHW L.IRC.JOIN
lda #4 channel
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
.2 >SYSCALL SPrintF
bcs .9
jsr CS.RUN.SendMsg
.9 rts
*--------------------------------------
2021-03-13 16:11:47 +00:00
CS.RUN.CMD.353 ldy #80
lda #0
sta (ZPMsgExtPtr),y
>LDYA ZPMsgExtPtr RPL_NAMREPLY
2020-06-25 21:20:22 +00:00
jmp CS.RUN.STATUSPDATE
2021-03-12 12:50:03 +00:00
*--------------------------------------
2020-06-26 19:34:12 +00:00
CS.RUN.CMD.372
2021-03-12 12:50:03 +00:00
CS.RUN.CMD.375
2020-06-26 19:34:12 +00:00
CS.RUN.CMD.376
2021-03-12 12:50:03 +00:00
CS.RUN.CMD.INFO >PUSHW L.SEQ.INFOMSG
2020-06-26 19:34:12 +00:00
>PUSHW ZPMsgExtPtr
>PUSHBI 2
>SYSCALL PrintF
rts
2020-06-25 21:20:22 +00:00
*--------------------------------------
2021-03-13 16:11:47 +00:00
CS.RUN.DUMPMSG >PUSHW L.SEQ.DUMPMSG
2021-03-12 12:50:03 +00:00
2021-03-13 16:11:47 +00:00
>PUSHW ZPMsgPfxPtr
>PUSHW ZPMsgCmdPtr
>PUSHW ZPMsgArgPtr
>PUSHW ZPMsgExtPtr
2021-03-12 12:50:03 +00:00
2021-03-13 16:11:47 +00:00
>PUSHBI 8
>SYSCALL PrintF
2021-03-11 21:40:55 +00:00
rts
2020-07-09 18:57:35 +00:00
*--------------------------------------
2021-05-19 12:44:47 +00:00
CS.RUN.SendMsg pha
>PUSHB hSocket
2021-03-13 16:11:47 +00:00
>PUSHW ZPRespPtr
2021-05-19 12:44:47 +00:00
pla
>PUSHYA
2021-03-13 16:11:47 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Write
rts
*--------------------------------------
CS.RUN.SCRSETUP >PUSHW L.SEQ.INIT
>PUSHBI 0
>SYSCALL PrintF
bcs CS.RUN.TXTCLR.RTS
2020-06-24 14:39:11 +00:00
2021-03-13 16:11:47 +00:00
jsr CS.RUN.TOPUPDATE
bcs CS.RUN.TXTCLR.RTS
*--------------------------------------
CS.RUN.TXTCLR lda #0
sta (pData)
2020-06-25 15:39:51 +00:00
2021-03-13 16:11:47 +00:00
stz TextPtr
stz TextLen
stz bEscMode
2020-06-25 15:39:51 +00:00
2021-03-13 16:11:47 +00:00
>PUSHW L.SEQ.TXTCLR
>PUSHBI 0
>SYSCALL PrintF
CS.RUN.TXTCLR.RTS
rts
*--------------------------------------
CS.RUN.TOPUPDATE
>PUSHW ZPOutputBufPtr
>PUSHW L.MSG.TOPBAR
>PUSHW A2osX.KVER
2020-06-25 15:39:51 +00:00
2021-03-13 16:11:47 +00:00
lda #1
>SYSCALL ArgV
>PUSHYA
2021-03-12 12:50:03 +00:00
2021-03-13 16:11:47 +00:00
lda #2
>SYSCALL ArgV
>PUSHYA
2020-06-25 15:39:51 +00:00
2021-03-13 16:11:47 +00:00
lda #3
>SYSCALL ArgV
>PUSHYA
2020-06-25 21:20:22 +00:00
2021-03-13 16:11:47 +00:00
>PUSHBI 8
>SYSCALL SPrintF
2020-06-25 15:39:51 +00:00
2021-03-13 16:11:47 +00:00
>PUSHW L.SEQ.BAR
>PUSHBI 1
>PUSHW ZPOutputBufPtr
>PUSHBI 3
>SYSCALL PrintF
2020-06-25 15:39:51 +00:00
rts
2021-03-13 16:11:47 +00:00
*--------------------------------------
CS.RUN.STATUSPDATE
pha
phy
>PUSHW ZPOutputBufPtr
>PUSHW L.MSG.STATUSBAR
2020-06-24 14:39:11 +00:00
2021-03-13 16:11:47 +00:00
lda #4
>SYSCALL ArgV
>PUSHYA
ply
pla
>PUSHYA
>PUSHBI 4
bra CS.RUN.STATUS
2020-06-24 14:39:11 +00:00
*--------------------------------------
2021-03-13 16:11:47 +00:00
CS.RUN.STATUSMSG
pha
>PUSHW ZPOutputBufPtr
>PUSHW L.MSG.STATUSBARMSG
pla
>PUSHYA
>PUSHBI 2
2020-06-25 15:39:51 +00:00
2021-03-13 16:11:47 +00:00
CS.RUN.STATUS >SYSCALL SPrintF
2020-06-25 15:39:51 +00:00
2021-03-13 16:11:47 +00:00
>PUSHW L.SEQ.BAR
>PUSHBI 21
>PUSHW ZPOutputBufPtr
>PUSHBI 3
2020-06-24 14:39:11 +00:00
>SYSCALL PrintF
rts
2020-06-18 15:13:56 +00:00
*--------------------------------------
2020-06-19 15:20:59 +00:00
CS.RUN.CHARIN bit bEscMode
bpl .4
cmp #'['
2020-06-26 19:34:12 +00:00
beq .8
2020-06-19 15:20:59 +00:00
stz bEscMode
ldx #EscChars.Cnt-1
.1 cmp EscChars,x
beq .2
dex
bpl .1
2020-06-26 19:34:12 +00:00
clc
rts
2020-06-19 15:20:59 +00:00
.2 txa
asl
tax
jmp (J.ESC,x)
.4 cmp #C.ESC
bne .5
sec
ror bEscMode
2020-06-26 19:34:12 +00:00
.8 clc
2020-06-19 15:20:59 +00:00
rts
.5 cmp #C.SPACE
bcc CS.RUN.CHARIN.CTRL
cmp #C.DEL
bne CS.RUN.CHARIN.INS
2020-06-25 15:39:51 +00:00
2020-06-19 15:20:59 +00:00
jmp CS.RUN.CHARIN.DEL
*--------------------------------------
CS.RUN.CHARIN.INS
2020-06-24 14:39:11 +00:00
ldy TextLen
cpy #TEXTMAX
beq .8
2020-06-25 15:39:51 +00:00
inc TextLen
2020-06-24 14:39:11 +00:00
ldy TextPtr
2021-03-12 12:50:03 +00:00
sta (pData),y
2020-06-24 14:39:11 +00:00
iny
sty TextPtr
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
pha
lda #0
2021-03-12 12:50:03 +00:00
sta (pData),y
2020-06-24 14:39:11 +00:00
pla
>SYSCALL PutChar
rts
2020-06-25 15:39:51 +00:00
2020-07-09 20:05:28 +00:00
.8
CS.RUN.CHARIN.INS.8
clc
2020-06-24 14:39:11 +00:00
rts
2020-06-26 19:34:12 +00:00
*--------------------------------------
2020-06-19 15:20:59 +00:00
CS.RUN.CHARIN.CTRL
2020-06-24 14:39:11 +00:00
cmp #C.CR
2021-03-13 16:11:47 +00:00
beq CS.RUN.CHARIN.CR
2021-03-11 21:40:55 +00:00
2021-03-13 16:11:47 +00:00
cmp #$14 Ctrl-T
2021-03-11 21:40:55 +00:00
bne .8
2021-03-12 12:50:03 +00:00
2021-03-11 21:40:55 +00:00
>PUSHW ZPRespPtr
>PUSHW L.IRC.PART
lda #4 channel
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
>SYSCALL SPrintF
bcs .9
jsr CS.RUN.SendMsg
bcs .9
lda #3
sec
.9 rts
.8 clc
rts
*--------------------------------------
CS.RUN.CHARIN.CR
2020-06-26 19:34:12 +00:00
bit bJoin
2020-07-09 20:05:28 +00:00
bpl CS.RUN.CHARIN.INS.8
2021-03-12 12:50:03 +00:00
2020-07-10 20:38:49 +00:00
lda TextLen
beq CS.RUN.CHARIN.INS.8
2020-06-25 15:39:51 +00:00
2021-03-11 21:40:55 +00:00
>PUSHW ZPRespPtr
2020-07-09 19:45:51 +00:00
>PUSHW L.IRC.PRIVMSG
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
lda #4 channel
>SYSCALL ArgV
>PUSHYA
2021-03-12 12:50:03 +00:00
>PUSHW pData
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
>PUSHBI 4
2021-03-11 21:40:55 +00:00
>SYSCALL SPrintF
bcs .9
jsr CS.RUN.SendMsg
2020-06-24 14:39:11 +00:00
bcs .9
2020-06-25 15:39:51 +00:00
2020-07-09 20:05:28 +00:00
>PUSHW L.SEQ.PRIVMSG
2020-07-09 20:46:05 +00:00
lda #3 nickname
2020-07-09 20:05:28 +00:00
>SYSCALL ArgV
>PUSHYA
2021-03-12 12:50:03 +00:00
>PUSHW pData
2020-07-09 20:05:28 +00:00
>PUSHBI 4
>SYSCALL PrintF
bcs .9
2020-06-24 14:39:11 +00:00
jmp CS.RUN.TXTCLR
2021-03-12 12:50:03 +00:00
.9 rts
2021-03-13 16:11:47 +00:00
*--------------------------------------
CS.RUN.CHARIN.DEL
2020-06-26 19:34:12 +00:00
*--------------------------------------
2020-06-19 15:20:59 +00:00
CS.RUN.CHARIN.LEFT
2020-07-09 20:46:05 +00:00
clc
2021-03-12 12:50:03 +00:00
2021-03-13 16:11:47 +00:00
ldy TextPtr
2020-06-19 15:20:59 +00:00
beq .9
2021-03-12 12:50:03 +00:00
2021-03-13 16:11:47 +00:00
dey
sty TextPtr
lda #0
sta (pData),y
2021-03-12 12:50:03 +00:00
2020-06-19 15:20:59 +00:00
lda #C.BS
>SYSCALL PutChar
2021-03-13 16:11:47 +00:00
lda #C.SPACE
>SYSCALL PutChar
lda #C.BS
>SYSCALL PutChar
2020-06-19 15:20:59 +00:00
.9 rts
2021-03-13 16:11:47 +00:00
*--------------------------------------
2020-06-19 15:20:59 +00:00
CS.RUN.CHARIN.DOWN
CS.RUN.CHARIN.UP
clc
rts
2021-03-13 16:11:47 +00:00
*--------------------------------------
2020-06-19 15:20:59 +00:00
CS.RUN.CHARIN.RIGHT
2021-03-13 16:11:47 +00:00
clc
rts
2020-06-19 15:20:59 +00:00
lda TextPtr
cmp TextLen
2020-07-09 20:46:05 +00:00
clc
2021-03-12 12:50:03 +00:00
2020-06-19 15:20:59 +00:00
beq .9
2020-06-25 15:39:51 +00:00
2020-06-19 15:20:59 +00:00
inc
sta TextPtr
2021-03-12 12:50:03 +00:00
lda #C.ESC
2020-06-25 15:39:51 +00:00
>SYSCALL PutChar
lda #'['
>SYSCALL PutChar
lda #'C'
>SYSCALL PutChar
2020-06-19 15:20:59 +00:00
.9 rts
*--------------------------------------
2020-06-18 15:13:56 +00:00
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
2021-03-11 21:40:55 +00:00
2020-06-18 15:13:56 +00:00
lda TimeOut
beq .9
2021-03-11 21:40:55 +00:00
2020-06-18 15:13:56 +00:00
dec TimeOut
2021-03-11 21:40:55 +00:00
2020-06-18 15:13:56 +00:00
.9 sec do not discard TIMER event
rts
*--------------------------------------
2021-03-13 16:11:47 +00:00
CS.QUIT ldy #hOutputBuf
jsr .7
2021-03-13 16:11:47 +00:00
ldy #hRespBuf
jsr .7
2021-03-13 16:11:47 +00:00
ldy #hMsgBuf
jsr .7
2020-06-18 15:13:56 +00:00
2021-03-13 16:11:47 +00:00
ldy #hBufBuf
jsr .7
2020-06-18 15:13:56 +00:00
2021-03-13 16:11:47 +00:00
lda hSocket
beq .1
2021-03-12 12:50:03 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
2021-03-13 16:11:47 +00:00
.1 lda hLIBTCPIP
beq .2
2020-06-18 15:13:56 +00:00
>SYSCALL UnloadLib
2021-03-13 16:11:47 +00:00
.2 clc
2020-06-18 15:13:56 +00:00
rts
2021-03-13 16:11:47 +00:00
.7 lda (pData),y
beq .8
2021-03-13 16:11:47 +00:00
>SYSCALL FreeMem
.8 rts
2022-04-19 18:24:34 +00:00
*--------------------------------------
.DO TLS=1
.INB usr/src/bin/irc.s.tls
.FIN
2020-06-18 15:13:56 +00:00
*--------------------------------------
CS.END
LIBTCPIP .AZ "libtcpip"
hLIBTCPIP .BS 1
2022-11-02 06:54:30 +00:00
MSG.IPKO .CZ "TCP/IP Not Loaded/Configured."
MSG.USAGE .CZ "Usage : IRC <ip|host> <port> <nickname> <#channel> [key]"
MSG.UNKNOWN .CZ "%s: Unknown host\r\n"
MSG.HOSTOK .CZ "Connecting to %d.%d.%d.%d:%D (%s)..."
MSG.SKTKO .CZ "Failed to Open Socket."
MSG.SKTOK .CZ "Connected\r\n(Exit key is Ctrl-T)\r\n"
MSG.SKTERR .CZ "Socket Error : $%h\r\n"
.DO TLS=1
2022-11-02 06:54:30 +00:00
MSG.TLS .CZ "TLS:Negociation..."
MSG.TLS.HDR .CZ "TLS:Received %D bytes, Message Type:%h.\r\n"
MSG.TLSKO .CZ "TLS:Negotiation failed."
.FIN
2022-11-02 06:54:30 +00:00
MSG.REGISTER .CZ "Registering User..."
MSG.JOIN .CZ "Joining Channel..."
MSG.TOPBAR .CZ "A2osX IRC %d.%d Server:%s:%s Nick:%s"
MSG.STATUSBAR .CZ "%s:%s"
2021-03-12 12:50:03 +00:00
MSG.STATUSBARMSG .AS "STATUS:%s"
MSG.NULL .HS 00
2020-06-19 15:20:59 +00:00
*--------------------------------------
EscChars .AS 'DBAC'
EscChars.Cnt .EQ *-EscChars
EscChars.Remap .DA #C.BS,#C.VT,#C.LF,#21
2020-06-18 15:13:56 +00:00
*--------------------------------------
2020-06-25 15:39:51 +00:00
IRC.REP.NOIDENT .AZ "*** No Ident response"
2020-06-22 05:59:53 +00:00
IRC.REP.JOIN .AZ "JOIN"
2020-06-24 14:39:11 +00:00
*--------------------------------------
2021-03-12 12:50:03 +00:00
IRC.CMDS .AZ "PING"
.AZ "JOIN"
2020-07-10 20:38:49 +00:00
.AZ "PART"
2021-03-13 16:11:47 +00:00
.AZ "QUIT"
2020-06-24 14:39:11 +00:00
.AZ "PRIVMSG"
.AZ "MODE"
2021-03-12 12:50:03 +00:00
.AZ "001"
2020-06-25 21:20:22 +00:00
.AZ "353"
2020-06-26 19:34:12 +00:00
.AZ "372"
2021-03-12 12:50:03 +00:00
.AZ "375"
2020-06-26 19:34:12 +00:00
.AZ "376"
2020-06-24 14:39:11 +00:00
.DA #0
2020-06-18 15:13:56 +00:00
*--------------------------------------
2022-11-02 06:54:30 +00:00
IRC.REGISTER .CS "NICK %s\r\n"
.CZ "USER %s %s %s :A2osX IRC\r\n"
IRC.JOIN .CZ "JOIN %s\r\n"
IRC.JOINKEY .CZ "JOIN %s %s\r\n"
IRC.PONG .CZ "PONG :%s\r\n"
IRC.PART .CS "PART %s\r\n"
.CZ "QUIT :Pfff\r\n"
IRC.NAMES .CZ "NAMES %s\r\n"
IRC.PRIVMSG .CZ "PRIVMSG %s :%s\r\n"
2020-06-18 15:13:56 +00:00
*--------------------------------------
2022-11-02 06:54:30 +00:00
SEQ.INIT .CZ "\ec\e(B\e)0\e[?7l\e[2;20r\e[22;1H\e[?7h"
SEQ.BAR .CZ "\e[?7l\e7\e[%d;1H\e[7m\e[37;40m%80s\e[0m\e8\e[?7h"
2023-10-18 05:41:12 +00:00
SEQ.TXTCLR .CZ "\e[97;41m\e[24;1H\e[K\e[23;1H\e[K\e[22;1H\e[K"
2022-11-02 06:54:30 +00:00
SEQ.PRIVMSG .CZ "\e7\e[20;1H\r\n\e[93;44m\e[7m%s:\e[0m\e[93;44m%s\e[K\e8"
SEQ.DUMPMSG .CZ "\e7\e[20;1H\r\n\e[7m%s \e[0m%s %s %s\e8"
SEQ.INFOMSG .CZ "\e7\e[20;1H\e[92;44m%s\r\n\e8"
SEQ.RESET .CZ "\ec"
2020-06-18 15:13:56 +00:00
*--------------------------------------
SA.LOCAL .DA #AF.INET S.SOCKADDR.AF
.BS 1
.BS 4 S.SOCKADDR.ADDR
.BS 2 S.SOCKADDR.PORT
*--------------------------------------
SA.REMOTE .DA #AF.INET S.SOCKADDR.AF
.BS 1
.BS 4 S.SOCKADDR.ADDR
2021-03-11 21:40:55 +00:00
.DA 6667
*--------------------------------------
.DO TLS=1
TLS.CHELLO .DA #TLS.CT.HS
.DA TLS.LV.TLS10
.DA /TLS.CHELLO.L1,#TLS.CHELLO.L1
TLS.CHELLO.1 .DA #TLS.HS.MT.CH
.DA #0,/TLS.CHELLO.L2,#TLS.CHELLO.L2
TLS.CHELLO.2 .DA TLS.LV.TLS12
TLS.CHELLO.UT .BS 4
TLS.CHELLO.R .BS 28
.DA #0 SID
.DA #0,#2 CSL
2022-04-07 17:19:48 +00:00
.DA #0,#TLS.HS.CH.CS.RSAAES128CBCSHA256
.DA TLS.HS.CH.CM.NONE
.DA /TLS.CHELLO.LE,#TLS.CHELLO.LE
TLS.CHELLO.E .HS 000D T=sig alg
.HS 0004 sig alg Len
.HS 0002 sig hash alg len
2022-04-07 17:19:48 +00:00
.HS 0401 SHA256 RSA
TLS.CHELLO.L .EQ *-TLS.CHELLO
TLS.CHELLO.L1 .EQ *-TLS.CHELLO.1
TLS.CHELLO.L2 .EQ *-TLS.CHELLO.2
TLS.CHELLO.LE .EQ *-TLS.CHELLO.E
2022-04-19 18:24:34 +00:00
*--------------------------------------
TLS.HDR .DA #TLS.CT.HS
.DA TLS.LV.TLS12
TLS.HDR.L .EQ *-TLS.HDR
*--------------------------------------
.FIN
2020-06-18 15:13:56 +00:00
*--------------------------------------
.DUMMY
.OR 0
2021-03-12 12:50:03 +00:00
DS.START .BS TEXTMAX+1
2021-03-13 16:11:47 +00:00
hBufBuf .BS 1
hMsgBuf .BS 1
hRespBuf .BS 1
hOutputBuf .BS 1
2020-08-25 10:56:00 +00:00
DS.END .ED
2020-06-18 15:13:56 +00:00
*--------------------------------------
MAN
SAVE usr/src/bin/irc.s
ASM