A2osX/BIN/FORMAT.S.txt

217 lines
3.9 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/FORMAT
*--------------------------------------
.INB /A2OSX.DEV/INC/MACROS.I
.INB /A2OSX.DEV/INC/A2OSX.I
.INB /A2OSX.DEV/INC/LIBBLKDEV.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.LIBBLKDEV .DA LIBBLKDEV
L.MSG.USAGE .DA MSG.USAGE
.DA 0
*--------------------------------------
CS.INIT >SYSCALL GetArgC
sta ArgCount
cmp #1
beq .99
stz ArgIndex
.1 dec ArgCount
beq .7
inc ArgIndex
lda ArgIndex
>SYSCALL GetArgA
>STYA ZPPtr1
lda (ZPPtr1)
cmp #2
bne .4
ldy #1
lda (ZPPtr1),y
cmp #'-'
bne .4
iny
lda (ZPPtr1),y
ldx OptionList
.2 cmp OptionList,x
beq .3
dex
bne .2
.99 >LDYA L.MSG.USAGE
>SYSCALL CPrintFYA
lda #SYSMGR.ERRSYN
sec
rts
.3 ldy OptionVars-1,x
lda #$80
sta (pData),y
bra .1
.4 lda (pData)
bne .99 Already have a vol name...syntax error
lda (ZPPtr1)
cmp #16
bcc .5
lda #15
.5 sta (ZPPtr1)
tay
.6 lda (ZPPtr1),y
sta (pData),y
dey
bne .6
bra .1 success, scan for any other args
.7 lda (pData)
bne .8 Volume name ok
ldy DefaultVolName
.71 lda DefaultVolName,y
sta (pData),y
dey
bpl .71
.8 >LDYA L.LIBBLKDEV
>SYSCALL LoadLibYA
sta hLIBBLKDEV
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
rts
*--------------------------------------
CS.RUN ldy #bCANCEL
lda (pData),y
bmi .99
ldy #bSTOP
lda (pData),y
bmi .8
.8 clc
rts
.99 lda #0
sec
rts
*--------------------------------------
CS.DOEVENT ldy #S.EVT.hDEV is Event from active IN device?
lda (pEvent),y
2017-01-12 17:43:45 +00:00
ldy #S.PS.hStdIn
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 lda hLIBBLKDEV
beq .8
>SYSCALL UnloadLibA
.8 clc
rts
*--------------------------------------
CS.END
*--------------------------------------
OptionList >PSTR "L"
OptionVars .DA #bLL
*--------------------------------------
MSG.USAGE >CSTR "Usage : FORMAT <BLOCKDEV> [VOLUME.NAME]\n -L : Low-Level Format\n"
MSG.OK >CSTR "[OK]\n"
MSG.ERR >CSTR "[%h]\n"
*--------------------------------------
LIBBLKDEV >PSTR "libblkdev.o"
DefaultVolName >PSTR "BLANK"
ArgCount .BS 1
ArgIndex .BS 1
hLIBBLKDEV .BS 1
*--------------------------------------
.DUMMY
.OR 0
DS.START
VolName .BS 16
DevName .BS 4
bCANCEL .BS 1
bSTOP .BS 1
bLL .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE BIN/FORMAT.S
ASM