A2osX/BIN/IRC.S.txt

1067 lines
18 KiB
Plaintext
Raw Normal View History

2020-06-18 15:13:56 +00:00
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
.TF bin/irc
*--------------------------------------
.INB inc/macros.i
.INB inc/a2osx.i
2020-06-23 06:19:11 +00:00
.INB inc/mli.i
2020-06-18 15:13:56 +00:00
.INB inc/eth.i
.INB inc/libtcpip.i
*--------------------------------------
TIMEOUT.MAX .EQ 200 20 sec.
2020-06-22 05:59:53 +00:00
MSGSIZE .EQ 1024
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
2020-06-22 05:59:53 +00:00
2020-06-18 15:13:56 +00:00
hSocket .BS 1
2020-06-23 06:19:11 +00:00
hFile .BS 1
2020-06-18 15:13:56 +00:00
2020-06-22 05:59:53 +00:00
hLineBuf .BS 1
2020-06-24 14:39:11 +00:00
ZPLineBufPtr .BS 2
2020-06-19 15:20:59 +00:00
TextPtr .BS 1
TextLen .BS 1
2020-06-24 14:39:11 +00:00
hText .BS 1
ZPTextPtr .BS 2
2020-06-19 15:20:59 +00:00
bEscMode .BS 1
2020-06-18 15:13:56 +00:00
2020-06-24 14:39:11 +00:00
TimeOut .BS 1
2020-06-26 19:34:12 +00:00
bJoin .BS 1
2020-06-25 15:39:51 +00:00
hMsgBuf .BS 1
2020-06-24 06:12:43 +00:00
ZPMsgPtr .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
2020-06-18 15:13:56 +00:00
ZS.END
.ED
*--------------------------------------
* 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
2020-06-23 06:19:11 +00:00
L.NOD.Template .DA NOD.Template
2020-06-18 15:13:56 +00:00
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
2020-06-22 05:59:53 +00:00
L.MSG.NICK .DA MSG.NICK
2020-06-18 15:13:56 +00:00
L.MSG.USER .DA MSG.USER
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
2020-06-22 05:59:53 +00:00
L.IRC.NICK .DA IRC.NICK
2020-06-18 15:13:56 +00:00
L.IRC.USER .DA IRC.USER
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
2020-06-26 19:34:12 +00:00
J.IRC.CMDS .DA CS.RUN.CMD.JOIN
2020-07-10 20:38:49 +00:00
.DA CS.RUN.CMD.PART
2020-06-26 19:34:12 +00:00
.DA CS.RUN.CMD.PING
2020-06-24 14:39:11 +00:00
.DA CS.RUN.CMD.PRIVMSG
.DA CS.RUN.CMD.MODE
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
2020-06-18 15:13:56 +00:00
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib
bcs .9
sta hLIBTCPIP
.9 rts
*--------------------------------------
2020-06-22 05:59:53 +00:00
CS.RUN >LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG is TCPIP loaded ?
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
>STYA ZPPtr1
lda (ZPPtr1) Configured ?
2020-06-18 15:13:56 +00:00
bmi CS.RUN.IPOK
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
>LDYA L.MSG.IPKO
>SYSCALL PutS
lda #E.SYN
sec
2020-06-24 06:12:43 +00:00
.99 rts
2020-06-18 15:13:56 +00:00
CS.RUN.IPOK ldy #S.PS.ARGC
lda (pPS),y
cmp #3
bcc .9
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
lda #TIMEOUT.MAX
sta TimeOut
.2 >SLEEP
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
>PUSHW L.SA.REMOTE.AD
lda #1
>SYSCALL ArgV
>PUSHYA
>LIBCALL hLIBTCPIP,LIBTCPIP.HST.GETBYNAME
bcc CS.RUN.HOSTOK
lda TimeOut
bne .2
>PUSHW L.MSG.UNKNOWN
lda #1
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
>SYSCALL PrintF
bra .99
.9 >LDYA L.MSG.USAGE
>SYSCALL PutS
.99 lda #E.SYN
sec
rts
CS.RUN.HOSTOK lda #2
>SYSCALL ArgV
>SYSCALL atoi
>STYA SA.REMOTE+S.SOCKADDR.PORT
>PUSHW L.MSG.HOSTOK
ldx #0
.1 >PUSHB SA.REMOTE+S.SOCKADDR.ADDR,x
inx
cpx #4
bne .1
>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
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
CS.RUN.OPENSKT >PUSHBI 0 no protocol
2020-06-22 05:59:53 +00:00
lda #S.SOCKET.T.STREAM
2020-06-18 15:13:56 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.Socket
bcs .9
sta hSocket
>PUSHW L.SA.LOCAL
lda hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Bind
bcc .2
.9 pha
>LDYA L.MSG.SKTKO
>SYSCALL PutS
pla
sec
.99 rts
.2 lda #TIMEOUT.MAX
sta TimeOut
.3 >SLEEP
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
>PUSHW L.SA.REMOTE
lda hSocket
>LIBCALL hLIBTCPIP,LIBTCPIP.Connect
bcc .4
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
cmp #ERR.SKT.NOCONN
bne .9
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
lda TimeOut
bne .3
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
lda #ERR.SKT.NOCONN
bra .9
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
.4 >PUSHW L.MSG.SKTOK
>PUSHBI 0
>SYSCALL PrintF
2020-06-19 06:33:47 +00:00
2020-06-23 06:19:11 +00:00
jsr CS.RUN.MkNod
bcs .99
2020-06-25 15:39:51 +00:00
2020-06-22 05:59:53 +00:00
jsr CS.RUN.GETBUF
bcs .99
2020-06-24 06:12:43 +00:00
jsr CS.RUN.SCRSETUP
bcs .99
2020-06-22 05:59:53 +00:00
jsr CS.RUN.NICK
bcs .99
>SLEEP
2020-06-19 06:33:47 +00:00
jsr CS.RUN.USER
bcs .99
2020-06-19 15:20:59 +00:00
2020-06-22 05:59:53 +00:00
>SLEEP
2020-06-25 15:39:51 +00:00
2020-06-19 06:33:47 +00:00
jsr CS.RUN.JOIN
bcs .99
2020-06-25 15:39:51 +00:00
2020-06-26 19:34:12 +00:00
>LDYA pData NULLSTRING
2020-06-25 15:39:51 +00:00
jsr CS.RUN.STATUSPDATE
bcs .99
2020-06-18 15:13:56 +00:00
CS.RUN.LOOP >SLEEP
2020-06-24 14:39:11 +00:00
lda hFile
>SYSCALL feof
bcs .9
2020-06-29 05:49:24 +00:00
2020-06-24 14:39:11 +00:00
tay
2020-06-29 05:49:24 +00:00
bne .2
2020-06-25 15:39:51 +00:00
2020-07-09 18:57:35 +00:00
jsr CS.RUN.GetMsg
2020-06-24 14:39:11 +00:00
bcs .9
2020-07-09 20:05:28 +00:00
beq .2
2020-06-18 15:13:56 +00:00
2020-06-26 19:34:12 +00:00
jsr CS.RUN.REQ
2020-06-18 15:13:56 +00:00
bcs .9
2020-06-29 05:49:24 +00:00
>SLEEP
2020-06-18 15:13:56 +00:00
.2 ldy #S.PS.hStdIn
lda (pPS),y
>SYSCALL feof
2020-06-24 14:39:11 +00:00
bcs .9
2020-06-18 15:13:56 +00:00
tay
bne CS.RUN.LOOP EOF = true, no char from STDIN
>SYSCALL GetChar
bcs .9
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
jsr CS.RUN.CHARIN
2020-06-22 05:59:53 +00:00
bcc CS.RUN.LOOP
2020-06-18 15:13:56 +00:00
2020-06-24 14:39:11 +00:00
.9 php
2020-06-18 15:13:56 +00:00
pha
>PUSHW L.SEQ.RESET
>PUSHBI 0
>SYSCALL PrintF
pla
plp
rts
*--------------------------------------
2020-06-23 06:19:11 +00:00
CS.RUN.MkNod >PUSHEA.G NodBuf
>PUSHW L.NOD.Template
>PUSHB hSocket
>PUSHBI 1
>SYSCALL sprintf
bcs .9
>PUSHEA.G NodBuf
>PUSHW 0
>PUSHB hSocket
>SYSCALL mknod
bcs .9
2020-06-25 15:39:51 +00:00
2020-06-23 06:19:11 +00:00
>PUSHEA.G NodBuf
>PUSHBI O.RDWR+O.TEXT
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
2020-06-25 15:39:51 +00:00
2020-06-23 06:19:11 +00:00
sta hFile
2020-06-25 15:39:51 +00:00
2020-06-23 06:19:11 +00:00
.9 rts
*--------------------------------------
2020-06-25 15:39:51 +00:00
CS.RUN.GETBUF >LDYAI MSGSIZE
>SYSCALL GetMem
bcs .9
stx hMsgBuf
>STYA ZPMsgPtr
2020-06-24 14:39:11 +00:00
>LDYAI 256
>SYSCALL GetMem
bcs .9
stx hText
>STYA ZPTextPtr
2020-06-22 05:59:53 +00:00
>LDYAI 256
2020-06-19 15:20:59 +00:00
>SYSCALL GetMem
bcs .9
2020-06-22 05:59:53 +00:00
stx hLineBuf
>STYA ZPLineBufPtr
2020-06-19 15:20:59 +00:00
.9 rts
*--------------------------------------
2020-06-18 15:13:56 +00:00
CS.RUN.SCRSETUP >PUSHW L.SEQ.INIT
>PUSHBI 0
>SYSCALL PrintF
2020-06-19 15:20:59 +00:00
bcs .9
jsr CS.RUN.TOPUPDATE
bcs .9
2020-06-22 05:59:53 +00:00
2020-06-19 15:20:59 +00:00
jsr CS.RUN.TXTCLR
2020-06-22 05:59:53 +00:00
2020-06-19 15:20:59 +00:00
.9 rts
*--------------------------------------
CS.RUN.TOPUPDATE
2020-06-22 05:59:53 +00:00
>PUSHW ZPLineBufPtr
2020-06-18 15:13:56 +00:00
>PUSHW L.MSG.TOPBAR
2020-06-19 06:33:47 +00:00
>PUSHB #K.VER
>PUSHB /K.VER
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
lda #1
>SYSCALL ArgV
>PUSHYA
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
lda #2
>SYSCALL ArgV
>PUSHYA
2020-06-19 15:20:59 +00:00
lda #3
>SYSCALL ArgV
>PUSHYA
>PUSHBI 8
>SYSCALL SPrintF
>PUSHW L.SEQ.BAR
2020-06-24 06:12:43 +00:00
>PUSHBI 1
2020-06-22 05:59:53 +00:00
>PUSHW ZPLineBufPtr
2020-06-24 06:12:43 +00:00
>PUSHBI 3
2020-06-19 15:20:59 +00:00
>SYSCALL PrintF
rts
*--------------------------------------
CS.RUN.STATUSPDATE
2020-06-25 21:20:22 +00:00
pha
phy
2020-06-22 05:59:53 +00:00
>PUSHW ZPLineBufPtr
2020-06-19 15:20:59 +00:00
>PUSHW L.MSG.STATUSBAR
2020-06-25 15:39:51 +00:00
2020-06-18 15:13:56 +00:00
lda #4
>SYSCALL ArgV
>PUSHYA
2020-06-25 21:20:22 +00:00
ply
pla
>PUSHYA
2020-06-19 15:20:59 +00:00
>PUSHBI 4
2020-06-25 15:39:51 +00:00
bra CS.RUN.STATUS
*--------------------------------------
CS.RUN.STATUSMSG
pha
>PUSHW ZPLineBufPtr
>PUSHW L.MSG.STATUSBARMSG
pla
>PUSHYA
>PUSHBI 2
2020-06-19 15:20:59 +00:00
2020-06-25 15:39:51 +00:00
CS.RUN.STATUS >SYSCALL SPrintF
2020-06-19 15:20:59 +00:00
>PUSHW L.SEQ.BAR
2020-06-24 06:12:43 +00:00
>PUSHBI 21
2020-06-22 05:59:53 +00:00
>PUSHW ZPLineBufPtr
2020-06-24 06:12:43 +00:00
>PUSHBI 3
2020-06-18 15:13:56 +00:00
>SYSCALL PrintF
2020-06-19 15:20:59 +00:00
rts
*--------------------------------------
CS.RUN.TXTCLR lda #0
2020-06-24 14:39:11 +00:00
sta (ZPTextPtr)
2020-06-25 15:39:51 +00:00
2020-06-19 15:20:59 +00:00
stz TextPtr
stz TextLen
stz bEscMode
>PUSHW L.SEQ.TXTCLR
>PUSHBI 0
>SYSCALL PrintF
2020-06-18 15:13:56 +00:00
rts
*--------------------------------------
2020-06-25 15:39:51 +00:00
CS.RUN.NICK >LDYA L.MSG.NICK
jsr CS.RUN.STATUSMSG
2020-06-22 05:59:53 +00:00
2020-06-23 06:19:11 +00:00
>PUSHB hFile
2020-06-22 05:59:53 +00:00
>PUSHW L.IRC.NICK
lda #3 nickname
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
2020-06-23 06:19:11 +00:00
>SYSCALL FPrintF
2020-06-22 05:59:53 +00:00
bcs .9
.1 >SLEEP
2020-07-09 18:57:35 +00:00
jsr CS.RUN.GetMsg
2020-06-24 06:12:43 +00:00
bcs .9
2020-07-09 20:05:28 +00:00
beq .1
2020-06-25 15:39:51 +00:00
2020-07-09 18:57:35 +00:00
jsr CS.RUN.SplitMsg
2020-06-24 14:39:11 +00:00
jsr CS.RUN.DUMPMSG
2020-06-25 15:39:51 +00:00
ldy #$ff
.3 iny
lda IRC.REP.NOIDENT,y
2020-06-22 05:59:53 +00:00
beq .8
2020-06-25 15:39:51 +00:00
cmp (ZPMsgExtPtr),y
2020-06-22 05:59:53 +00:00
beq .3
bra .1
2020-06-23 06:19:11 +00:00
2020-06-29 05:49:24 +00:00
.8 clc
2020-06-24 06:12:43 +00:00
.9 rts
2020-06-22 05:59:53 +00:00
*--------------------------------------
CS.RUN.USER >LDYA L.MSG.USER
2020-06-25 15:39:51 +00:00
jsr CS.RUN.STATUSMSG
2020-06-22 05:59:53 +00:00
2020-06-23 06:19:11 +00:00
>PUSHB hFile
2020-06-18 15:13:56 +00:00
>PUSHW L.IRC.USER
lda #3 nickname
>SYSCALL ArgV
>PUSHYA
lda #3 nickname
>SYSCALL ArgV
>PUSHYA
>PUSHBI 4
2020-06-23 06:19:11 +00:00
>SYSCALL FPrintF
2020-06-19 06:33:47 +00:00
bcs .9
2020-06-19 15:20:59 +00:00
2020-06-19 06:33:47 +00:00
.1 >SLEEP
2020-07-09 18:57:35 +00:00
jsr CS.RUN.GetMsg
2020-06-24 06:12:43 +00:00
bcs .9
2020-07-09 20:05:28 +00:00
beq .1
2020-06-19 15:20:59 +00:00
2020-07-09 18:57:35 +00:00
.2 jsr CS.RUN.SplitMsg
2020-06-24 14:39:11 +00:00
jsr CS.RUN.DUMPMSG
2020-06-25 15:39:51 +00:00
ldy #$ff
.3 iny
lda IRC.REP.001,y
2020-06-22 05:59:53 +00:00
beq .8
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
cmp (ZPMsgCmdPtr),y
2020-06-22 05:59:53 +00:00
beq .3
2020-06-19 06:33:47 +00:00
2020-06-22 05:59:53 +00:00
bra .1
2020-06-23 06:19:11 +00:00
2020-06-29 05:49:24 +00:00
.8 clc
2020-06-24 06:12:43 +00:00
.9 rts
2020-06-18 15:13:56 +00:00
*--------------------------------------
2020-06-22 05:59:53 +00:00
CS.RUN.JOIN >LDYA L.MSG.JOIN
2020-06-25 15:39:51 +00:00
jsr CS.RUN.STATUSMSG
2020-06-22 05:59:53 +00:00
2020-06-23 06:19:11 +00:00
>PUSHB hFile
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
lda #5 key
>SYSCALL ArgV
bcs .1
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
>PUSHW L.IRC.JOINKEY
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
lda #4 channel
>SYSCALL ArgV
>PUSHYA
lda #5 key
>SYSCALL ArgV
>PUSHYA
>PUSHBI 4
2020-06-22 05:59:53 +00:00
bra .2
2020-06-18 15:13:56 +00:00
.1 >PUSHW L.IRC.JOIN
2020-06-19 15:20:59 +00:00
2020-06-18 15:13:56 +00:00
lda #4 channel
>SYSCALL ArgV
>PUSHYA
2020-06-19 06:33:47 +00:00
>PUSHBI 2
2020-06-18 15:13:56 +00:00
2020-06-23 06:19:11 +00:00
.2 >SYSCALL FPrintF
2020-06-24 06:12:43 +00:00
.9 rts
2020-06-22 05:59:53 +00:00
*--------------------------------------
2020-07-09 18:57:35 +00:00
CS.RUN.REQ jsr CS.RUN.SplitMsg
2020-06-24 14:39:11 +00:00
bcs .8
2020-06-25 21:20:22 +00:00
* jsr CS.RUN.DUMPMSG
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
>LDYA L.IRC.CMDS
>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
*--------------------------------------
2020-07-10 20:38:49 +00:00
CS.RUN.CMD.JOIN lda bJoin
bmi .1
sec
2020-06-26 19:34:12 +00:00
ror bJoin
clc
rts
2020-07-10 20:38:49 +00:00
.1
*--------------------------------------
CS.RUN.CMD.PART >PUSHB hFile
>PUSHW L.IRC.NAMES
lda #4 channel
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
>SYSCALL FPrintF
rts
2020-06-26 19:34:12 +00:00
*--------------------------------------
2020-06-24 14:39:11 +00:00
CS.RUN.CMD.PING >PUSHB hFile
>PUSHW L.IRC.PONG
2020-06-25 21:20:22 +00:00
>PUSHW ZPMsgExtPtr
2020-06-24 14:39:11 +00:00
>PUSHBI 2
>SYSCALL FPrintF
rts
*--------------------------------------
CS.RUN.CMD.PRIVMSG
2020-06-26 19:34:12 +00:00
ldy #0
.1 iny
lda (ZPMsgPfxPtr),y
beq .2
eor #'!'
bne .1
sta (ZPMsgPfxPtr),y
.2 >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
rts
*--------------------------------------
2020-06-25 15:39:51 +00:00
CS.RUN.CMD.MODE
2020-06-24 14:39:11 +00:00
clc
rts
*--------------------------------------
2020-07-10 20:38:49 +00:00
CS.RUN.CMD.353 >LDYA ZPMsgExtPtr RPL_NAMREPLY
2020-06-25 21:20:22 +00:00
jmp CS.RUN.STATUSPDATE
2020-06-26 19:34:12 +00:00
CS.RUN.CMD.375
CS.RUN.CMD.372
CS.RUN.CMD.376
>PUSHW L.SEQ.INFOMSG
>PUSHW ZPMsgExtPtr
>PUSHBI 2
>SYSCALL PrintF
rts
2020-06-25 21:20:22 +00:00
*--------------------------------------
2020-07-09 18:57:35 +00:00
CS.RUN.GetMsg >PUSHWI MSGSIZE
>PUSHW ZPMsgPtr
lda hFile
>SYSCALL fgets
2020-07-09 20:05:28 +00:00
bcs .9
lda (ZPMsgPtr)
* clc
.9 rts
2020-07-09 18:57:35 +00:00
*--------------------------------------
CS.RUN.SplitMsg >LDYA pData
2020-06-25 15:39:51 +00:00
>STYA ZPMsgPfxPtr
>STYA ZPMsgCmdPtr
>STYA ZPMsgArgPtr
>STYA ZPMsgExtPtr
2020-06-24 06:12:43 +00:00
ldy #0
2020-06-25 21:20:22 +00:00
ldx #0
2020-06-25 15:39:51 +00:00
2020-06-23 06:19:11 +00:00
lda (ZPMsgPtr)
2020-07-10 20:38:49 +00:00
cmp #':' do we have a prefix ?
2020-06-25 21:20:22 +00:00
bne .2
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
lda ZPMsgPtr
2020-06-24 06:12:43 +00:00
clc
2020-06-24 14:39:11 +00:00
adc #1
sta ZPMsgPfxPtr
lda ZPMsgPtr+1
adc #0
sta ZPMsgPfxPtr+1
2020-06-25 15:39:51 +00:00
.1 iny
lda (ZPMsgPtr),y
beq .9
cmp #C.SPACE
bne .1
lda #0
2020-07-10 20:38:49 +00:00
sta (ZPMsgPtr),y End Of prefix
2020-06-25 15:39:51 +00:00
2020-06-25 21:20:22 +00:00
iny Skip blank
2020-06-25 15:39:51 +00:00
2020-06-25 21:20:22 +00:00
tya
tax Save CMD start pos
.2 iny
2020-06-24 14:39:11 +00:00
lda (ZPMsgPtr),y
beq .4
2020-06-25 15:39:51 +00:00
2020-07-10 20:38:49 +00:00
.3 cmp #C.SPACE scan until end of CMD
2020-06-25 21:20:22 +00:00
bne .2
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
lda #0
2020-07-10 20:38:49 +00:00
sta (ZPMsgPtr),y End of CMD
2020-06-25 21:20:22 +00:00
iny Skip blank
2020-06-24 14:39:11 +00:00
.4 php
2020-06-25 15:39:51 +00:00
txa
2020-06-25 21:20:22 +00:00
clc
2020-06-24 14:39:11 +00:00
adc ZPMsgPtr
sta ZPMsgCmdPtr
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
lda #0
adc ZPMsgPtr+1
sta ZPMsgCmdPtr+1
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
plp
2020-06-25 15:39:51 +00:00
beq .80
tya
2020-06-25 21:20:22 +00:00
tax Save Arg start pos
2020-06-24 14:39:11 +00:00
lda (ZPMsgPtr),y
cmp #':'
2020-07-10 20:38:49 +00:00
beq .71 no arg....ext
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
.6 iny
lda (ZPMsgPtr),y
beq .7
2020-06-25 15:39:51 +00:00
2020-07-10 20:38:49 +00:00
cmp #':' ARGS could be "ARG1 ARG2 ARG3"
2020-06-24 14:39:11 +00:00
bne .6
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
lda #0
sta (ZPMsgPtr),y
2020-06-25 21:20:22 +00:00
2020-07-10 20:38:49 +00:00
iny Skip :
2020-06-24 14:39:11 +00:00
.7 php
2020-06-25 15:39:51 +00:00
txa
2020-06-25 21:20:22 +00:00
clc
2020-06-24 14:39:11 +00:00
adc ZPMsgPtr
sta ZPMsgArgPtr
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
lda #0
adc ZPMsgPtr+1
sta ZPMsgArgPtr+1
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
plp
beq .80
2020-06-25 21:20:22 +00:00
lda (ZPMsgPtr),y
cmp #':'
bne .8
2020-06-25 15:39:51 +00:00
2020-06-25 21:20:22 +00:00
.71 iny Skip blank
.8 tya
clc
2020-06-24 14:39:11 +00:00
adc ZPMsgPtr
sta ZPMsgExtPtr
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
lda #0
adc ZPMsgPtr+1
sta ZPMsgExtPtr+1
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
.80 clc
2020-06-25 15:39:51 +00:00
rts
2020-06-24 14:39:11 +00:00
.9 sec
rts
*--------------------------------------
CS.RUN.DUMPMSG >PUSHW L.SEQ.DUMPMSG
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
>PUSHW ZPMsgPfxPtr
>PUSHW ZPMsgCmdPtr
>PUSHW ZPMsgArgPtr
>PUSHW ZPMsgExtPtr
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
>PUSHBI 8
>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
lda TextLen
2020-06-26 19:34:12 +00:00
beq .8
2020-06-25 15:39:51 +00:00
2020-06-19 15:20:59 +00:00
lda TextPtr
2020-06-26 19:34:12 +00:00
beq .8
2020-06-25 15:39:51 +00:00
2020-06-19 15:20:59 +00:00
lda #C.BS
>SYSCALL PutChar
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
sta (ZPTextPtr),y
iny
sty TextPtr
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
pha
lda #0
sta (ZPTextPtr),y
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
2020-06-26 19:34:12 +00:00
bne .1
2020-06-30 05:59:37 +00:00
2020-06-26 19:34:12 +00:00
bit bJoin
2020-07-09 20:05:28 +00:00
bpl CS.RUN.CHARIN.INS.8
2020-07-10 20:38:49 +00:00
lda TextLen
beq CS.RUN.CHARIN.INS.8
2020-06-25 15:39:51 +00:00
2020-07-09 19:45:51 +00:00
>PUSHB hFile
>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
>PUSHW ZPTextPtr
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
>PUSHBI 4
2020-07-09 19:45:51 +00:00
>SYSCALL FPrintF
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
>PUSHW ZPTextPtr
>PUSHBI 4
>SYSCALL PrintF
bcs .9
2020-06-24 14:39:11 +00:00
jmp CS.RUN.TXTCLR
2020-06-26 19:34:12 +00:00
.1 cmp #$14 Ctrl-T
bne .8
2020-06-29 05:49:24 +00:00
>PUSHB hFile
>PUSHW L.IRC.PART
lda #4 channel
>SYSCALL ArgV
>PUSHYA
>PUSHBI 2
>SYSCALL FPrintF
2020-07-09 19:45:51 +00:00
>SLEEP
2020-06-26 19:34:12 +00:00
lda #3
sec
rts
2020-06-25 15:39:51 +00:00
2020-06-24 14:39:11 +00:00
.8 clc
.9 rts
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
2020-06-19 15:20:59 +00:00
lda TextPtr
beq .9
2020-07-09 20:46:05 +00:00
2020-06-19 15:20:59 +00:00
dec TextPtr
2020-07-09 20:46:05 +00:00
2020-06-19 15:20:59 +00:00
lda #C.BS
>SYSCALL PutChar
.9 rts
CS.RUN.CHARIN.DOWN
CS.RUN.CHARIN.UP
clc
rts
CS.RUN.CHARIN.RIGHT
lda TextPtr
cmp TextLen
2020-07-09 20:46:05 +00:00
clc
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
2020-07-09 20:46:05 +00:00
2020-06-19 15:20:59 +00:00
lda #C.FS
2020-06-25 15:39:51 +00:00
>SYSCALL PutChar
2020-06-19 15:20:59 +00:00
.9 rts
*--------------------------------------
CS.RUN.CHARIN.DEL
2020-06-18 15:13:56 +00:00
clc
rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .9 is it a TIMER event?
lda TimeOut
beq .9
dec TimeOut
.9 sec do not discard TIMER event
rts
*--------------------------------------
2020-06-23 06:19:11 +00:00
CS.QUIT lda hFile
2020-06-18 15:13:56 +00:00
beq .1
2020-06-25 15:39:51 +00:00
2020-06-23 06:19:11 +00:00
>SYSCALL fclose
.1 lda hSocket
beq .2
2020-06-18 15:13:56 +00:00
2020-07-14 20:17:15 +00:00
* >LIBCALL hLIBTCPIP,LIBTCPIP.Shutdown
2020-06-18 15:13:56 +00:00
2020-06-24 14:39:11 +00:00
.2 lda hText
2020-06-23 06:19:11 +00:00
beq .3
2020-06-18 15:13:56 +00:00
>SYSCALL FreeMem
2020-06-23 06:19:11 +00:00
.3 lda hLIBTCPIP
2020-06-18 15:13:56 +00:00
beq .8
>SYSCALL UnloadLib
.8 clc
rts
*--------------------------------------
CS.END
LIBTCPIP .AZ "libtcpip"
hLIBTCPIP .BS 1
MSG.IPKO .AZ "TCP/IP Not Loaded/Configured."
MSG.USAGE .AZ "Usage : IRC <ip|host> <port> <nickname> <#channel> [key]"
MSG.UNKNOWN .AZ "%s: Unknown host\r\n"
MSG.HOSTOK .AZ "Connecting to %d.%d.%d.%d:%D (%s)..."
MSG.SKTKO .AZ "Failed to Open Socket."
MSG.SKTOK .AZ "Connected\r\n(Exit key is Ctrl-T)\r\n"
MSG.SKTERR .AZ "Socket Error : $%h\r\n"
2020-06-25 15:39:51 +00:00
MSG.NICK .AZ "Registering User..."
2020-06-22 05:59:53 +00:00
MSG.USER .AZ "Connecting User..."
MSG.JOIN .AZ "Joining Channel..."
2020-06-26 19:34:12 +00:00
MSG.TOPBAR .AZ "A2osX IRC %d.%d Server:%s:%s Nick:%s"
2020-06-24 06:12:43 +00:00
MSG.STATUSBAR .AZ "%s:%s"
2020-06-25 15:39:51 +00:00
MSG.STATUSBARMSG .AZ "STATUS:%s"
2020-06-19 15:20:59 +00:00
*--------------------------------------
EscChars .AS 'DBAC'
EscChars.Cnt .EQ *-EscChars
EscChars.Remap .DA #C.BS,#C.VT,#C.LF,#C.FS
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.001 .AZ "001"
IRC.REP.JOIN .AZ "JOIN"
2020-06-24 14:39:11 +00:00
*--------------------------------------
2020-06-26 19:34:12 +00:00
IRC.CMDS .AZ "JOIN"
2020-07-10 20:38:49 +00:00
.AZ "PART"
2020-06-26 19:34:12 +00:00
.AZ "PING"
2020-06-24 14:39:11 +00:00
.AZ "PRIVMSG"
.AZ "MODE"
2020-06-25 21:20:22 +00:00
.AZ "353"
2020-06-26 19:34:12 +00:00
.AZ "375"
.AZ "372"
.AZ "376"
2020-06-24 14:39:11 +00:00
.DA #0
2020-06-18 15:13:56 +00:00
*--------------------------------------
2020-06-22 05:59:53 +00:00
IRC.NICK .AZ "NICK %s\r\n"
IRC.USER .AZ "USER %s 0 * :%s\r\n"
IRC.JOIN .AZ "JOIN %s\r\n"
IRC.JOINKEY .AZ "JOIN %s %s\r\n"
2020-06-23 06:19:11 +00:00
IRC.PONG .AZ "PONG %s\r\n"
2020-07-14 20:17:15 +00:00
IRC.PART .AS "PART %s\r\n"
.AZ "QUIT :Pfff\r\n"
2020-07-10 20:38:49 +00:00
IRC.NAMES .AZ "NAMES %s\r\n"
2020-06-22 05:59:53 +00:00
IRC.PRIVMSG .AZ "PRIVMSG %s :%s\r\n"
2020-06-18 15:13:56 +00:00
*--------------------------------------
2020-06-25 15:39:51 +00:00
SEQ.INIT .AZ "\ec\e(B\e)0\e[?7l\e[2;20r\e[22;1H\e[?7h"
2020-06-29 05:49:24 +00:00
SEQ.BAR .AZ "\e7\e[%d;1H\e[7m\e[37;40m%80s\e[0m\e8"
2020-06-24 06:12:43 +00:00
SEQ.TXTCLR .AZ "\e[22;1H\e[K\r\n\e[K\r\n\e[K\e[22;1H"
2020-06-26 19:34:12 +00:00
SEQ.PRIVMSG .AZ "\e7\e[20;1H\r\n\e[7m%s:\e[0m%s\e8"
2020-06-25 21:20:22 +00:00
SEQ.DUMPMSG .AZ "\e7\e[20;1H\r\n\e[7m%s \e[0m%s %s %s\e8"
2020-06-26 19:34:12 +00:00
SEQ.INFOMSG .AZ "\e7\e[20;1H%s\r\n\e8"
2020-06-19 06:33:47 +00:00
SEQ.RESET .AZ "\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
2020-06-19 06:33:47 +00:00
.BS 2
2020-06-23 06:19:11 +00:00
*--------------------------------------
NOD.Template .AZ "/dev/irc%h"
2020-06-18 15:13:56 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
2020-06-25 15:39:51 +00:00
NULLSTRING .BS 1
2020-06-23 06:19:11 +00:00
NodBuf .BS 11
2020-06-18 15:13:56 +00:00
DS.END
.ED
*--------------------------------------
MAN
SAVE usr/src/bin/irc.s
ASM