A2osX/BIN/CHTYP.S.txt
2016-10-24 17:54:43 +02:00

354 lines
6.0 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/CHTYP
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
*--------------------------------------
ZPPtr1 .EQ ZPBIN
ZPPtr2 .EQ ZPBIN+2
ZPPtr3 .EQ ZPBIN+4
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START Code Length To Relocate
.DA DS.END-DS.START Data Segment to Allocate
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.OK .DA MSG.OK
L.MSG.ERR .DA MSG.ERR
L.FullPath .DA FullPath
L.PRODOS.FT.TXT .DA PRODOS.FT.TXT-1
.DA 0
*--------------------------------------
CS.INIT ldy #S.PS.hARGS
lda (pPs),y
beq .98
>PUSHA
>PUSHBI $20 Push SEP=' '
>PUSHBI 0 Push 0 for getting CMD & ARGS
>SYSCALL PStrGetTkn
bcs .99
ldy #hArg1
sta (pData),y
txa
beq .98
ldy #hArg2
sta (pData),y
jsr GetHexFileTypeA
bcs .99
ldy #hArg1
lda (pData),y
>SYSCALL GetMemPtrA
>STYA ZPPtr1
lda (ZPPtr1)
beq .98
ldy #1
lda (ZPPtr1),y
cmp #'/'
bne .10
ldy #S.PS.hARGS
lda (pPs),y
bra .3
.10 ldy #S.PS.hARGS
lda (pPs),y
>PUSHA
ldy #S.PS.hPREFIX
lda (pPs),y
>PUSHA
>SYSCALL PStrCat
sta hDIRPATH
.3 >SYSCALL GetMemPtrA
>SYSCALL ListDirInitYA
bcs .99
ldy #hS.LISTDIR
sta (pData),y
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
rts
.98 >LDYA L.MSG.USAGE
>SYSCALL PStrOutYA
.99 lda #SYSMGR.ERRSYN
sec
rts
*--------------------------------------
CS.RUN ldy #bCANCEL
lda (pData),y
beq .10
sec
rts
.10 ldy #bSTOP
lda (pData),y
beq .1
clc
.99 rts
.1 ldy #hS.LISTDIR
lda (pData),y
>SYSCALL ListDirNextA
bcs .99
pha
>SYSCALL GetMemPtrA
>STYA ZPPtr1
lda (ZPPtr1)
pha
and #$0F
sta (ZPPtr1) Adjust Filename len
pla
and #$F0
bne .8 skip VOLHeader ($f),DIRHeader ($e),DIR ($d)
ldy #hS.LISTDIR
lda (pData),y
>SYSCALL GetMemPtrA
>STYA ZPPtr2
ldy #S.LISTDIR.hPATH
lda (ZPPtr2),y
>SYSCALL GetMemPtrA
>STYA ZPPtr2
lda (ZPPtr2)
tax
tay
.2 lda (ZPPtr2),y
sta FullPath,y
dey
bne .2
ldy #0
.3 inx
iny
lda (ZPPtr1),y
sta FullPath,x
tya
cmp (ZPPtr1)
bne .3
stx FullPath
>LDYA L.FullPath
>SYSCALL PStrOutYA
>LDYA L.FullPath
>SYSCALL MLIGetFileInfoYA
bcs .5
>STYA ZPPtr3
>LDYA L.MSG.OK
>SYSCALL PStrOutYA
bra .8
.5 >PUSHA
>LDYA L.MSG.ERR
>SYSCALL PStrOutYA
.8 pla
>SYSCALL FreeMemA
clc
rts
*--------------------------------------
CS.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
lda (pEvent),y
ldy #S.PS.hINDEV
cmp (pPs),y
bne .9
lda (pEvent)
and #S.EVT.F.KEY is it a KEY event?
beq .9
ldy #S.EVT.DATAHI is it an O or SAPPLE key ?
lda (pEvent),y
bne .9
ldy #S.EVT.DATALO
lda (pEvent),y
cmp #$03 Ctrl-C
bne .1
lda #$FF
ldy #bCANCEL
sta (pData),y
bra .8
.1 cmp #$13 Ctrl-S
bne .8
ldy #bSTOP
lda (pData),y
eor #$FF
sta (pData),y
.8 clc
rts
.9 sec
rts
*--------------------------------------
CS.QUIT ldy #hS.LISTDIR
lda (pData),y
beq .1
>SYSCALL ListDirCloseA
.1 ldy #hDIRPATH
lda (pData),y
beq .2
>SYSCALL FreeMemA
.2 ldy #hArg2
lda (pData),y
beq .3
>SYSCALL FreeMemA
.3 ldy #hArg1
lda (pData),y
beq .8
>SYSCALL FreeMemA
.8 clc
rts
*--------------------------------------
GetHexFileTypeA >SYSCALL GetMemPtrA
>STYA ZPPtr1
lda (ZPPtr1)
cmp #3
bne .9
ldy #1
lda (ZPPtr1),y
cmp #'$'
bne .1
iny
lda (ZPPtr1),y
cmp #'0'
bcc .9
cmp #'9'+1
bcs .9
asl
asl
asl
asl
sta Tmp
iny
lda (ZPPtr1),y
cmp #'0'
bcc .9
cmp #'9'+1
bcs .9
and #$F
ora Tmp
ldy #HexFileType
sta (pData),y
clc
rts
.1 ldx #0
>LDYA L.PRODOS.FT.TXT
>STYA ZPPtr2
.2 ldy #3
.21 lda (ZPPtr1),y
cmp #'a'
bcc .3
cmp #'z'+1
bcs .3
eor #$20
.3 cmp (ZPPtr2),y
bne .4
dey
bne .21
lda PRODOS.FT.ID,x
ldy #HexFileType
sta (pData),y
clc
rts
.4 clc
lda ZPPtr2
adc #3
sta ZPPtr2
lda ZPPtr2+1
adc #0
sta ZPPtr2+1
inx
cpx #PRODOS.FT.COUNT
bne .2
.9 sec
rts
*--------------------------------------
CS.END
MSG.USAGE >PSTR "Usage : CHTYP [File *,? wildcards allowed] [File type : $xx or SYS,TXT....]\n"
MSG.OK >PSTR " [Ok]\n"
MSG.ERR >PSTR " [%h]\n"
FullPath .BS 64
Tmp .BS 1
*--------------------------------------
PRODOS.FT.COUNT .EQ 7
PRODOS.FT.ID .HS 0406FAFCFDE2FF
PRODOS.FT.TXT .AS "TXT"
.AS "BIN"
.AS "S-C"
.AS "BAS"
.AS "VAR"
.AS "ATK"
.AS "SYS"
*--------------------------------------
.DUMMY
.OR 0
DS.START
hDIRPATH .BS 1
hS.LISTDIR .BS 1
hArg1 .BS 1
hArg2 .BS 1
bSTOP .BS 1
bCANCEL .BS 1
HexFileType .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE BIN/CHTYP.S
ASM