A2osX/BIN/FORMAT.S.txt

176 lines
3.3 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/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
.8 clc
rts
.99 lda #0
sec
rts
*--------------------------------------
CS.DOEVENT 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]\r\n -L : Low-Level Format\r\n"
MSG.OK >CSTR "[OK]\r\n"
MSG.ERR >CSTR "[%h]\r\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
bLL .BS 1
DS.END
.ED
*--------------------------------------
MAN
SAVE BIN/FORMAT.S
ASM