2016-12-02 16:09:24 +00:00
|
|
|
|
NEW
|
2017-12-22 21:24:30 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
|
|
|
|
AUTO 4,1
|
2016-12-02 16:09:24 +00:00
|
|
|
|
.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
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.DA CS.END-CS.START CS
|
|
|
|
|
.DA DS.END-DS.START DS
|
|
|
|
|
.DA #16 SS
|
|
|
|
|
.DA #4 ZP
|
2016-12-02 16:09:24 +00:00
|
|
|
|
.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.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
|
|
|
|
|
*--------------------------------------
|
2017-10-03 15:33:30 +00:00
|
|
|
|
CS.INIT ldy #S.PS.ARGC
|
|
|
|
|
lda (pPs),y
|
2018-04-19 12:06:21 +00:00
|
|
|
|
beq .90
|
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.1 >INC.G ArgIndex
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
2017-08-24 12:46:48 +00:00
|
|
|
|
>SYSCALL GetArg.A
|
2018-04-19 12:06:21 +00:00
|
|
|
|
bcc .11
|
|
|
|
|
jmp .8
|
2017-10-03 15:33:30 +00:00
|
|
|
|
|
2018-04-19 12:06:21 +00:00
|
|
|
|
.11 >STYA ZPPtr1
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .4
|
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
ldy #1
|
2016-12-02 16:09:24 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2018-04-19 12:06:21 +00:00
|
|
|
|
beq .90
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
2018-04-19 12:06:21 +00:00
|
|
|
|
cmp #'0'
|
|
|
|
|
bcc .20
|
|
|
|
|
cmp #'9'+1
|
|
|
|
|
bcs .20
|
|
|
|
|
|
|
|
|
|
and #$0F
|
|
|
|
|
>STA.G CatSize
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.20 ldx OptionList
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
|
|
|
|
.2 cmp OptionList,x
|
|
|
|
|
beq .3
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
2018-04-19 12:06:21 +00:00
|
|
|
|
.90 bra .99
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
|
|
|
|
.3 ldy OptionVars-1,x
|
|
|
|
|
lda #$80
|
|
|
|
|
sta (pData),y
|
|
|
|
|
bra .1
|
|
|
|
|
|
2017-10-04 06:16:39 +00:00
|
|
|
|
.4 >LDA.G hDev
|
2017-03-30 16:11:31 +00:00
|
|
|
|
bne .5 Already have a dev name...go get VolName
|
2017-10-03 15:33:30 +00:00
|
|
|
|
|
2017-03-30 16:11:31 +00:00
|
|
|
|
>LDYA ZPPtr1
|
2017-10-03 15:33:30 +00:00
|
|
|
|
>SYSCALL GetDevByName.YA
|
2017-03-30 16:11:31 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
txa
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>STA.G hDev
|
2017-03-30 16:11:31 +00:00
|
|
|
|
bra .1
|
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.5 ldy #$ff
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.6 iny
|
2017-10-04 15:12:03 +00:00
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .61
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
2017-10-04 15:12:03 +00:00
|
|
|
|
cpy #15
|
2017-10-03 15:33:30 +00:00
|
|
|
|
beq .99 VolName too long
|
|
|
|
|
|
2017-10-04 15:12:03 +00:00
|
|
|
|
.61 >PUSHW ZPPtr1
|
|
|
|
|
>PUSHEA.G VolName
|
|
|
|
|
>SYSCALL StrCpy
|
|
|
|
|
jmp .1 success, scan for any other args
|
2018-04-19 12:06:21 +00:00
|
|
|
|
|
|
|
|
|
.8 >LDYA L.LIBBLKDEV
|
|
|
|
|
>SYSCALL LoadLib.YA
|
|
|
|
|
sta hLIBBLKDEV
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
2018-04-19 12:06:21 +00:00
|
|
|
|
* lda (pPs)
|
|
|
|
|
* ora #S.PS.F.EVENT Now accept events
|
|
|
|
|
* sta (pPs)
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.99 >LDYA L.MSG.USAGE
|
|
|
|
|
>SYSCALL PrintF.YA
|
|
|
|
|
lda #K.E.SYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN jsr CS.RUN.InitCat
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.BuildCat
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr CS.RUN.WriteCat
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.OK
|
|
|
|
|
>SYSCALL PrintF.YA
|
|
|
|
|
lda #0
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 pha
|
|
|
|
|
>PUSHA
|
|
|
|
|
>LDYA L.MSG.ERR
|
|
|
|
|
>SYSCALL PrintF.YA
|
|
|
|
|
pla
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
CS.RUN.InitCat >LDA.G CatSize
|
|
|
|
|
bne .1
|
|
|
|
|
lda #4
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
|
|
|
|
.1 >LDA.G VolName
|
2016-12-02 16:09:24 +00:00
|
|
|
|
bne .8 Volume name ok
|
2017-10-04 06:16:39 +00:00
|
|
|
|
|
|
|
|
|
ldx #$ff
|
|
|
|
|
ldy #VolName-1
|
|
|
|
|
|
2018-04-19 12:06:21 +00:00
|
|
|
|
.2 inx
|
2017-10-04 06:16:39 +00:00
|
|
|
|
iny
|
|
|
|
|
lda BLANK,x
|
|
|
|
|
sta (pData),y
|
2018-04-19 12:06:21 +00:00
|
|
|
|
bne .2
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
2017-03-30 16:11:31 +00:00
|
|
|
|
lda A2osX.TIMER16
|
|
|
|
|
jsr A2CharAX
|
2017-10-04 06:16:39 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
|
|
|
|
lda A2osX.TIMER16+1
|
|
|
|
|
jsr A2CharAX
|
2017-10-04 06:16:39 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
|
|
|
|
lda A2osX.RANDOM16
|
|
|
|
|
jsr A2CharAX
|
2017-10-04 06:16:39 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
|
|
|
|
lda A2osX.RANDOM16+1
|
|
|
|
|
jsr A2CharAX
|
2017-10-04 06:16:39 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
|
|
|
|
txa
|
|
|
|
|
sta (pData),y
|
|
|
|
|
iny
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
2017-10-04 06:16:39 +00:00
|
|
|
|
lda #0
|
2016-12-02 16:09:24 +00:00
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2018-04-19 12:06:21 +00:00
|
|
|
|
.8 clc
|
2016-12-02 16:09:24 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-10-04 06:16:39 +00:00
|
|
|
|
CS.RUN.BuildCat >LDA.G hDev
|
2018-01-15 06:50:44 +00:00
|
|
|
|
>SYSCALL GetDevStatus.A
|
2017-11-21 16:27:07 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
2017-03-30 16:11:31 +00:00
|
|
|
|
>STYA ZPPtr1
|
2017-10-27 06:36:46 +00:00
|
|
|
|
ldy #S.DSTAT.SIZE
|
2017-03-30 16:11:31 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>STA.G SizeInBlocks
|
2017-10-27 06:36:46 +00:00
|
|
|
|
ldy #S.DSTAT.SIZE+1
|
2017-03-30 16:11:31 +00:00
|
|
|
|
lda (ZPPtr1),y
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>STA.G SizeInBlocks+1
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>LDA.G hDev
|
2017-10-03 15:33:30 +00:00
|
|
|
|
>SYSCALL GetDevByID.A
|
2017-03-30 16:11:31 +00:00
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
pha
|
|
|
|
|
tya
|
|
|
|
|
adc #S.DEV.NAME
|
|
|
|
|
sta ZPPtr2
|
|
|
|
|
pla
|
|
|
|
|
adc /S.DEV.NAME
|
|
|
|
|
sta ZPPtr2+1
|
|
|
|
|
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>PUSHEA.G VolName
|
|
|
|
|
>PUSHW.G SizeInBlocks
|
2017-03-30 16:11:31 +00:00
|
|
|
|
>PUSHW ZPPtr2
|
|
|
|
|
|
|
|
|
|
>LDYA L.MSG.INIT
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>SYSCALL PrintF.YA
|
2017-10-04 06:16:39 +00:00
|
|
|
|
.99 bcs .9
|
2017-10-04 15:12:03 +00:00
|
|
|
|
|
2018-04-19 12:06:21 +00:00
|
|
|
|
jsr .7
|
|
|
|
|
|
2017-10-04 15:12:03 +00:00
|
|
|
|
>LIBCALL hLIBBLKDEV,LIBBLKDEV.GetProDOSCatSize
|
2017-10-04 06:16:39 +00:00
|
|
|
|
bcs .9
|
2017-10-04 15:12:03 +00:00
|
|
|
|
|
2017-10-04 06:16:39 +00:00
|
|
|
|
phy
|
|
|
|
|
pha
|
2017-10-04 15:12:03 +00:00
|
|
|
|
txa
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>STA.G BlkCnt
|
|
|
|
|
pla
|
|
|
|
|
ply
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
2018-04-19 12:06:21 +00:00
|
|
|
|
>SYSCALL GetMem0.YA BufferSize
|
2017-03-30 16:11:31 +00:00
|
|
|
|
bcs .9
|
2017-10-04 15:12:03 +00:00
|
|
|
|
|
|
|
|
|
phx
|
|
|
|
|
>STYA.G BlkParams.Ptr
|
|
|
|
|
pla
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>STA.G hBuf
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
2018-04-19 12:06:21 +00:00
|
|
|
|
jsr .7
|
|
|
|
|
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>PUSHEA.G VolName
|
2017-10-04 15:12:03 +00:00
|
|
|
|
>PUSHW.G BlkParams.Ptr
|
2017-03-30 16:11:31 +00:00
|
|
|
|
>LIBCALL hLIBBLKDEV,LIBBLKDEV.BuildProDOSCat
|
|
|
|
|
.9 rts
|
2018-04-19 12:06:21 +00:00
|
|
|
|
|
|
|
|
|
.7 >PUSHW.G SizeInBlocks
|
|
|
|
|
>PUSHB.G CatSize
|
|
|
|
|
>PUSHB.G CatOptions
|
|
|
|
|
rts
|
2017-03-30 16:11:31 +00:00
|
|
|
|
*--------------------------------------
|
2018-01-15 06:50:44 +00:00
|
|
|
|
CS.RUN.WriteCat >PUSHB.G hDev
|
|
|
|
|
>PUSHBI DEVMGR.WRITEBLOCK
|
|
|
|
|
>PUSHEA.G BlkParams.Ptr
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
2018-04-16 15:25:39 +00:00
|
|
|
|
>SYSCALL IOCTL
|
2017-03-30 16:11:31 +00:00
|
|
|
|
bcs .9
|
2017-10-04 15:12:03 +00:00
|
|
|
|
|
|
|
|
|
lda #'.'
|
|
|
|
|
>SYSCALL PutChar.A
|
|
|
|
|
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>LDA.G BlkParams.Ptr+1
|
2018-04-16 15:25:39 +00:00
|
|
|
|
clc
|
2017-10-04 06:16:39 +00:00
|
|
|
|
adc #2
|
|
|
|
|
sta (pData),y
|
|
|
|
|
|
2017-10-04 15:12:03 +00:00
|
|
|
|
>INC.G BlkParams.Num
|
|
|
|
|
|
2018-04-16 15:25:39 +00:00
|
|
|
|
>SLEEP
|
2017-10-04 15:12:03 +00:00
|
|
|
|
|
2017-10-04 06:16:39 +00:00
|
|
|
|
>DEC.G BlkCnt
|
2017-10-04 15:12:03 +00:00
|
|
|
|
bne CS.RUN.WriteCat
|
2017-03-30 16:11:31 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-03-13 16:55:43 +00:00
|
|
|
|
CS.DOEVENT sec
|
2016-12-02 16:09:24 +00:00
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-10-04 06:16:39 +00:00
|
|
|
|
CS.QUIT >LDA.G hBuf
|
2017-03-30 16:11:31 +00:00
|
|
|
|
beq .1
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>SYSCALL FreeMem.A
|
2017-03-30 16:11:31 +00:00
|
|
|
|
|
|
|
|
|
.1 lda hLIBBLKDEV
|
2016-12-02 16:09:24 +00:00
|
|
|
|
beq .8
|
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
>SYSCALL UnloadLib.A
|
2016-12-02 16:09:24 +00:00
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-03-30 16:11:31 +00:00
|
|
|
|
A2CharAX pha
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
2017-06-25 12:04:33 +00:00
|
|
|
|
OptionList >PSTR "Ll"
|
|
|
|
|
OptionVars .DA #bLL,#bLL
|
2016-12-02 16:09:24 +00:00
|
|
|
|
*--------------------------------------
|
2018-04-19 12:06:21 +00:00
|
|
|
|
MSG.USAGE .AS "Usage : FORMAT <BLOCKDEV> [VOLUME.NAME]\r\n"
|
|
|
|
|
.AS " -L : Low-Level Format\r\n"
|
|
|
|
|
.AZ " -1-9 : Catalog Size (Blocks)\r\n"
|
2018-04-11 15:35:51 +00:00
|
|
|
|
MSG.OK .AZ "[OK]\r\n"
|
|
|
|
|
MSG.ERR .AZ "[%h]\r\n"
|
|
|
|
|
MSG.INIT .AZ "Formatting %s (%D Blks),Volname:%s..."
|
2016-12-02 16:09:24 +00:00
|
|
|
|
*--------------------------------------
|
2018-04-11 15:35:51 +00:00
|
|
|
|
LIBBLKDEV .AZ "libblkdev.o"
|
|
|
|
|
BLANK .AZ "BLANK"
|
2016-12-02 16:09:24 +00:00
|
|
|
|
hLIBBLKDEV .BS 1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.DUMMY
|
|
|
|
|
.OR 0
|
|
|
|
|
DS.START
|
2017-10-03 15:33:30 +00:00
|
|
|
|
ArgIndex .BS 1
|
2017-10-04 06:16:39 +00:00
|
|
|
|
bLL .BS 1
|
2016-12-02 16:09:24 +00:00
|
|
|
|
VolName .BS 16
|
2017-03-30 16:11:31 +00:00
|
|
|
|
hDev .BS 5
|
2017-10-04 06:16:39 +00:00
|
|
|
|
SizeInBlocks .BS 2
|
2018-04-19 12:06:21 +00:00
|
|
|
|
CatSize .BS 1
|
|
|
|
|
CatOptions .BS 1
|
2017-10-04 06:16:39 +00:00
|
|
|
|
BlkCnt .BS 1
|
|
|
|
|
BlkParams.Ptr .BS 2
|
|
|
|
|
BlkParams.Num .BS 2
|
2017-03-31 15:24:42 +00:00
|
|
|
|
hBuf .BS 1
|
2017-10-09 05:51:32 +00:00
|
|
|
|
DS.END .ED
|
2016-12-02 16:09:24 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
MAN
|
2017-03-29 15:48:15 +00:00
|
|
|
|
SAVE /A2OSX.SRC/BIN/FORMAT.S
|
2016-12-02 16:09:24 +00:00
|
|
|
|
ASM
|