mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-23 07:35:19 +00:00
284 lines
5.0 KiB
Plaintext
284 lines
5.0 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.SRC
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BOOT/BIN/LS
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
.INB INC/LIBSTR.I
|
||
*--------------------------------------
|
||
ZPPtr1 .EQ ZPBIN
|
||
ZPPtr2 .EQ ZPBIN+2
|
||
*--------------------------------------
|
||
* 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.LIBSTR .DA LIBSTR
|
||
L.MSG.VOL .DA MSG.VOL
|
||
L.MSG.DIR .DA MSG.DIR
|
||
L.MSG.FILE .DA MSG.FILE
|
||
L.PRODOS.FT.TXT .DA PRODOS.FT.TXT
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT >LDYA L.LIBSTR
|
||
>SYSCALL SYS.LoadLibYA
|
||
sta hLIBSTR
|
||
|
||
>SYSCALL SYS.GetArgC
|
||
cmp #1
|
||
bne .1
|
||
|
||
ldy #S.PS.hPREFIX
|
||
lda (pPs),y
|
||
>SYSCALL SYS.GetMemPtrA
|
||
>SYSCALL SYS.NewPStrYA no arg, go get current prefix
|
||
stx hFullPath
|
||
bra .2
|
||
|
||
.1 lda #1
|
||
>SYSCALL SYS.GetArgA
|
||
|
||
>SYSCALL SYS.GetFullPathYA
|
||
stx hFullPath
|
||
|
||
.2 >SYSCALL SYS.OPENDIRYA
|
||
bcs .99
|
||
ldy #hDIR
|
||
sta (pData),y
|
||
|
||
jsr .99
|
||
|
||
lda (pPs)
|
||
ora #S.PS.F.EVENT Now accept events
|
||
sta (pPs)
|
||
|
||
clc
|
||
rts
|
||
|
||
.99 pha
|
||
lda hFullPath
|
||
>SYSCALL SYS.FreeMemA
|
||
pla
|
||
sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN ldy #bCANCEL
|
||
lda (pData),y
|
||
beq .1
|
||
sec
|
||
rts
|
||
|
||
.1 ldy #bSTOP
|
||
lda (pData),y
|
||
beq .2
|
||
clc
|
||
rts
|
||
|
||
.2 ldy #hDIR
|
||
lda (pData),y
|
||
>SYSCALL SYS.READDIRA
|
||
bcs .9
|
||
|
||
phx Save hDIRENT
|
||
>STYA ZPPtr1
|
||
|
||
.3 lda (ZPPtr1)
|
||
|
||
beq .8
|
||
|
||
lda ZPPtr1
|
||
sec
|
||
adc (ZPPtr1)
|
||
sta ZPPtr2
|
||
lda ZPPtr1+1
|
||
adc #0
|
||
sta ZPPtr2+1
|
||
|
||
ldy #S.STAT.PRODOS.TYPE
|
||
lda (ZPPtr2),y
|
||
cmp #$0F Directory ?
|
||
bne .31
|
||
|
||
lda #'/'
|
||
>SYSCALL SYS.COutA
|
||
|
||
.31 >LDYA ZPPtr1
|
||
>SYSCALL SYS.PStrOutYA
|
||
|
||
ldy #S.STAT.PRODOS.TYPE
|
||
lda (ZPPtr2),y
|
||
cmp #$0F Directory ?
|
||
beq .32
|
||
|
||
pha
|
||
lda #'.'
|
||
>SYSCALL SYS.COutA
|
||
|
||
pla
|
||
jsr FileType2PSTR
|
||
>SYSCALL SYS.PStrOutYA
|
||
|
||
|
||
|
||
|
||
.32
|
||
|
||
lda #13
|
||
>SYSCALL SYS.COutA
|
||
|
||
.7 lda ZPPtr2
|
||
clc
|
||
adc #S.STAT
|
||
sta ZPPtr1
|
||
lda ZPPtr2+1
|
||
adc #0
|
||
sta ZPPtr1+1
|
||
bra .3
|
||
|
||
.8 pla
|
||
>SYSCALL SYS.FreeMemA
|
||
clc
|
||
.9 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 #hDIR
|
||
lda (pData),y
|
||
|
||
>SYSCALL SYS.CLOSEDIRA
|
||
|
||
ldy #hDIRPATH
|
||
lda (pData),y
|
||
beq .3
|
||
>SYSCALL SYS.FreeMemA
|
||
|
||
.3 lda hLIBSTR
|
||
>SYSCALL SYS.UnloadLibA
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
FileType2PSTR ldy #0
|
||
|
||
.1 cmp PRODOS.FT.HEX,y
|
||
beq .3
|
||
|
||
.2 iny
|
||
cpy #PRODOS.FT.TXT-PRODOS.FT.TXT
|
||
bne .1
|
||
|
||
pha
|
||
lsr
|
||
lsr
|
||
lsr
|
||
lsr
|
||
tax
|
||
lda HEXDIGIT,x
|
||
sta PRODOS.FT.DFLT+2
|
||
|
||
pla
|
||
and #$0F
|
||
tax
|
||
lda HEXDIGIT,x
|
||
sta PRODOS.FT.DFLT+3
|
||
|
||
.3 tya
|
||
asl
|
||
asl CC
|
||
adc L.PRODOS.FT.TXT
|
||
tay
|
||
lda L.PRODOS.FT.TXT+1
|
||
adc #0
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
LIBSTR >PSTRING "libstr.o"
|
||
MSG.VOL >CSTRING "/%S\n"
|
||
MSG.DIR >CSTRING "/%15S <dir> %a %T %t %T %t\n"
|
||
MSG.FILE >CSTRING "%15S %S $%H %a %8L %T %t %T %t\n"
|
||
*--------------------------------------
|
||
PRODOS.FT.HEX .HS 0406FAFCFDE2FF
|
||
PRODOS.FT.TXT >PSTRING "TXT"
|
||
>PSTRING "BIN"
|
||
>PSTRING "S-C"
|
||
>PSTRING "BAS"
|
||
>PSTRING "VAR"
|
||
>PSTRING "ATK"
|
||
>PSTRING "SYS"
|
||
PRODOS.FT.DFLT >PSTRING "$ "
|
||
HEXDIGIT .AS '0123456789ABCDEF'
|
||
hLIBSTR .BS 1
|
||
hFullPath .BS 1
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
hDIRPATH .BS 1
|
||
hDIR .BS 1
|
||
hVOLHEADER .BS 1
|
||
hDIRHEADER .BS 1
|
||
bSTOP .BS 1
|
||
bCANCEL .BS 1
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE BIN/LS.S
|
||
ASM
|