A2osX/BIN/RM.S.txt

271 lines
4.6 KiB
Plaintext
Raw Normal View History

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/RM
*--------------------------------------
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/A2OSX.API.I
.INB INC/LIBSTR.I
*--------------------------------------
ZPListDirPTR .EQ ZPBIN
*--------------------------------------
* 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.FullPath .DA FullPath
.DA 0
*--------------------------------------
CS.INIT lda #0
ldy #DS.END-DS.START-1
.11 sta (pData),y
dey
bpl .11
ldy #S.PS.hARGS
lda (pPs),y
beq .98
>SYSCALL SYS.GetMemPtrA
>STYA ZPQuickPtr1
lda (ZPQuickPtr1)
beq .98
ldy #1
lda (ZPQuickPtr1),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 SYS.PStrCat
sta hDIRPATH
.3 >SYSCALL SYS.ListDirInitA
bcs .99
ldy #hS.LISTDIR
sta (pData),y
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
rts
.98 lda #SYSMGR.ERRSYN
.99 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 SYS.ListDirNextA
bcs .99
pha
>SYSCALL SYS.GetMemPtrA
>STYA ZPQuickPtr1
lda (ZPQuickPtr1)
pha
and #$0F
sta (ZPQuickPtr1) Adjust Filename len
pla
and #$F0
cmp #$F0 Volume ($F) HEADER ?
beq .8
cmp #$E0 Dir ($E) HEADER ?
beq .8
ldy #hS.LISTDIR
lda (pData),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPQuickPtr2
ldy #S.LISTDIR.hPATH
lda (ZPQuickPtr2),y
>SYSCALL SYS.GetMemPtrA
>STYA ZPQuickPtr2
lda (ZPQuickPtr2)
tax
tay
.2 lda (ZPQuickPtr2),y
sta FullPath,y
dey
bne .2
ldy #0
.3 inx
iny
lda (ZPQuickPtr1),y
sta FullPath,x
tya
cmp (ZPQuickPtr1)
bne .3
stx FullPath
ldy #0
.4 iny
lda FullPath,y
jsr COUT
cpy FullPath
bne .4
>LDYA L.FullPath
>SYSCALL SYS.MLIDestroyYA
bcc .5
pha
lda #"["
jsr COUT
pla
jsr PRBYTE
lda #"]"
jsr COUT
.5 jsr CROUT
.8 pla
>SYSCALL SYS.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
>SYSCALL SYS.ListDirCloseA
ldy #hDIRPATH
lda (pData),y
beq .3
>SYSCALL SYS.FreeMemA
.3 clc
rts
*--------------------------------------
PRBYTE pha
lsr
lsr
lsr
lsr
ora #$B0
cmp #$BA
bcc .1
adc #6
.1 jsr COUT
pla
and #$0F
ora #$B0
cmp #$BA
bcc COUT
adc #6
bra COUT
*--------------------------------------
CROUT lda #13
*--------------------------------------
COUT phx
phy
ldx #DEVMGR.COUT
jsr pDevJmp
ply
plx
rts
pDevJmp jmp (pDev)
*--------------------------------------
CS.END
FullPath .BS 64
*--------------------------------------
.DUMMY
.OR 0
DS.START
hDIRPATH .BS 1
hS.LISTDIR .BS 1
bSTOP .BS 1
bCANCEL .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE BIN/RM.S
ASM