2016-12-02 16:09:24 +00:00
|
|
|
|
PR#3
|
2017-03-29 15:48:15 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2016-12-02 16:09:24 +00:00
|
|
|
|
NEW
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
.LIST OFF
|
|
|
|
|
.OP 65C02
|
|
|
|
|
.OR $2000
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.TF /A2OSX.BUILD/BIN/FORMAT
|
2016-12-02 16:09:24 +00:00
|
|
|
|
*--------------------------------------
|
2017-03-29 15:48:15 +00:00
|
|
|
|
.INB /A2OSX.BUILD/INC/MACROS.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/A2OSX.I
|
|
|
|
|
.INB /A2OSX.BUILD/INC/LIBBLKDEV.I
|
2016-12-02 16:09:24 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
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
|
2017-03-30 16:11:31 +00:00
|
|
|
|
L.BlkParams.Ptr .DA BlkParams.Ptr
|
|
|
|
|
L.MSG.USAGE .DA MSG.USAGE
|
|
|
|
|
L.MSG.INIT .DA MSG.INIT
|
|
|
|
|
L.MSG.OK .DA MSG.OK
|
|
|
|
|
L.MSG.ERR .DA MSG.ERR
|
2016-12-02 16:09:24 +00:00
|
|
|
|
.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
|
|
|
|
|
|
2017-03-30 16:11:31 +00:00
|
|
|
|
.4 ldy #hDev
|
|
|
|
|
lda (pData),y
|
|
|
|
|
bne .5 Already have a dev name...go get VolName
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
2017-03-30 16:11:31 +00:00
|
|
|
|
cmp #4
|
|
|
|
|
bne .99 DevName must be DxDy
|
|
|
|
|
|
|
|
|
|
>LDYA ZPPtr1
|
|
|
|
|
>SYSCALL GetDevByNameYA
|
|
|
|
|
bcs .99
|
|
|
|
|
txa
|
|
|
|
|
ldy #hDev
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.5 lda (ZPPtr1)
|
2016-12-02 16:09:24 +00:00
|
|
|
|
cmp #16
|
2017-03-30 16:11:31 +00:00
|
|
|
|
bcs .99 VolName too long
|
|
|
|
|
|
2016-12-02 16:09:24 +00:00
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.6 lda (ZPPtr1),y
|
|
|
|
|
sta (pData),y
|
|
|
|
|
dey
|
2017-03-30 16:11:31 +00:00
|
|
|
|
bpl .6
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
2017-03-30 16:11:31 +00:00
|
|
|
|
bra .1 success, scan for any other args
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
|
|
|
|
.7 lda (pData)
|
|
|
|
|
bne .8 Volume name ok
|
|
|
|
|
|
2017-03-30 16:11:31 +00:00
|
|
|
|
lda A2osX.TIMER16
|
|
|
|
|
jsr A2CharAX
|
|
|
|
|
sta DefaultVolName+6
|
|
|
|
|
stx DefaultVolName+7
|
|
|
|
|
|
|
|
|
|
lda A2osX.TIMER16+1
|
|
|
|
|
jsr A2CharAX
|
|
|
|
|
sta DefaultVolName+8
|
|
|
|
|
stx DefaultVolName+9
|
|
|
|
|
|
|
|
|
|
lda A2osX.RANDOM16
|
|
|
|
|
jsr A2CharAX
|
|
|
|
|
sta DefaultVolName+10
|
|
|
|
|
stx DefaultVolName+11
|
|
|
|
|
|
|
|
|
|
lda A2osX.RANDOM16+1
|
|
|
|
|
jsr A2CharAX
|
|
|
|
|
sta DefaultVolName+12
|
|
|
|
|
stx DefaultVolName+13
|
|
|
|
|
|
2016-12-02 16:09:24 +00:00
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
2017-03-30 16:11:31 +00:00
|
|
|
|
CS.RUN jsr CS.RUN.BuildCat
|
|
|
|
|
bcs .9
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
2017-03-30 16:11:31 +00:00
|
|
|
|
jsr CS.RUN.WriteCat
|
|
|
|
|
bcs .9
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
2017-03-30 16:11:31 +00:00
|
|
|
|
>LDYA L.MSG.OK
|
|
|
|
|
>SYSCALL CPrintFYA
|
|
|
|
|
lda #0
|
|
|
|
|
sec
|
2016-12-02 16:09:24 +00:00
|
|
|
|
rts
|
|
|
|
|
|
2017-03-30 16:11:31 +00:00
|
|
|
|
.9 pha
|
|
|
|
|
>PUSHA
|
|
|
|
|
>LDYA L.MSG.ERR
|
|
|
|
|
>SYSCALL CPrintFYA
|
|
|
|
|
pla
|
2016-12-02 16:09:24 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-30 16:11:31 +00:00
|
|
|
|
CS.RUN.BuildCat ldy #hDev
|
|
|
|
|
lda (pData),y
|
|
|
|
|
>SYSCALL GetDevStatusA
|
|
|
|
|
|
|
|
|
|
bcs .99
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
ldy #S.DEVSTAT.SIZE
|
|
|
|
|
lda (ZPPtr1),y
|
2017-03-31 15:24:42 +00:00
|
|
|
|
sta SizeInBlocks
|
2017-03-30 16:11:31 +00:00
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtr1),y
|
2017-03-31 15:24:42 +00:00
|
|
|
|
sta SizeInBlocks+1
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
|
|
|
|
ldy #hDev
|
|
|
|
|
lda (pData),y
|
|
|
|
|
>SYSCALL GetDevByIDA
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
pha
|
|
|
|
|
tya
|
|
|
|
|
adc #S.DEV.NAME
|
|
|
|
|
sta ZPPtr2
|
|
|
|
|
pla
|
|
|
|
|
adc /S.DEV.NAME
|
|
|
|
|
sta ZPPtr2+1
|
|
|
|
|
|
|
|
|
|
>PUSHW pData
|
2017-03-31 15:24:42 +00:00
|
|
|
|
>PUSHW SizeInBlocks
|
2017-03-30 16:11:31 +00:00
|
|
|
|
>PUSHW ZPPtr2
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.INIT
|
|
|
|
|
>SYSCALL CPrintFYA
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-03-31 15:24:42 +00:00
|
|
|
|
>PUSHW SizeInBlocks
|
2017-03-30 16:11:31 +00:00
|
|
|
|
>LIBCALL hLIBBLKDEV,LIBBLKDEV.GetProDOSCatSize
|
|
|
|
|
|
|
|
|
|
.99 bcs .9
|
|
|
|
|
stx BlkCnt
|
|
|
|
|
|
|
|
|
|
>PUSHYA BufferSize
|
|
|
|
|
>PUSHBI S.MEM.F.INIT0
|
|
|
|
|
>SYSCALL GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
>STYA BlkParams.Ptr
|
|
|
|
|
txa
|
|
|
|
|
ldy #hBuf
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2017-03-31 15:24:42 +00:00
|
|
|
|
>PUSHW SizeInBlocks
|
2017-03-30 16:11:31 +00:00
|
|
|
|
>PUSHW pData
|
|
|
|
|
>PUSHW BlkParams.Ptr
|
|
|
|
|
>LIBCALL hLIBBLKDEV,LIBBLKDEV.BuildProDOSCat
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.WriteCat stz BlkParams.Num
|
|
|
|
|
stz BlkParams.Num+1
|
|
|
|
|
|
|
|
|
|
ldy #hDev
|
|
|
|
|
lda (pData),y
|
|
|
|
|
>SYSCALL GetDevByIDA
|
|
|
|
|
bcs .9
|
|
|
|
|
>STYA pDev
|
|
|
|
|
|
|
|
|
|
.1 >LDYA L.BlkParams.Ptr
|
|
|
|
|
ldx #DEVMGR.WRITEBLOCK
|
|
|
|
|
|
|
|
|
|
jsr pDevJmp
|
|
|
|
|
bcs .9
|
|
|
|
|
inc BlkParams.Ptr+1
|
|
|
|
|
inc BlkParams.Ptr+1
|
|
|
|
|
inc BlkParams.Num
|
|
|
|
|
dec BlkCnt
|
|
|
|
|
bne .1
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-03-13 16:55:43 +00:00
|
|
|
|
CS.DOEVENT sec
|
2016-12-02 16:09:24 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-30 16:11:31 +00:00
|
|
|
|
CS.QUIT ldy #hBuf
|
|
|
|
|
lda (pData),y
|
|
|
|
|
beq .1
|
|
|
|
|
>SYSCALL FreeMemA
|
|
|
|
|
|
|
|
|
|
.1 lda hLIBBLKDEV
|
2016-12-02 16:09:24 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
>SYSCALL UnloadLibA
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-30 16:11:31 +00:00
|
|
|
|
A2CharAX pha
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
and #$0F
|
|
|
|
|
ora #$30
|
|
|
|
|
cmp #'9'+1
|
|
|
|
|
bcc .1
|
|
|
|
|
adc #6
|
|
|
|
|
.1 tax
|
|
|
|
|
pla
|
|
|
|
|
and #$0F
|
|
|
|
|
ora #$30
|
|
|
|
|
cmp #'9'+1
|
|
|
|
|
bcc .8
|
|
|
|
|
adc #6
|
|
|
|
|
.8 rts
|
|
|
|
|
*--------------------------------------
|
2016-12-02 16:09:24 +00:00
|
|
|
|
CS.END
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
OptionList >PSTR "L"
|
|
|
|
|
OptionVars .DA #bLL
|
|
|
|
|
*--------------------------------------
|
2017-03-13 16:55:43 +00:00
|
|
|
|
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"
|
2017-03-30 16:11:31 +00:00
|
|
|
|
MSG.INIT >CSTR "Formatting %S (%D Blks),Volname:%S..."
|
2016-12-02 16:09:24 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
LIBBLKDEV >PSTR "libblkdev.o"
|
2017-03-30 16:11:31 +00:00
|
|
|
|
DefaultVolName >PSTR "BLANKXXXXXXXX"
|
2016-12-02 16:09:24 +00:00
|
|
|
|
ArgCount .BS 1
|
|
|
|
|
ArgIndex .BS 1
|
|
|
|
|
hLIBBLKDEV .BS 1
|
2017-03-31 15:24:42 +00:00
|
|
|
|
SizeInBlocks .BS 2
|
2017-03-30 16:11:31 +00:00
|
|
|
|
BlkCnt .BS 1
|
|
|
|
|
BlkParams.Ptr .BS 2
|
|
|
|
|
BlkParams.Num .BS 2
|
2016-12-02 16:09:24 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
|
|
|
|
VolName .BS 16
|
2017-03-30 16:11:31 +00:00
|
|
|
|
hDev .BS 5
|
2017-03-31 15:24:42 +00:00
|
|
|
|
hBuf .BS 1
|
2016-12-02 16:09:24 +00:00
|
|
|
|
bLL .BS 1
|
|
|
|
|
DS.END
|
|
|
|
|
.ED
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/BIN/FORMAT.S
|
2016-12-02 16:09:24 +00:00
|
|
|
|
ASM
|