2023-05-19 15:39:42 +00:00
|
|
|
|
NEW
|
|
|
|
|
AUTO 3,1
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
|
|
|
|
.TF bin/man
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.INB inc/macros.i
|
|
|
|
|
.INB inc/mli.i
|
|
|
|
|
.INB inc/a2osx.i
|
|
|
|
|
.INB inc/libtui.i
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR ZPBIN
|
|
|
|
|
ZS.START
|
2023-05-30 17:13:23 +00:00
|
|
|
|
hFileBuf .BS 1
|
|
|
|
|
hLineBuf .BS 1
|
2023-05-19 15:39:42 +00:00
|
|
|
|
|
|
|
|
|
TimeOut .BS 1
|
|
|
|
|
|
|
|
|
|
hCTX .BS 1
|
|
|
|
|
hSCR .BS 1
|
|
|
|
|
hTBOX .BS 1
|
|
|
|
|
|
2023-05-30 17:13:23 +00:00
|
|
|
|
BufSize .BS 2
|
|
|
|
|
ZPLinePtr .BS 2
|
2023-05-19 15:39:42 +00:00
|
|
|
|
ZPPtr1 .BS 2
|
2023-05-30 17:13:23 +00:00
|
|
|
|
ZPPtr2 .BS 2
|
|
|
|
|
ZPPtr3 .BS 2
|
2023-05-19 15:39:42 +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
|
|
|
|
|
.DA CS.DOEVENT
|
|
|
|
|
.DA CS.QUIT
|
|
|
|
|
|
|
|
|
|
L.LIBTUI .DA LIBTUI
|
|
|
|
|
|
2023-05-30 17:13:23 +00:00
|
|
|
|
L.ENV.MANPATH .DA ENV.MANPATH
|
|
|
|
|
L.FILE.INDEX .DA FILE.INDEX
|
2023-05-19 15:39:42 +00:00
|
|
|
|
L.MSG.ScrTitle .DA MSG.ScrTitle
|
|
|
|
|
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
|
|
|
|
L.MSG.CRLF .DA MSG.CRLF
|
|
|
|
|
L.MSG.NULL .DA MSG.NULL
|
|
|
|
|
L.MSG.GOTO .DA MSG.GOTO
|
|
|
|
|
L.MSG.OK .DA MSG.OK
|
|
|
|
|
L.MSG.ERROR .DA MSG.ERROR
|
|
|
|
|
.DA 0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.INIT >LDYA L.LIBTUI
|
|
|
|
|
>SYSCALL LoadLib
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
sta hLIBTUI
|
|
|
|
|
|
|
|
|
|
.9
|
|
|
|
|
CS.INIT.RTS rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.USAGE >LDYA L.MSG.USAGE
|
|
|
|
|
>SYSCALL PutS
|
|
|
|
|
lda #E.SYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2023-05-30 17:13:23 +00:00
|
|
|
|
CS.RUN >LDYAI 256
|
2023-05-19 15:39:42 +00:00
|
|
|
|
>SYSCALL GetMem
|
|
|
|
|
bcs CS.INIT.RTS
|
|
|
|
|
|
2023-05-30 17:13:23 +00:00
|
|
|
|
>STYA ZPLinePtr
|
|
|
|
|
stx hLineBuf
|
|
|
|
|
|
|
|
|
|
lda #1
|
|
|
|
|
>SYSCALL ArgV
|
|
|
|
|
bcc .1
|
|
|
|
|
|
|
|
|
|
>LDYA L.FILE.INDEX
|
2023-05-19 15:39:42 +00:00
|
|
|
|
|
2023-05-30 17:13:23 +00:00
|
|
|
|
.1 jsr CS.GetLink
|
|
|
|
|
bcs CS.RUN.USAGE
|
|
|
|
|
|
|
|
|
|
jsr CS.GetFile
|
2023-05-19 15:39:42 +00:00
|
|
|
|
bcs CS.INIT.RTS
|
|
|
|
|
|
|
|
|
|
jsr CS.Scr.Init
|
|
|
|
|
bcs CS.INIT.RTS
|
|
|
|
|
*--------------------------------------
|
2023-05-30 17:13:23 +00:00
|
|
|
|
CS.RUN.LOOP0 jsr CS.Scr.SetBuf
|
2023-05-19 15:39:42 +00:00
|
|
|
|
jsr CS.Scr.SetStatusOkErr
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.LOOP >SLEEP
|
|
|
|
|
|
|
|
|
|
lda hSCR
|
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.Exec
|
|
|
|
|
bcs CS.RUN.LOOP.9
|
|
|
|
|
|
|
|
|
|
tay
|
|
|
|
|
beq CS.RUN.LOOP No Event
|
|
|
|
|
|
|
|
|
|
cmp #3
|
|
|
|
|
beq CS.RUN.LOOP.9
|
|
|
|
|
|
|
|
|
|
cmp #EV.HL.SELECTED
|
|
|
|
|
bne .1
|
|
|
|
|
|
2023-05-30 17:13:23 +00:00
|
|
|
|
>LEA.G LinkBuf
|
|
|
|
|
jsr CS.GetLink
|
|
|
|
|
|
2023-05-19 15:39:42 +00:00
|
|
|
|
jsr CS.Scr.SetStatusGoto
|
|
|
|
|
bcc CS.RUN.LOOP
|
|
|
|
|
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.1 cmp #EV.HL.PRESSED
|
|
|
|
|
bne CS.RUN.LOOP
|
|
|
|
|
|
2023-05-30 17:13:23 +00:00
|
|
|
|
jsr CS.GetFile
|
|
|
|
|
jsr CS.Scr.SetStatusOkErr
|
2023-05-19 15:39:42 +00:00
|
|
|
|
bcc CS.RUN.LOOP0
|
|
|
|
|
|
|
|
|
|
CS.RUN.LOOP.9 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
|
|
|
|
|
*--------------------------------------
|
2023-05-30 17:13:23 +00:00
|
|
|
|
CS.QUIT lda hLineBuf
|
|
|
|
|
jsr .7
|
|
|
|
|
|
|
|
|
|
lda hFileBuf
|
|
|
|
|
jsr .7
|
|
|
|
|
|
|
|
|
|
lda hCTX
|
2023-05-19 15:39:42 +00:00
|
|
|
|
beq .1
|
2023-05-30 17:13:23 +00:00
|
|
|
|
|
2023-05-19 15:39:42 +00:00
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.Close
|
|
|
|
|
|
|
|
|
|
.1 lda hLIBTUI
|
2023-05-30 17:13:23 +00:00
|
|
|
|
beq .2
|
2023-05-19 15:39:42 +00:00
|
|
|
|
|
|
|
|
|
>SYSCALL UnloadLib
|
|
|
|
|
|
2023-05-30 17:13:23 +00:00
|
|
|
|
.2 clc
|
2023-05-19 15:39:42 +00:00
|
|
|
|
rts
|
2023-05-30 17:13:23 +00:00
|
|
|
|
|
|
|
|
|
.7 beq .8
|
|
|
|
|
|
2023-07-14 10:24:49 +00:00
|
|
|
|
>SYSCALL FreeMem
|
2023-05-30 17:13:23 +00:00
|
|
|
|
|
|
|
|
|
.8 rts
|
2023-05-19 15:39:42 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.Scr.Init >LIBCALL hLIBTUI,LIBTUI.Init
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
sta hCTX
|
|
|
|
|
|
|
|
|
|
>PUSHA hCTX
|
|
|
|
|
>PUSHBI S.OBJ.F.bTitle+S.OBJ.F.bStatus
|
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.NewScrn
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
sta hSCR
|
|
|
|
|
|
2023-05-30 17:13:23 +00:00
|
|
|
|
jsr CS.Scr.SetTitle
|
|
|
|
|
jsr CS.Scr.SetStatus
|
2023-05-19 15:39:42 +00:00
|
|
|
|
|
|
|
|
|
>PUSHB hSCR
|
|
|
|
|
>PUSHBI 0 X1
|
|
|
|
|
>PUSHBI 0 Y1
|
|
|
|
|
>PUSHBI 80 W
|
|
|
|
|
>PUSHBI 22 H
|
|
|
|
|
>PUSHBI 0 F
|
2023-05-30 17:13:23 +00:00
|
|
|
|
lda hFileBuf
|
2023-05-19 15:39:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>PUSHYA
|
2023-05-30 17:13:23 +00:00
|
|
|
|
>PUSHW BufSize
|
2023-05-19 15:39:42 +00:00
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.NewTBox
|
|
|
|
|
.99 bcs .9
|
|
|
|
|
|
|
|
|
|
sta hTBOX
|
|
|
|
|
|
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.Activate
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>PUSHB hTBOX
|
|
|
|
|
>PUSHBI S.OBJ.pVar
|
2023-05-30 17:13:23 +00:00
|
|
|
|
>PUSHEA.G LinkBuf
|
2023-05-19 15:39:42 +00:00
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.SetProp
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.Scr.SetTitle >PUSHB hSCR
|
|
|
|
|
>PUSHBI S.OBJ.pTITLE
|
|
|
|
|
>PUSHW L.MSG.ScrTitle
|
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.SetProp
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.Scr.SetBuf >PUSHB hTBOX
|
|
|
|
|
>PUSHBI S.OBJ.pBuf
|
2023-05-30 17:13:23 +00:00
|
|
|
|
lda hFileBuf
|
2023-05-19 15:39:42 +00:00
|
|
|
|
>SYSCALL GetMemPtr
|
|
|
|
|
>PUSHYA
|
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.SetProp
|
2023-05-30 17:13:23 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>PUSHB hTBOX
|
|
|
|
|
>PUSHBI S.OBJ.BufSize
|
|
|
|
|
>PUSHW BufSize
|
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.SetProp
|
|
|
|
|
|
|
|
|
|
.9 rts
|
2023-05-19 15:39:42 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.Scr.SetStatusGoto
|
|
|
|
|
>PUSHEA.G SCR.StatusBuf skip type
|
|
|
|
|
>PUSHW L.MSG.GOTO
|
2023-05-30 17:13:23 +00:00
|
|
|
|
>PUSHEA.G PathBuf
|
|
|
|
|
>PUSHEA.G HtagBuf
|
|
|
|
|
>PUSHBI 4
|
2023-05-19 15:39:42 +00:00
|
|
|
|
>SYSCALL SPrintF
|
|
|
|
|
bra CS.Scr.SetStatus
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.Scr.SetStatusOkErr
|
|
|
|
|
bcc .1
|
|
|
|
|
|
|
|
|
|
pha
|
|
|
|
|
>PUSHEA.G SCR.StatusBuf
|
|
|
|
|
>PUSHW L.MSG.ERROR
|
|
|
|
|
pla
|
|
|
|
|
pha
|
|
|
|
|
>PUSHA
|
|
|
|
|
>PUSHBI 1
|
|
|
|
|
>SYSCALL SPrintF
|
|
|
|
|
jsr CS.Scr.SetStatus
|
|
|
|
|
pla
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.1 >PUSHEA.G SCR.StatusBuf
|
|
|
|
|
>PUSHW L.MSG.OK
|
|
|
|
|
>PUSHBI 0
|
|
|
|
|
>SYSCALL SPrintF
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.Scr.SetStatus
|
|
|
|
|
>PUSHB hSCR
|
|
|
|
|
>PUSHBI S.OBJ.pSTATUS
|
|
|
|
|
>PUSHEA.G SCR.StatusBuf
|
|
|
|
|
>LIBCALL hLIBTUI,LIBTUI.SetProp
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* [[text]host:port/path#htag]
|
2023-05-30 17:13:23 +00:00
|
|
|
|
* [#htag]text]
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.GetLink >STYA ZPPtr1
|
|
|
|
|
|
|
|
|
|
>LEA.G PathBuf
|
|
|
|
|
>STYA ZPPtr2
|
|
|
|
|
|
|
|
|
|
>LEA.G HTagBuf
|
|
|
|
|
>STYA ZPPtr3
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPPtr2)
|
|
|
|
|
|
|
|
|
|
>PUSHW L.ENV.MANPATH
|
|
|
|
|
>PUSHW ZPPtr2
|
|
|
|
|
>SYSCALL GetEnv
|
|
|
|
|
|
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.2 jsr CS.GetCharPtr1
|
|
|
|
|
beq .4
|
|
|
|
|
|
|
|
|
|
cmp #'#'
|
|
|
|
|
beq .3
|
|
|
|
|
|
|
|
|
|
sta (ZPPtr2),y
|
|
|
|
|
iny
|
|
|
|
|
bra .2
|
|
|
|
|
|
|
|
|
|
.3 lda #0
|
|
|
|
|
|
|
|
|
|
.4 sta (ZPPtr2),y
|
|
|
|
|
|
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.5 iny
|
|
|
|
|
jsr CS.GetCharPtr1
|
|
|
|
|
sta (ZPPtr3),y
|
|
|
|
|
bne .5
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
|
|
|
|
|
.9 rts
|
2023-05-19 15:39:42 +00:00
|
|
|
|
*--------------------------------------
|
2023-05-30 17:13:23 +00:00
|
|
|
|
CS.GetCharPtr1 lda (ZPPtr1)
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
inc ZPPtr1
|
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.GetFile >LEA.G PathBuf
|
|
|
|
|
>SYSCALL LoadTxtFile
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
stx hFileBuf
|
|
|
|
|
iny
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
inc
|
|
|
|
|
|
|
|
|
|
.1 >STYA BufSize
|
2023-05-19 15:39:42 +00:00
|
|
|
|
|
2023-05-30 17:13:23 +00:00
|
|
|
|
.9 rts
|
2023-05-19 15:39:42 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.END
|
|
|
|
|
LIBTUI .AZ "libtui"
|
|
|
|
|
hLIBTUI .BS 1
|
2023-05-30 17:13:23 +00:00
|
|
|
|
ENV.MANPATH .AZ "MANPATH"
|
|
|
|
|
FILE.INDEX .AZ "index"
|
2023-05-19 15:39:42 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MSG.ScrTitle .CZ "A2osX-MAN - <Ctrl-Q>uit"
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MSG.USAGE .CS "Usage : MAN <manfile>[#htag]"
|
|
|
|
|
MSG.CRLF .CS "\r\n"
|
|
|
|
|
MSG.NULL .HS 00
|
2023-05-30 17:13:23 +00:00
|
|
|
|
MSG.GOTO .CZ "Goto: %s#%s"
|
2023-05-19 15:39:42 +00:00
|
|
|
|
MSG.OK .CZ "Ok"
|
|
|
|
|
MSG.ERROR .CZ "Error: $%h"
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2023-05-30 17:13:23 +00:00
|
|
|
|
LinkBuf .BS 32
|
2023-05-19 15:39:42 +00:00
|
|
|
|
PathBuf .BS MLI.MAXPATH+1
|
2023-05-30 17:13:23 +00:00
|
|
|
|
HTagBuf .BS 32
|
2023-05-19 15:39:42 +00:00
|
|
|
|
SCR.StatusBuf .BS 80
|
|
|
|
|
DS.END .ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
|
|
|
|
SAVE usr/src/bin/man.s
|
|
|
|
|
ASM
|