A2osX/ProDOS.FX/ProDOS.S.XDOS.F.txt

1032 lines
26 KiB
Plaintext
Raw Normal View History

2019-10-16 06:09:13 +00:00
NEW
AUTO 3,1
2019-10-28 06:32:12 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
* 'detree' deallocates blocks from tree files. it is assumed that the device has
2023-11-04 14:42:28 +00:00
* been pre-selected and the 'XDOS.GBuf' may be used.
2019-10-16 06:09:13 +00:00
*
* on entry:
* stortype = storage type in upper nibble, lower nibble is undisturbed.
* firstbl & firstbh = first block of file (index or data).
* deblock = 0
* dtree = ptr to 1st block with data to be deallocated at tree level.
* dsap = ptr to 1st block at sapling level.
* dseed = byte (0-511) position to be zeroed from (inclusive).
*
* on exit:
* stortype = modified result of storage type (if applicable).
* firstbl & h = modified if storage type changed.
* deblock = total number of blocks freed at all levels.
* dtree, dsap, deseed unchanged.
*
* to trim a tree to a seed file, both dtree and dsap must be zero.
* to go from tree to sapling, dtree alone must be zero.
2020-05-25 13:58:59 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
detree lda stortyp which kind of tree ?
cmp #$20 is it a 'seed' ?
bcc L4C46 if yes.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
cmp #$30 a sapling ?
bcc L4C51 if yes.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
cmp #$40 is it at least a 'tree' ?
bcc L4C59 branch if it is.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda #$0C block allocation error.
2023-11-04 14:42:28 +00:00
jsr GP.SYSDEATH P8 system death vector
2019-10-16 06:09:13 +00:00
2020-05-25 13:58:59 +00:00
* seedling file type - make sure first desirable block is the only
2019-10-16 06:09:13 +00:00
* block available in a seedling file.
L4C46 lda dsap
ora dtree
bne L4CC2
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jmp seedel0
2020-05-25 13:58:59 +00:00
* sapling file type - make sure first desirable block is within the range of
2019-10-16 06:09:13 +00:00
* blocks available in a sapling file
L4C51 lda dtree can't have any blocks in this range
bne L4CC2 if so then done
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jmp sapdel0 else go deallocate
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4C59 lda #$80
sta topdest for tree top start at end, work backwards.
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
L4C5E jsr drdfrst read specified first block into XDOS.GBuf.
2019-10-16 06:09:13 +00:00
bcs L4CC2 return errors.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldy topdest get current pointer to top indexes.
cpy dtree have enough sapling indexes been
beq L4CC3 deallocated? yes, now deallocate blocks
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldx #$07 buffer up to 8 sapling index block
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
L4C6D lda XDOS.GBuf,y addresses. fetch low block address
2019-10-16 06:09:13 +00:00
sta dealbufl,x and save it.
2023-11-04 14:42:28 +00:00
ora XDOS.GBuf+$100,y is it a real block that is allocated?
2019-10-16 06:09:13 +00:00
beq L4C81 branch if phantom block.
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
lda XDOS.GBuf+$100,y fetch high block address
2019-10-16 06:09:13 +00:00
sta dealbufh,x and save it.
dex decrement and test for dealc buf filled.
bmi L4C93 branch if 8 addresses fetched.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4C81 dey look for end of deallocation limit.
cpy dtree is this the last position on tree level?
bne L4C6D if not.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
iny
2020-05-13 17:00:37 +00:00
L4C8A stz dealbufl,x fill rest of dealc buffer with null addresses.
stz dealbufh,x
2019-10-16 06:09:13 +00:00
dex
bpl L4C8A
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4C93 dey decrement to prepare for next time.
sty topdest save index.
2020-05-25 13:58:59 +00:00
2019-10-16 06:09:13 +00:00
ldx #$07
2020-05-25 13:58:59 +00:00
2019-10-16 06:09:13 +00:00
L4C99 stx dtmpx save index to dealc buf.
lda dealbufl,x
2023-11-04 14:42:28 +00:00
sta ZP.BLKNUM
2019-10-16 06:09:13 +00:00
ora dealbufh,x finished ?
beq L4C5E branch if done with this level.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda dealbufh,x complete address with high byte,
2023-11-04 14:42:28 +00:00
sta ZP.BLKNUM+1
jsr XDOS.ReadGBuf read sapling level into XDOS.GBuf.
2019-10-16 06:09:13 +00:00
bcs L4CC2 return errors.
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
jsr XDOS.DeallocBlk0 go free all data indexes in this block
2019-10-16 06:09:13 +00:00
bcs L4CC2
2020-05-13 17:00:37 +00:00
2020-05-25 13:58:59 +00:00
jsr XDOS.WriteGBuf write the flipped index block
2019-10-16 06:09:13 +00:00
bcs L4CC2
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldx dtmpx restore index to dealc buff.
dex are there more to free?
bpl L4C99 branch if so.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
bmi L4C5E branch always to get up to 8 more
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4CC2 rts sapling block numbers.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4CC3 ldy dtree deallocate all sapling blocks greater
iny than specified block.
2023-11-05 15:26:06 +00:00
jsr XDOS.DeallocBlkY (master index in XDOS.GBuf)
2019-10-16 06:09:13 +00:00
bcs L4CC2 if errors.
2020-05-13 17:00:37 +00:00
2020-05-25 13:58:59 +00:00
jsr XDOS.WriteGBuf write updated master index back to disk.
2019-10-16 06:09:13 +00:00
bcs L4CC2
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldy dtree figure out if tree can become sapling.
beq L4CEB branch if it can.
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
lda XDOS.GBuf,y otherwise, continue with partial, deallocation of last sapling index.
ora XDOS.GBuf+$100,y is there such a sapling index block ?
2019-10-16 06:09:13 +00:00
beq L4CC2 all done if not.
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
lda XDOS.GBuf,y
ldx XDOS.GBuf+$100,y read in sapling level to be modified.
2020-05-25 13:58:59 +00:00
2023-11-04 14:42:28 +00:00
jsr XDOS.ReadGBufAX read highest sapling index into XDOS.GBuf.
2019-10-16 06:09:13 +00:00
bcc L4CF5
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
rts
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4CEB jsr shrink shrink tree to sapling
bcs L4CC2
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
sapdel0 jsr drdfrst read specified sapling level index
2023-11-04 14:42:28 +00:00
bcs L4CC2 into XDOS.GBuf. branch if error.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4CF5 ldy dsap pointer to last of desirable indexes.
iny inc to 1st undesirable.
beq L4D05 branch if all are desirable.
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
jsr XDOS.DeallocBlkY deallocate all indexes above specified.
2019-10-16 06:09:13 +00:00
bcs L4CC2
2020-05-13 17:00:37 +00:00
2020-05-25 13:58:59 +00:00
jsr XDOS.WriteGBuf write out the index block
2019-10-16 06:09:13 +00:00
bcs L4CC2
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4D05 ldy dsap prepare to clean up last data block.
beq L4D1F branch if possibility of making a seed.
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
L4D0A lda XDOS.GBuf,y fetch low order data block address.
ora XDOS.GBuf+$100,y is it a real block ?
2019-10-16 06:09:13 +00:00
beq L4CC2 if not, then done.
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
lda XDOS.GBuf,y
ldx XDOS.GBuf+$100,y
2020-05-25 13:58:59 +00:00
2023-11-04 14:42:28 +00:00
jsr XDOS.ReadGBufAX go read data block into XDOS.GBuf.
2019-10-16 06:09:13 +00:00
bcc L4D2E branch if good read
2020-05-13 17:00:37 +00:00
2020-05-25 13:58:59 +00:00
L4D1E rts or return error.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4D1F lda dtree are both tree and sap levels zero ?
bne L4D0A if not.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr shrink reduce this sap to a seed.
2020-05-25 13:58:59 +00:00
bcs L4D1E if error.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
seedel0 jsr drdfrst go read data block.
2020-05-25 13:58:59 +00:00
bcs L4D1E if error.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4D2E ldy dseed+1 check high byte for no deletion.
beq L4D39 branch if all of 2nd page to be deleted.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
dey if dseed > $200 then all were done.
2020-05-25 13:58:59 +00:00
bne L4D1E branch if that is the case.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldy dseed clear only bytes >= dseed.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4D39 lda #$00
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
L4D3B sta XDOS.GBuf+$100,y zero out unwanted data
2019-10-16 06:09:13 +00:00
iny
bne L4D3B
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldy dseed+1 is that all ?
bne L4D4F yes.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldy dseed
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
L4D49 sta XDOS.GBuf,y
2019-10-16 06:09:13 +00:00
iny
bne L4D49
2020-05-13 17:00:37 +00:00
2020-05-25 13:58:59 +00:00
L4D4F jmp XDOS.WriteGBuf update data block to disk.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4D52 rts return error status.
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
drdfrst lda firstbl read specified 1st block into XDOS.GBuf
2019-10-16 06:09:13 +00:00
ldx firstbh
2020-05-25 13:58:59 +00:00
jmp XDOS.ReadGBufAX go read it
2023-11-04 14:42:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
* beware that dealloc may bring in a new bitmap block and may destroy
* locations 46 and 47 which are used to point to the current index block.
2023-11-04 14:42:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
shrink ldx firstbh first deallocate top index block
phx
2019-10-16 06:09:13 +00:00
lda firstbl
pha save block address of this index block.
2020-08-28 10:47:41 +00:00
jsr XDOS.DeallocAX free it from the bitmap
2019-10-16 06:09:13 +00:00
pla
2023-11-04 14:42:28 +00:00
sta ZP.BLKNUM set master of sapling
2019-10-16 06:09:13 +00:00
pla index block address.
2023-11-04 14:42:28 +00:00
sta ZP.BLKNUM+1
2020-05-25 13:58:59 +00:00
bcs L4D1E report errors.
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
lda XDOS.GBuf get # of new 1st block from old index.
2019-10-16 06:09:13 +00:00
sta firstbl
2023-11-04 14:42:28 +00:00
lda XDOS.GBuf+$100
2019-10-16 06:09:13 +00:00
sta firstbh
ldy #$00
2023-11-05 15:26:06 +00:00
jsr XDOS.SwapGBUFY flip that one entry in old top index.
2019-10-16 06:09:13 +00:00
sec now change file type,
lda stortyp from tree to sapling,
sbc #$10 or from sapling to seed.
sta stortyp
2020-05-25 13:58:59 +00:00
jmp XDOS.WriteGBuf write the (deallocated) old top index.
2023-11-05 15:26:06 +00:00
*--------------------------------------
XDOS.DeallocBlk0
ldy #$00 start at beginning.
XDOS.DeallocBlkY
lda ZP.BLKNUM save disk address of XDOS.GBuf's data.
2019-10-16 06:09:13 +00:00
pha
2023-11-04 14:42:28 +00:00
lda ZP.BLKNUM+1
2019-10-16 06:09:13 +00:00
pha
2020-05-13 17:00:37 +00:00
.1 lda XDOS.GBuf,y get low address of block to deallocate.
2019-10-16 06:09:13 +00:00
cmp #$01 test for null block into carry.
2023-11-05 15:26:06 +00:00
ldx XDOS.GBuf+$100,y get remainder of block address.
bne .2 branch if not null.
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
bcc .3 was the low part null too ?
2020-05-13 17:00:37 +00:00
.2 phy
* sty saptr save current index.
jsr XDOS.DeallocAX free it up on volume bitmap.
ply
2023-11-05 15:26:06 +00:00
bcs XDOS.PopBlkNumRTS return any error.
2020-05-13 17:00:37 +00:00
* ldy saptr get index to sapling level index block.
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
jsr XDOS.SwapGBUFY
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
.3 iny next block address.
bne .1 if more to deallocate or test.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
clc no error.
2023-11-05 15:26:06 +00:00
*--------------------------------------
XDOS.PopBlkNumRTS
plx restore blocknm (16 bit)
stx ZP.BLKNUM+1 keeping A and C if error
plx
stx ZP.BLKNUM
2019-10-16 06:09:13 +00:00
rts
2023-11-05 15:26:06 +00:00
*--------------------------------------
XDOS.SwapGBUFY lda delflag swapping or zeroing ?
bne .1 skip if swapping.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
tax make x = 0.
2023-11-05 15:26:06 +00:00
beq .2 zero the index (always taken).
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
.1 ldx XDOS.GBuf+$100,y index high
lda XDOS.GBuf,y index low
.2 sta XDOS.GBuf+$100,y save index high
2019-10-16 06:09:13 +00:00
txa
2023-11-05 15:26:06 +00:00
sta XDOS.GBuf,y save index low
2019-10-16 06:09:13 +00:00
rts done.
*--------------------------------------
2019-10-16 06:09:13 +00:00
* MEMMGR memory manager
*
* allocate buffer in memory tables
*--------------------------------------
2019-10-16 06:09:13 +00:00
alcbuffr ldy #$04 index to user specified buffer.
2023-11-04 14:42:28 +00:00
alcbufr1 lda (ZP.A3L),y this buffer must be on a page boundary.
2019-10-16 06:09:13 +00:00
tax save for validation.
cmp #$08
bcc L4E1E cannot be lower than video !
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
cmp #$BC nor greater than $BB00
bcs L4E1E since it would wipe out globals...
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
sta ZP.DataPtr+1
2019-10-16 06:09:13 +00:00
dey
2023-11-04 14:42:28 +00:00
lda (ZP.A3L),y low address should be zero !
2023-11-05 15:26:06 +00:00
sta ZP.DataPtr
2019-10-16 06:09:13 +00:00
bne L4E1E error if not page boundary.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inx add 4 pages for 1k buffer.
inx
inx
inx
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4DED dex test for conflicts.
2023-11-04 14:42:28 +00:00
jsr XDOS.X2MemTablYA test for free buffer space
and GP.MEMTABL,y
2019-10-16 06:09:13 +00:00
bne L4E1E report memory conflict, if any.
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
cpx ZP.DataPtr+1 test all 4 pages.
2019-10-16 06:09:13 +00:00
bne L4DED
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inx add 4 pages again for allocation.
inx
inx
inx
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4DFE dex set proper bits to 1
2023-11-04 14:42:28 +00:00
jsr XDOS.MemTablEOR
2023-11-05 15:26:06 +00:00
cpx ZP.DataPtr+1 set all 4 pages
2019-10-16 06:09:13 +00:00
bne L4DFE
2020-05-13 17:00:37 +00:00
ldy XDOS.FCBPtr calculate buffer number
2023-11-04 14:42:28 +00:00
lda XDOS.FCBs,y
2019-10-16 06:09:13 +00:00
asl buffer number = (entnum) * 2.
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.BUFID,y save it in fcb.
2019-10-16 06:09:13 +00:00
tax use entnum * 2 as index to global
2023-11-05 15:26:06 +00:00
lda ZP.DataPtr+1 buffer addr tables. get addr already
sta GP.BUFTABL-1,x validated as good. store hi addr
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
clc (entnums start at 1, not 0)
rts
2019-10-28 06:32:12 +00:00
2020-05-21 12:55:49 +00:00
L4E1E lda #MLI.E.BADBUF buffer is in use or not legal
2019-10-16 06:09:13 +00:00
sec
rts
2020-09-18 15:06:12 +00:00
*--------------------------------------
relbuffr tax index into global buffer table.
lda GP.BUFTABL-2,x
sta XDOS.BufAddr
lda GP.BUFTABL-1,x
sta XDOS.BufAddr+1
2020-09-18 15:06:12 +00:00
beq relbuffr.8 branch if unallocated buffer space.
2020-05-13 17:00:37 +00:00
stz GP.BUFTABL-1,x take address out of buffer list.
stz GP.BUFTABL-2,x (x was set up by getbufadr)
2020-05-13 17:00:37 +00:00
freebuf ldx XDOS.BufAddr+1 get hi buffer address
2019-10-16 06:09:13 +00:00
inx add 4 pages to account for 1k space.
inx
inx
inx
2020-09-17 15:29:41 +00:00
2020-09-18 15:06:12 +00:00
.1 dex drop to next lower page.
2023-11-04 14:42:28 +00:00
jsr XDOS.MemTablEOR
cpx XDOS.BufAddr+1 all pages freed ?
2020-09-18 15:06:12 +00:00
bne .1 no.
2020-05-13 17:00:37 +00:00
2020-09-18 15:06:12 +00:00
relbuffr.8 clc no error.
2019-10-16 06:09:13 +00:00
rts
2019-11-10 18:28:06 +00:00
*--------------------------------------
valdbuf lda ZP.UserBuf+1 high address of user's buffer
2019-10-16 06:09:13 +00:00
cmp #$02 must be greater than page 2.
bcc L4E1E report bad buffer
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldx cbytes+1
lda cbytes get cbytes-1 value.
sbc #$01 (carry is set)
bcs L4E76
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
dex
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4E76 clc
adc ZP.UserBuf calculate end of request address.
2019-10-16 06:09:13 +00:00
txa do high address.
adc ZP.UserBuf+1 the final address
2019-10-16 06:09:13 +00:00
tax must be less than $BFnn (globals)
cpx #$BF
bcs L4E1E report bad buffer.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inx loop thru all affected pages.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
vldbuf1 dex check next lower page.
2023-11-04 14:42:28 +00:00
jsr XDOS.X2MemTabLYA
and GP.MEMTABL,y if 0 then no conflict.
2019-10-16 06:09:13 +00:00
bne L4E1E branch if conflict.
2020-05-13 17:00:37 +00:00
cpx ZP.UserBuf+1 was that the last (lowest) page ?
2019-10-16 06:09:13 +00:00
bne vldbuf1 if not.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
clc all pages ok.
rts
2019-11-23 15:24:55 +00:00
*--------------------------------------
2023-11-04 14:42:28 +00:00
* calculate memory allocation bit position.
* on entry: x = high address of buffer, low address assumed zero.
* on exit: acc = allocation bit mask, x = unchanged, y = pointer to memtabl byte
*--------------------------------------
XDOS.MemTablEOR jsr XDOS.X2MemTablYA
eor GP.MEMTABL,y
sta GP.MEMTABL,y
rts
*--------------------------------------
XDOS.X2MemTablYA
txa page address
and #$07 which page in any 2k set ?
tay use as index to determine
lda whichbit,y bit position representation.
pha save bit position mask for now.
txa page address.
lsr
lsr determine 2k set
lsr
tay return it in y.
pla restore bit mask. return bit position
rts in a & y, pointer to memtabl in x.
*--------------------------------------
2019-11-23 15:24:55 +00:00
XDOS.GetBuf ldy #$02 give user address of file buffer referenced by refnum.
lda XDOS.BufAddr
2023-11-04 14:42:28 +00:00
sta (ZP.A3L),y
2019-10-16 06:09:13 +00:00
iny
lda XDOS.BufAddr+1
2023-11-04 14:42:28 +00:00
sta (ZP.A3L),y
2019-10-16 06:09:13 +00:00
clc no errors possible
rts
2019-11-23 15:24:55 +00:00
*--------------------------------------
XDOS.SetBuf ldy #$03
2019-10-16 06:09:13 +00:00
jsr alcbufr1 allocate new buffer address over old one
bcs L4EC7 report any errors immediately
2019-11-23 15:24:55 +00:00
lda XDOS.BufAddr+1
sta ZP.UserBuf+1
lda XDOS.BufAddr
sta ZP.UserBuf
2019-10-16 06:09:13 +00:00
jsr freebuf free address space of old buffer
2019-11-23 15:24:55 +00:00
2019-10-16 06:09:13 +00:00
ldy #$00
ldx #$03
.1 lda (ZP.UserBuf),y move all 4 pages of the buffer to
2023-11-05 15:26:06 +00:00
sta (ZP.DataPtr),y new location.
2019-10-16 06:09:13 +00:00
iny
bne .1
2019-11-23 15:24:55 +00:00
2023-11-05 15:26:06 +00:00
inc ZP.DataPtr+1
inc ZP.UserBuf+1
2019-10-16 06:09:13 +00:00
dex
bpl .1
XDOS.SetBuf.CLCRTS
2019-10-16 06:09:13 +00:00
clc no errors
L4EC7 rts
2019-11-09 12:19:41 +00:00
*--------------------------------------
2019-11-10 18:28:06 +00:00
XDOS.IsValidChar
cmp #'0'
bcc XDOS.IsValidFirstChar
cmp #'9'+1
bcc XDOS.IsValidFirstChar.RTS
XDOS.IsValidFirstChar
.DO ENHFILENAME=1
cmp #'.'
2020-09-18 15:06:12 +00:00
beq XDOS.SetBuf.CLCRTS
2019-11-10 18:28:06 +00:00
cmp #'_'
2020-09-18 15:06:12 +00:00
beq XDOS.SetBuf.CLCRTS
2019-11-10 18:28:06 +00:00
.FIN
cmp #'A'
bcc XDOS.IsValidFirstChar.SEC
cmp #'Z'+1
.DO LOWERCASE=1
bcc XDOS.IsValidFirstChar.RTS
cmp #'a'
bcc XDOS.IsValidFirstChar.SEC
cmp #'z'+1
.FIN
XDOS.IsValidFirstChar.RTS
rts
2019-11-10 18:28:06 +00:00
XDOS.IsValidFirstChar.SEC
sec
rts
*--------------------------------------
2023-11-12 13:20:15 +00:00
* move 3 pages of dispatcher from LC Bank2 $D100 to $1000
2019-10-16 06:09:13 +00:00
* this move routine must be resident above $E000 at all times
2019-11-09 12:19:41 +00:00
*--------------------------------------
2023-11-12 13:20:15 +00:00
XDOS.CallDisp .DO M.SEL
lda IO.RRAMWRAMBNK2 read/write RAM bank 2
2023-11-04 14:42:28 +00:00
lda IO.RRAMWRAMBNK2
2019-11-06 20:48:15 +00:00
2023-11-04 14:42:28 +00:00
stz ZP.A1L
2019-11-06 20:48:15 +00:00
lda #$D1
2023-11-04 14:42:28 +00:00
sta ZP.A1L+1
2019-11-06 20:48:15 +00:00
2023-11-04 14:42:28 +00:00
stz ZP.A2L
2019-11-06 20:48:15 +00:00
lda #$10
2023-11-04 14:42:28 +00:00
sta ZP.A2L+1
2019-11-06 20:48:15 +00:00
2019-10-16 06:09:13 +00:00
ldy #$00
ldx #$03 3 pages to move.
2019-11-06 20:48:15 +00:00
2023-11-04 14:42:28 +00:00
.1 lda (ZP.A1L),y
sta (ZP.A2L),y
2019-11-06 20:48:15 +00:00
iny
bne .1
2023-11-04 14:42:28 +00:00
inc ZP.A1L+1 pointers to next page
inc ZP.A2L+1
2019-10-16 06:09:13 +00:00
dex move all pages needed
2019-11-06 20:48:15 +00:00
bne .1
2023-11-04 14:42:28 +00:00
lda IO.RRAMWRAMBNK1 read/write RAM bank 1
lda IO.RRAMWRAMBNK1 swap mli space back in
2019-11-06 20:48:15 +00:00
2023-11-04 14:42:28 +00:00
stz GP.MLIACTV MLI active flag
2023-11-04 14:42:28 +00:00
stz ROM.SOFTEV
2019-11-06 20:48:15 +00:00
lda #$10 point RESET to dispatch entry
2023-11-04 14:42:28 +00:00
sta ROM.SOFTEV+1
2019-10-16 06:09:13 +00:00
eor #$A5
2023-11-04 14:42:28 +00:00
sta ROM.PWREDUP power up byte
2019-11-06 20:48:15 +00:00
2023-11-05 15:26:06 +00:00
.DO AUXLC=1
jmp GP.SELJMP
.ELSE
2019-11-06 20:48:15 +00:00
jmp $1000
2023-11-05 15:26:06 +00:00
.FIN
2023-11-12 13:20:15 +00:00
.ELSE
inc ROM.PWREDUP
lda /ROM.RESETV-1
pha
lda #ROM.RESETV-1
pha
jmp IRQ.ToRomRTS
.FIN
2019-11-09 12:19:41 +00:00
*--------------------------------------
XDOS.SPREMAP ldx #$03 assume 3 parameters.
2023-11-04 14:42:28 +00:00
lda ZP.CMDNUM
sta .5
2019-11-09 12:19:41 +00:00
bne .1 taken if not status call
2019-10-16 06:09:13 +00:00
2023-11-05 15:26:06 +00:00
ldy #XDOS.SPStatusBuf set up memory for the status list buffer
2023-11-04 14:42:28 +00:00
sty ZP.BUFPTR fake up the prodos parameters
2023-11-05 15:26:06 +00:00
ldy /XDOS.SPStatusBuf
2023-11-04 14:42:28 +00:00
sty ZP.BUFPTR+1
stz ZP.BLKNUM set statcode = 0 for simple status call
2019-10-16 06:09:13 +00:00
2019-11-09 12:19:41 +00:00
.1 cmp #$03 format command ?
bne .2 no.
2019-10-16 06:09:13 +00:00
ldx #$01 format has only 1 parameter.
2019-11-09 12:19:41 +00:00
2020-04-13 17:04:02 +00:00
.2 stx XDOS.SPParams set # of parms.
2019-11-09 12:19:41 +00:00
2023-11-04 14:42:28 +00:00
lda ZP.UNITNUM DSSS0000
2019-10-16 06:09:13 +00:00
lsr turn unit number into an index
lsr
lsr
lsr
2019-11-09 12:19:41 +00:00
tax range = 1-15
2020-04-13 17:04:02 +00:00
lda XDOS.SPUnit-1,x get the smartport unit number and
sta XDOS.SPParams.U store into smartport parm list.
lda XDOS.SPVectLo-1,x
2023-11-04 14:42:28 +00:00
sta .4+1 copy smartport entry address
2020-04-13 17:04:02 +00:00
lda XDOS.SPVectHi-1,x
2023-11-04 14:42:28 +00:00
sta .4+2
2019-11-09 12:19:41 +00:00
2019-10-16 06:09:13 +00:00
ldx #$04 copy buffer pointer and block #
2019-11-09 12:19:41 +00:00
2023-11-04 14:42:28 +00:00
.3 lda ZP.BUFPTR-1,x from prodos parameters
sta XDOS.SPParams.B-1,x to smartport parameter block
2019-10-16 06:09:13 +00:00
dex
2019-11-09 12:19:41 +00:00
bne .3
2023-11-04 14:42:28 +00:00
.4 jsr $0000 smartport call (entry address gets modified)
.5 .HS 00 command #
2020-04-13 17:04:02 +00:00
.DA XDOS.SPParams
2019-11-09 12:19:41 +00:00
bcs .9
2019-10-16 06:09:13 +00:00
2023-11-04 14:42:28 +00:00
ldx .5 status call ?
2019-11-09 12:19:41 +00:00
bne .9 no...
2023-11-05 15:26:06 +00:00
ldx XDOS.SPStatusBuf+1 else get the block count
ldy XDOS.SPStatusBuf+2
lda XDOS.SPStatusBuf get the returned status.
2019-10-16 06:09:13 +00:00
bit #$10 is there a disk present ?
2019-11-09 12:19:41 +00:00
beq .8
and #$44 mask all but write allowed and write
2019-10-16 06:09:13 +00:00
eor #$40 protected bits. if allowed and not
2019-11-09 12:19:41 +00:00
* clc
beq .9 protected, exit with carry clear
2019-11-04 07:21:40 +00:00
2019-11-09 12:19:41 +00:00
lda #MLI.E.WRTPROT else return write protected error.
.HS 2C BIT ABS
.8 lda #MLI.E.OFFLINE return offline error.
sec
.9 rts
*--------------------------------------
2023-11-04 14:42:28 +00:00
XDOS.TBX bit IO.RRAMWRAMBNK1 Get RW access to LC
2023-11-05 15:26:06 +00:00
.DO AUXLC=1
2023-11-05 15:26:06 +00:00
stx .1+1
tsx
stx $100
ldx $101
txs
.1 ldx #$FF SELF MODIFIED
jsr .2
tsx
stx $101
ldx $100
txs
jmp GP.TBXEXIT
.ELSE
jsr .2
jmp IRQ.ToRomRTS
.FIN
.2 cpx #TBX.EnumNext
beq XDOS.TBX.EnumNext
bcc XDOS.TBX.EnumBlk
*--------------------------------------
XDOS.TBX.MemReset
ldx #$17
2023-11-04 14:42:28 +00:00
.1 stz GP.MEMTABL,x P8 memory bitmap
dex
bne .1
2023-11-04 14:42:28 +00:00
inc GP.MEMTABL+$17 protect global page
lda #$CF protect zero page, stack and page 1
2023-11-04 14:42:28 +00:00
sta GP.MEMTABL
rts
*--------------------------------------
XDOS.TBX.EnumBlk
jsr XDOS.ZPT.InitA
ldx XDOS.DH.EPB
lda (zpt)
cmp #$E0
bcc .2
ldy #$1F+3
ldx #3
.1 lda (zpt),y
sta XDOS.DH.EL,x
dey
dex
bpl .1
jsr XDOS.ZPT.Next skip header
ldx XDOS.DH.EPB
dex skip header
.2 stx cntent
XDOS.TBX.CheckFCnt
lda XDOS.DH.FileCnt
ora XDOS.DH.FileCnt+1
beq XDOS.TBX.SECRTS
2023-11-05 15:26:06 +00:00
clc
rts
*--------------------------------------
XDOS.TBX.EnumNext
sty sos
sta sos+1
jsr XDOS.TBX.CheckFCnt
bcs .9
.1 dec cntent
bmi XDOS.TBX.SECRTS
lda (zpt)
and #$0F
beq .7
sta (sos)
pha
jsr XDOS.ZPT.Unpack
ply
.2 lda (zpt),y
sta (sos),y
dey
bne .2
ldy #16 FileType
lda (zpt),y
pha
jsr XDOS.ZPT.Next
jsr XDOS.DH.DecFileCnt
pla
* clc
.9 rts
.7 jsr XDOS.ZPT.Next
bra .1
*--------------------------------------
XDOS.TBX.SECRTS sec
rts
*--------------------------------------
XDOS.ZPT.InitGBuf
2023-11-04 14:42:28 +00:00
lda /XDOS.GBuf
XDOS.ZPT.InitA sta zpt+1
lda #4
sta zpt
rts
*--------------------------------------
XDOS.ZPT.Unpack ldy #$1D MIN_VERSION
lda (zpt),y
bpl .6 no lowercase information
lda (zpt)
and #$0F
beq .6 length=0
tay
.2 cpy #8 CS if MIN_VERSION to use
phy
bcs .3
ldy #$1D MIN_VERSION
lda (zpt),y
ply
and whichbit,y
beq .5
bra .4
.3 ldy #$1C VERSION
lda (zpt),y
ply
and whichbit-8,y
beq .5
.4 lda (zpt),y
eor #$20 to lowercase
sta (zpt),y
.5 dey
bne .2
.6 rts
*--------------------------------------
XDOS.ZPT.Next lda XDOS.DH.EL
XDOS.ZPT.NextA clc
adc zpt
sta zpt
bcc .8
inc zpt+1
clc
.8 rts
*--------------------------------------
XDOS.DH.DecFileCnt
lda XDOS.DH.FileCnt
bne .1
dec XDOS.DH.FileCnt+1
.1 dec XDOS.DH.FileCnt
rts
*--------------------------------------
2019-10-16 06:09:13 +00:00
* data tables
2019-11-09 12:19:41 +00:00
*--------------------------------------
2020-07-10 13:59:56 +00:00
XDOS.CmdNums .HS D3D4D5D6 table of valid mli command numbers.
2019-11-23 15:24:55 +00:00
.HS 40410000
.HS 808182
.HS 65
.HS C0C1C2C3C4C5C6C7C8C9CACBCCCDCECF
2020-07-18 14:04:21 +00:00
.HS 00
2019-11-23 15:24:55 +00:00
.HS D0D1D2
2020-07-10 13:59:56 +00:00
XDOS.ParamCnt .HS 02020202 parameter counts for the calls
2019-11-23 15:24:55 +00:00
.HS 0201FFFF
.HS 030300
.HS 04
.HS 070102070A0201010303040401010202
2020-07-18 14:04:21 +00:00
.HS FF
2019-11-23 15:24:55 +00:00
.HS 020202
2020-05-28 21:13:52 +00:00
XDOS.CmdFlags .HS A0A1A2
.HS A384
.HS 050607
2019-11-28 22:06:22 +00:00
.HS 88494A4B
2020-05-28 21:13:52 +00:00
.HS 2C2D
.HS 4E4F
2019-11-28 22:06:22 +00:00
.HS 50515253
2020-07-17 06:04:08 +00:00
.HS 94959697
2019-11-28 22:06:22 +00:00
2019-11-10 18:28:06 +00:00
cmdtable .DA XDOS.Create
.DA XDOS.Destroy
.DA XDOS.Rename
.DA XDOS.SetFileInfo
2019-11-28 22:06:22 +00:00
2019-11-10 18:28:06 +00:00
.DA XDOS.GetFileInfo
.DA XDOS.Online
.DA XDOS.SetPrefix
.DA XDOS.GetPrefix
2019-11-28 22:06:22 +00:00
2019-11-10 18:28:06 +00:00
.DA XDOS.Open
2019-11-23 15:24:55 +00:00
.DA XDOS.NewLine
2019-11-20 07:04:00 +00:00
.DA XDOS.Read
.DA XDOS.Write
2019-11-28 22:06:22 +00:00
2019-11-10 18:28:06 +00:00
.DA XDOS.Close
.DA XDOS.Flush
2019-11-23 15:24:55 +00:00
.DA XDOS.SetMark
.DA XDOS.GetMark
2019-11-28 22:06:22 +00:00
2019-11-23 15:24:55 +00:00
.DA XDOS.SetEOF
.DA XDOS.GetEOF
.DA XDOS.SetBuf
.DA XDOS.GetBuf
2019-11-28 22:06:22 +00:00
2019-11-23 15:24:55 +00:00
.DA XDOS.SetFileInfoEx
.DA XDOS.GetFileInfoEx
2020-07-18 14:04:21 +00:00
.DA XDOS.ACL
2019-10-16 06:09:13 +00:00
dinctbl .HS 0100000200 table to increment directory usage/eof counts
2019-12-13 10:10:08 +00:00
.DO LOWERCASE=1
XDOS.VolHdrDef .HS C3270D
XDOS.VolHdrDef.Cnt .EQ *-XDOS.VolHdrDef
.ELSE
2019-10-16 06:09:13 +00:00
pass .HS 75
xdosver .HS 00
compat .HS 00
.HS C3270D000000
2019-11-23 15:24:55 +00:00
.FIN
2019-10-16 06:09:13 +00:00
rootstuf .HS 0F02000400000800
whichbit .HS 8040201008040201
ofcbtbl .HS 0C0D1819151617
inftabl .HS 1E101F2080939421
.HS 22232418191A1B
2020-09-18 15:06:12 +00:00
deathmsg .AS -"SYS ERR-$0"
2019-11-11 14:21:06 +00:00
deathmsg.LEN .EQ *-deathmsg
2019-11-09 12:19:41 +00:00
*--------------------------------------
2019-11-04 07:21:40 +00:00
XDOS.DATA .DUMMY
2020-05-28 21:13:52 +00:00
*--------------------------------------
XDOS.OH.Blk .HS 0000
XDOS.OH.EIB .HS 00
XDOS.OH.EL .HS 00
2020-05-28 21:13:52 +00:00
*--------------------------------------
2019-12-06 07:15:51 +00:00
.DO ACL=1
XDOS.DH.ACL .BS 8 5700 UID GID MOD
2019-12-06 07:15:51 +00:00
.FIN
XDOS.DH.CTime .HS 00000000 directory creation time
.HS 0000 Version/MVersion
XDOS.DH.Access .HS 00 attributes (protect bit, etc.)
XDOS.DH.EL .HS 00 length of each entry in this directory
XDOS.DH.EPB .HS 00 maximum number of entries per block
XDOS.DH.FileCnt .HS 0000 current # of files in this directory
XDOS.DH.BMPtr .HS 0000 address of first allocation bitmap
XDOS.DH.BlkCnt .HS 0000 total number of blocks on this unit
*--------------------------------------
XDOS.DE.DevID .HS 00 device number of this directory entry
XDOS.DE.DirHBlk .HS 0000 address of <sub> directory header
XDOS.DE.DirEBlk .HS 0000 address of block which contains entry
XDOS.DE.DirEIB .HS 00 entry number within block
*--------------------------------------
XDOS.DE.Filename .BS 16
XDOS.DE.Type .HS 00
XDOS.DE.KeyPtr .HS 0000 first block of file
XDOS.DE.BlkUsed .HS 0000 # of blocks allocated to this file
XDOS.DE.EOF .HS 000000 current end of file marker
XDOS.DE.CTime .HS 00000000 file creation time
XDOS.DE.Version .HS 00 version that created this file
XDOS.DE.MVersion .HS 00
XDOS.DE.Access .HS 00 attributes (protect, r/w, enable, etc.)
XDOS.DE.AuxType .HS 0000 user auxilliary identification
XDOS.DE.MTime .HS 00000000 file's last modification time
XDOS.DE.BlkPtr .HS 0000 file directory header block address
2020-05-23 18:45:32 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
scrtch .HS 00000000 scratch area for allocation address conversion.
oldeof .HS 000000 temp used in r/w
oldmark .HS 000000
2023-11-04 14:42:28 +00:00
*xvcbptr .HS 00 used in 'cmpvcb' as a temp
*XDOS.VCBPtr .HS 00
XDOS.FCBPtr .HS 00
2019-10-16 06:09:13 +00:00
fcbflg .HS 00
reql .HS 00
2019-10-16 06:09:13 +00:00
reqh .HS 00
levels .HS 00
totent .HS 00
XDOS.FileCnt .HS 0000
2019-10-16 06:09:13 +00:00
cntent .HS 00
nofree .HS 00
2023-11-04 14:42:28 +00:00
*bmcnt .HS 00
*saptr .HS 00
2019-10-16 06:09:13 +00:00
pathcnt .HS 00
*p_dev .HS 00
2019-10-16 06:09:13 +00:00
p_blok .HS 0000
2023-11-04 14:42:28 +00:00
*bmptr .HS 00
*basval .HS 00
2019-10-16 06:09:13 +00:00
half .HS 00
* bitmap info tables
XDOS.BM.Status .HS 00
XDOS.BM.DevID .HS 00
XDOS.BM.BlkNum .HS 0000
XDOS.BM.Idx .HS 00
2019-10-16 06:09:13 +00:00
tposll .HS 00
tposlh .HS 00
tposhi .HS 00
2019-10-16 06:09:13 +00:00
rwreql .HS 00
rwreqh .HS 00
2019-10-16 06:09:13 +00:00
nlchar .HS 00
nlmask .HS 00
2019-10-16 06:09:13 +00:00
ioaccess .HS 00 has a call been made to disk device handler ?
cmdtemp .HS 00
bkbitflg .HS 00 used to set or clear backup bit
* xdos temporary variables
namcnt .HS 00
rnptr .HS 00
namptr .HS 00
2023-11-04 14:42:28 +00:00
*vnptr .HS 00
2019-10-16 06:09:13 +00:00
prfxflg .HS 00
cferr .HS 00
* deallocation temporary variables
firstbl .HS 00
firstbh .HS 00
stortyp .HS 00
*--------------------------------------
2019-10-16 06:09:13 +00:00
deblock .HS 0000
dtree .HS 00
dsap .HS 00
dseed .HS 0000
*--------------------------------------
2019-10-16 06:09:13 +00:00
topdest .HS 00
dtmpx .HS 00
loklst .EQ * look list of recognized device numbers
dealbufl .HS 0000000000000000
dealbufh .HS 0000000000000000
cbytes .HS 0000
.HS 00 cbytes+2 must = 0
XDOS.BufAddr .HS 0000
2019-10-16 06:09:13 +00:00
delflag .HS 00 used by 'detree' to know if called from delete (destroy).
2020-05-23 18:45:32 +00:00
*--------------------------------------
2020-04-23 15:36:51 +00:00
* variables used by SP remap & XRW Disk ][ to store last track used
2020-05-23 18:45:32 +00:00
*--------------------------------------
2020-05-04 20:46:21 +00:00
XRW.D2Trk .EQ *
2020-04-13 17:04:02 +00:00
XDOS.SPUnit .HS 00000000000000 14+1 for S0D2
.HS 00
2019-11-04 07:21:40 +00:00
.HS 00000000000000
2019-11-09 12:19:41 +00:00
2020-05-08 19:02:27 +00:00
XRW.D2VolNum .EQ *
2020-04-13 17:04:02 +00:00
XDOS.SPVectLo .HS 00000000000000 storage for low byte of smartport entry.
2019-11-09 12:19:41 +00:00
.HS 00
2019-11-04 07:21:40 +00:00
.HS 00000000000000
2020-08-26 10:29:04 +00:00
XRW.D2SeekTime .EQ *
2020-04-13 17:04:02 +00:00
XDOS.SPVectHi .HS 00000000000000 storage for high byte of smartport entry.
2019-11-09 12:19:41 +00:00
.HS 00
.HS 00000000000000
2023-11-05 15:26:06 +00:00
*--------------------------------------
XDOS.SPParams .HS 00 # of parms
XDOS.SPParams.U .HS 00 unit number
XDOS.SPParams.B .HS 0000 data buffer
.HS 000000 block number (3 bytes)
2023-11-05 15:26:06 +00:00
XDOS.SPStatusBuf .HS 00000000
*--------------------------------------
2019-11-09 12:19:41 +00:00
.LIST ON
2019-11-04 07:21:40 +00:00
XDOS.DATA.LEN .EQ *-XDOS.DATA
2023-11-05 15:26:06 +00:00
XDOS.FREE .EQ $FEFD-*
2019-11-09 12:19:41 +00:00
.LIST OFF
2023-11-05 15:26:06 +00:00
.BS XDOS.FREE
2019-11-04 07:21:40 +00:00
.ED
*--------------------------------------
2023-11-04 14:42:28 +00:00
XDOS.CortDisp .EQ $FEFD
2023-11-05 15:26:06 +00:00
XDOS.CortFlag .EQ $FEFF cortland flag. 1 = Cortland system (must stay within page boundary)
2023-11-04 14:42:28 +00:00
*--------------------------------------
.EP
*--------------------------------------
XDOS.LEN .EQ *-XDOS.START
2019-10-16 06:09:13 +00:00
*--------------------------------------
MAN
SAVE usr/src/prodos.fx/prodos.s.xdos.f
LOAD usr/src/prodos.fx/prodos.s
2019-10-16 06:09:13 +00:00
ASM