mirror of
https://github.com/A2osX/A2osX.git
synced 2024-08-14 13:29:02 +00:00
332 lines
5.8 KiB
Plaintext
332 lines
5.8 KiB
Plaintext
PR#3
|
||
PREFIX /A2OSX.BUILD
|
||
NEW
|
||
INC 1
|
||
AUTO 6
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF /A2OSX.BUILD/BIN/FORMAT
|
||
*--------------------------------------
|
||
.INB /A2OSX.BUILD/INC/MACROS.I
|
||
.INB /A2OSX.BUILD/INC/A2OSX.I
|
||
.INB /A2OSX.BUILD/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 CS
|
||
.DA DS.END-DS.START DS
|
||
.DA #16 SS
|
||
.DA #4 ZP
|
||
.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
|
||
beq .99
|
||
|
||
.1 >INC.G ArgIndex
|
||
|
||
>SYSCALL GetArg.A
|
||
bcs .7
|
||
|
||
>STYA ZPPtr1
|
||
|
||
lda (ZPPtr1)
|
||
cmp #'-'
|
||
bne .4
|
||
|
||
ldy #1
|
||
lda (ZPPtr1),y
|
||
beq .99
|
||
|
||
ldx OptionList
|
||
|
||
.2 cmp OptionList,x
|
||
beq .3
|
||
dex
|
||
bne .2
|
||
|
||
.99 >LDYA L.MSG.USAGE
|
||
>SYSCALL PrintF.YA
|
||
lda #K.E.SYN
|
||
sec
|
||
rts
|
||
|
||
.3 ldy OptionVars-1,x
|
||
lda #$80
|
||
sta (pData),y
|
||
bra .1
|
||
|
||
.4 >LDA.G hDev
|
||
bne .5 Already have a dev name...go get VolName
|
||
|
||
>LDYA ZPPtr1
|
||
>SYSCALL GetDevByName.YA
|
||
bcs .99
|
||
txa
|
||
>STA.G hDev
|
||
bra .1
|
||
|
||
.5 ldy #$ff
|
||
|
||
.6 iny
|
||
lda (ZPPtr1),y
|
||
beq .61
|
||
|
||
cpy #15
|
||
beq .99 VolName too long
|
||
|
||
.61 >PUSHW ZPPtr1
|
||
>PUSHEA.G VolName
|
||
>SYSCALL StrCpy
|
||
jmp .1 success, scan for any other args
|
||
|
||
.7 >LDA.G VolName
|
||
bne .8 Volume name ok
|
||
|
||
ldx #$ff
|
||
ldy #VolName-1
|
||
|
||
.71 inx
|
||
iny
|
||
lda BLANK,x
|
||
sta (pData),y
|
||
bne .71
|
||
|
||
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 >LDYA L.LIBBLKDEV
|
||
>SYSCALL LoadLib.YA
|
||
sta hLIBBLKDEV
|
||
|
||
* lda (pPs)
|
||
* ora #S.PS.F.EVENT Now accept events
|
||
* sta (pPs)
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN 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.BuildCat >LDA.G hDev
|
||
>SYSCALL GetDevStatus.A
|
||
|
||
bcs .99
|
||
>STYA ZPPtr1
|
||
ldy #S.DSTAT.SIZE
|
||
lda (ZPPtr1),y
|
||
>STA.G SizeInBlocks
|
||
ldy #S.DSTAT.SIZE+1
|
||
lda (ZPPtr1),y
|
||
>STA.G SizeInBlocks+1
|
||
|
||
>LDA.G hDev
|
||
>SYSCALL GetDevByID.A
|
||
bcs .99
|
||
|
||
pha
|
||
tya
|
||
adc #S.DEV.NAME
|
||
sta ZPPtr2
|
||
pla
|
||
adc /S.DEV.NAME
|
||
sta ZPPtr2+1
|
||
|
||
>PUSHEA.G VolName
|
||
>PUSHW.G SizeInBlocks
|
||
>PUSHW ZPPtr2
|
||
|
||
>LDYA L.MSG.INIT
|
||
>SYSCALL PrintF.YA
|
||
.99 bcs .9
|
||
|
||
>PUSHW.G SizeInBlocks
|
||
>LIBCALL hLIBBLKDEV,LIBBLKDEV.GetProDOSCatSize
|
||
bcs .9
|
||
|
||
phy
|
||
pha
|
||
txa
|
||
>STA.G BlkCnt
|
||
pla
|
||
ply
|
||
|
||
>SYSCALL GetMem0.YA BufferSize
|
||
bcs .9
|
||
|
||
phx
|
||
>STYA.G BlkParams.Ptr
|
||
pla
|
||
>STA.G hBuf
|
||
|
||
>PUSHW.G SizeInBlocks
|
||
>PUSHEA.G VolName
|
||
>PUSHW.G BlkParams.Ptr
|
||
>LIBCALL hLIBBLKDEV,LIBBLKDEV.BuildProDOSCat
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.RUN.WriteCat >LDA.G hDev
|
||
>SYSCALL GetDevByID.A
|
||
bcs .9
|
||
>STYA pDev
|
||
|
||
>LEA.G BlkParams.Ptr
|
||
ldx #DEVMGR.WRITEBLOCK
|
||
|
||
jsr pDevJmp
|
||
bcs .9
|
||
|
||
lda #'.'
|
||
>SYSCALL PutChar.A
|
||
|
||
>LDA.G BlkParams.Ptr+1
|
||
* clc
|
||
adc #2
|
||
sta (pData),y
|
||
|
||
>INC.G BlkParams.Num
|
||
|
||
* >SLEEP
|
||
|
||
>DEC.G BlkCnt
|
||
bne CS.RUN.WriteCat
|
||
.9 rts
|
||
*--------------------------------------
|
||
CS.DOEVENT sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT >LDA.G hBuf
|
||
beq .1
|
||
>SYSCALL FreeMem.A
|
||
|
||
.1 lda hLIBBLKDEV
|
||
beq .8
|
||
|
||
>SYSCALL UnloadLib.A
|
||
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
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
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
OptionList >PSTR "Ll"
|
||
OptionVars .DA #bLL,#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"
|
||
MSG.INIT >CSTR "Formatting %s (%D Blks),Volname:%s..."
|
||
*--------------------------------------
|
||
LIBBLKDEV >CSTR "libblkdev.o"
|
||
BLANK >CSTR "BLANK"
|
||
hLIBBLKDEV .BS 1
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
ArgIndex .BS 1
|
||
bLL .BS 1
|
||
VolName .BS 16
|
||
hDev .BS 5
|
||
SizeInBlocks .BS 2
|
||
BlkCnt .BS 1
|
||
BlkParams.Ptr .BS 2
|
||
BlkParams.Num .BS 2
|
||
hBuf .BS 1
|
||
DS.END .ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE /A2OSX.SRC/BIN/FORMAT.S
|
||
ASM
|