A2osX/BIN/FORMAT.S.txt

353 lines
6.0 KiB
Plaintext
Raw Normal View History

NEW
2018-11-17 17:17:13 +00:00
PREFIX
2017-12-22 21:24:30 +00:00
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
2018-07-23 15:28:42 +00:00
.TF BIN/FORMAT
*--------------------------------------
2018-07-23 15:28:42 +00:00
.INB INC/MACROS.I
.INB INC/A2OSX.I
2018-12-18 14:37:07 +00:00
.INB INC/KERNEL.I
2018-07-23 15:28:42 +00:00
.INB INC/LIBBLKDEV.I
*--------------------------------------
2018-12-18 14:37:07 +00:00
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
ZPPtr2 .BS 2
2019-02-13 06:50:10 +00:00
ZPPtrFD .BS 2
ZPPtrDevName .BS 2
2018-12-18 14:37:07 +00:00
ZS.END
.ED
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
2018-12-18 14:37:07 +00:00
.DA #0 S.PS.F.EVENT
.DA #0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #32 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
.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
L.MSG.INIT .DA MSG.INIT
L.MSG.OK .DA MSG.OK
L.MSG.ERR .DA MSG.ERR
.DA 0
*--------------------------------------
CS.INIT ldy #S.PS.ARGC
lda (pPs),y
2018-11-23 16:20:19 +00:00
beq .90
2018-11-05 16:28:40 +00:00
.1 >INC.G ArgIndex
2018-10-16 15:48:03 +00:00
>SYSCALL ArgV
bcc .11
jmp .8
.11 >STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
ldy #1
lda (ZPPtr1),y
beq .90
cmp #'0'
bcc .20
cmp #'9'+1
bcs .20
and #$0F
>STA.G CatSize
bra .1
.20 ldx OptionList
.2 cmp OptionList,x
beq .3
dex
bne .2
.90 bra .99
.3 ldy OptionVars-1,x
lda #$80
sta (pData),y
bra .1
2018-12-18 14:37:07 +00:00
.4 >LDA.G hDevID
2018-08-11 10:57:57 +00:00
bne .5 Already have a dev...go get VolName
>LDYA ZPPtr1
2018-08-11 10:57:57 +00:00
>SYSCALL GetDevByName
bcs .99
2019-02-13 06:50:10 +00:00
>STYA ZPPtrFD
txa
2018-12-18 14:37:07 +00:00
>STA.G hDevID
2019-02-13 06:50:10 +00:00
>LDYA ZPPtr1
>STYA ZPPtrDevName
bra .1
.5 ldy #$ff
.6 iny
2017-10-04 15:12:03 +00:00
lda (ZPPtr1),y
beq .61
2017-10-04 15:12:03 +00:00
cpy #15
beq .99 VolName too long
2017-10-04 15:12:03 +00:00
.61 >PUSHW ZPPtr1
2018-07-20 14:10:10 +00:00
>LEA.G VolName
2017-10-04 15:12:03 +00:00
>SYSCALL StrCpy
jmp .1 success, scan for any other args
.8 >LDYA L.LIBBLKDEV
2018-07-19 15:33:55 +00:00
>SYSCALL LoadLib
2018-11-05 16:28:40 +00:00
bcs .9
sta hLIBBLKDEV
clc
2018-11-05 16:28:40 +00:00
.9 rts
2018-08-22 15:23:27 +00:00
.99 >PUSHBI 0
>LDYA L.MSG.USAGE
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2018-10-21 20:54:07 +00:00
lda #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
2018-08-22 15:23:27 +00:00
>SYSCALL puts
lda #0
sec
rts
.9 pha
>PUSHA
2018-08-22 15:23:27 +00:00
>PUSHBI 1
>LDYA L.MSG.ERR
2018-06-21 15:12:10 +00:00
>SYSCALL printf
pla
sec
rts
*--------------------------------------
CS.RUN.InitCat >LDA.G CatSize
bne .1
lda #4
sta (pData),y
.1 >LDA.G VolName
bne .8 Volume name ok
ldx #$ff
ldy #VolName-1
.2 inx
iny
lda BLANK,x
sta (pData),y
bne .2
lda A2osX.TIMER16
jsr A2CharAX
sta (pData),y
iny
txa
sta (pData),y
iny
lda A2osX.TIMER16+1
jsr A2CharAX
sta (pData),y
iny
txa
sta (pData),y
iny
lda A2osX.RANDOM16
jsr A2CharAX
sta (pData),y
iny
txa
sta (pData),y
iny
lda A2osX.RANDOM16+1
jsr A2CharAX
sta (pData),y
iny
txa
sta (pData),y
iny
lda #0
sta (pData),y
.8 clc
rts
*--------------------------------------
2018-07-20 14:10:10 +00:00
CS.RUN.BuildCat >PUSHEA.G DIB
2019-02-13 06:50:10 +00:00
>LDA.G hDevID
2018-12-18 14:37:07 +00:00
2018-07-18 15:30:42 +00:00
>SYSCALL GetDevStatus
bcs .99
2018-12-18 14:37:07 +00:00
>PUSHEA.G VolName
2018-07-20 14:10:10 +00:00
>PUSHW.G DIB+S.DIB.SIZE
2018-12-18 14:37:07 +00:00
2019-02-13 06:50:10 +00:00
>PUSHW ZPPtrDevName
2018-12-18 14:37:07 +00:00
2018-08-22 15:23:27 +00:00
>PUSHBI 6
>LDYA L.MSG.INIT
2018-06-21 15:12:10 +00:00
>SYSCALL printf
.99 bcs .9
2017-10-04 15:12:03 +00:00
jsr .7
2017-10-04 15:12:03 +00:00
>LIBCALL hLIBBLKDEV,LIBBLKDEV.GetProDOSCatSize
bcs .9
2017-10-04 15:12:03 +00:00
phy
pha
2017-10-04 15:12:03 +00:00
txa
>STA.G BlkCnt
pla
ply
2018-07-18 15:30:42 +00:00
>SYSCALL GetMem0 BufferSize
bcs .9
2017-10-04 15:12:03 +00:00
phx
2018-07-20 14:10:10 +00:00
>STYA.G IOCTL+S.IOCTL.BUFPTR
2017-10-04 15:12:03 +00:00
pla
>STA.G hBuf
jsr .7
>PUSHEA.G VolName
2018-07-20 14:10:10 +00:00
>PUSHW.G IOCTL+S.IOCTL.BUFPTR
>LIBCALL hLIBBLKDEV,LIBBLKDEV.BuildProDOSCat
.9 rts
2018-07-20 14:10:10 +00:00
.7 >PUSHW.G DIB+S.DIB.SIZE
>PUSHB.G CatSize
>PUSHB.G CatOptions
rts
*--------------------------------------
2018-07-20 14:10:10 +00:00
CS.RUN.WriteCat >PUSHEA.G IOCTL
>PUSHBI IOCTL.WRITEBLOCK
2019-02-13 06:50:10 +00:00
>LDA.G hDevID
2018-12-18 14:37:07 +00:00
>SYSCALL IOCTL
bcs .9
2017-10-04 15:12:03 +00:00
lda #'.'
2018-07-18 15:30:42 +00:00
>SYSCALL PutChar
2017-10-04 15:12:03 +00:00
2018-07-20 14:10:10 +00:00
>LDA.G IOCTL+S.IOCTL.BUFPTR+1
inc
inc
sta (pData),y
2018-07-20 14:10:10 +00:00
>INC.G IOCTL+S.IOCTL.BLKNUM
2017-10-04 15:12:03 +00:00
>SLEEP
2017-10-04 15:12:03 +00:00
>DEC.G BlkCnt
2017-10-04 15:12:03 +00:00
bne CS.RUN.WriteCat
.9 rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT >LDA.G hBuf
beq .1
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
.1 lda hLIBBLKDEV
beq .8
2018-07-20 14:10:10 +00:00
>SYSCALL UnloadLib
.8 clc
rts
*--------------------------------------
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
*--------------------------------------
CS.END
*--------------------------------------
OptionList >PSTR "Ll"
OptionVars .DA #bLL,#bLL
*--------------------------------------
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-08-22 15:23:27 +00:00
MSG.OK .AZ "[OK]"
MSG.ERR .AZ "[%h]\r\n"
MSG.INIT .AZ "Formatting %s (%D Blks),Volname:%s..."
*--------------------------------------
2018-11-05 16:28:40 +00:00
LIBBLKDEV .AZ "libblkdev"
BLANK .AZ "BLANK"
hLIBBLKDEV .BS 1
*--------------------------------------
.DUMMY
.OR 0
DS.START
ArgIndex .BS 1
bLL .BS 1
VolName .BS 16
2018-12-18 14:37:07 +00:00
hDevID .BS 1
CatSize .BS 1
CatOptions .BS 1
BlkCnt .BS 1
2018-07-20 14:10:10 +00:00
IOCTL .BS S.IOCTL
hBuf .BS 1
2018-07-20 14:10:10 +00:00
DIB .BS S.DIB
DS.END .ED
*--------------------------------------
MAN
2018-12-03 06:59:30 +00:00
SAVE USR/SRC/BIN/FORMAT.S
ASM