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

1007 lines
27 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
*--------------------------------------
2020-07-18 14:04:21 +00:00
XDOS.Destroy jsr XDOS.FindFile look for file to be destroyed.
2019-10-16 06:09:13 +00:00
bcs L4B66 if error.
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
jsr tstopen is it open ?
lda totent
bne L4B64 error if open.
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
stz reql force proper free count in volume.
stz reqh (no disk access occurs if already
jsr tstfrblk proper)
bcc L4B39 no errors.
2019-11-10 18:28:06 +00:00
cmp #MLI.E.VOLFULL was error a full disk ?
2019-10-16 06:09:13 +00:00
bne L4B66 no, report error.
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
L4B39 lda d_attr make sure ok to destroy file.
2020-08-28 10:47:41 +00:00
* and #$80
* bne L4B45 branch if ok to destroy.
bmi L4B45 branch if ok to destroy.
2020-05-25 13:58:59 +00:00
2019-10-16 06:09:13 +00:00
lda #MLI.E.LOCKED access error
jsr GP.P8errv
L4B45 lda devnum last device used.
jsr twrprot1 test for write protected hardware
bcs L4B66 before going thru deallocation.
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
lda d_frst 'detree' needs first block address
sta firstbl
lda d_frst+1
sta firstbh
lda d_stor find out which storage type.
and #$F0 strip off name length.
cmp #$40 is it a seed, sapling or tree ?
bcc L4B68 branch if it is.
bra L4BCF otherwise, test for directory destroy.
2019-11-10 18:28:06 +00:00
L4B64 lda #MLI.E.OPEN file busy error.
2019-10-16 06:09:13 +00:00
L4B66 sec can't be destroyed
rts
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
L4B68 sta stortyp destroy a tree file. save storage type.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldx #$05
2019-11-10 18:28:06 +00:00
2020-05-13 17:00:37 +00:00
* lda #$00 set 'detree' input variables, must be
L4B6F stz stortyp,x in order: deblock, dtree, dsap, dseed.
2019-10-16 06:09:13 +00:00
dex
bne L4B6F loop until all zero'd.
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
lda #$02 this avoids an extra file i/o and pre-
sta dseed+1 vents destruction of any deleted data.
inc delflag don't allow detree to zero index blocks.
jsr detree make trees and saplings into seeds.
dec delflag reset flag.
bcs L4B93 (de-evolution)
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
L4B85 ldx firstbh
lda firstbl now deallocate seed.
2020-08-28 10:47:41 +00:00
jsr XDOS.DeallocAX
2019-10-16 06:09:13 +00:00
bcs L4B93
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
jsr upbmap
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
L4B93 pha save possible error code.
lda #$00 update directory to free entry space.
sta d_stor
cmp h_fcnt file entry wrap ?
bne L4BA1 branch if no carry adjustment.
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
dec h_fcnt+1 take carry from hi byte of file entries.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4BA1 dec h_fcnt mark header with one less file.
jsr dvcbrev go update block count in vcb (ignore
jsr drevise error, if any) and update dir last.
tax save possible new error code,
pla restore possible old error code.
bcc L4BAF branch if last call succeeded.
txa last call failed, use it's error code.
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
L4BAF cmp #$01 adjust carry accordingly
rts
2019-11-10 18:28:06 +00:00
2020-05-23 18:45:32 +00:00
dvcbrev ldx vcbptr update block free count in vcb. point to vcb of correct device.
2019-10-16 06:09:13 +00:00
lda deblock get # of blocks recently freed.
2020-05-23 18:45:32 +00:00
adc VCBs+VCB.FBLK,x
sta VCBs+VCB.FBLK,x update current free block count.
2019-10-16 06:09:13 +00:00
lda deblock+1
2020-05-23 18:45:32 +00:00
adc VCBs+VCB.FBLK+1,x
sta VCBs+VCB.FBLK+1,x
2020-05-13 17:00:37 +00:00
2020-05-23 18:45:32 +00:00
stz VCBs+VCB.BMAPIDX,x force re-scan from 1st bitmap
2020-05-25 13:58:59 +00:00
* lda #0 ?????
2019-10-16 06:09:13 +00:00
rts
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
L4BCD bcc L4B85 branch widened (always taken)
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
L4BCF cmp #$D0 is this a directory file ?
bne L4C1B no, file incompatible.
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
jsr fndbmap make sure a buffer available for bitmap
bcs L4C1A if error.
2019-11-10 18:28:06 +00:00
2020-07-16 14:53:35 +00:00
jsr XDOS.ReadGBuf_d_frst read 1st block of directory into gbuf
2019-10-16 06:09:13 +00:00
bcs L4C1A
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
lda gbuf+37 do any files exist in this directory ?
2020-05-25 13:58:59 +00:00
ora gbuf+38
bne L4C1Abis if so, access error.
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
L4BF6 sta gbuf+4 make it an invalid subdirectory
2020-08-27 15:34:55 +00:00
.DO LOWERCASE=1
jsr XDOS.WriteGBufDir
.ELSE
2020-05-25 13:58:59 +00:00
jsr XDOS.WriteGBuf
2020-08-27 15:34:55 +00:00
.FIN
2019-10-16 06:09:13 +00:00
bcs L4C1A
2019-11-10 18:28:06 +00:00
2019-10-16 06:09:13 +00:00
L4BFE lda gbuf+2 get forward link.
cmp #$01 test for null block into carry.
ldx gbuf+3 get the rest of the block address.
bne L4C0A branch if not null.
bcc L4BCD was the low part null as well ?
2019-11-10 18:28:06 +00:00
2020-08-28 10:47:41 +00:00
L4C0A jsr XDOS.DeallocAX free this block.
2019-10-16 06:09:13 +00:00
bcs L4C1A
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda gbuf+2
ldx gbuf+3
2020-08-28 10:47:41 +00:00
jsr XDOS.ReadGBufAX read next DIR block (no need to unpack)
2019-10-16 06:09:13 +00:00
bcc L4BFE loop until all freed
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4C1A rts
2019-11-10 18:28:06 +00:00
2020-05-25 13:58:59 +00:00
L4C1Abis lda #MLI.E.LOCKED access error.
.HS 2C BIT ABS
2019-10-16 06:09:13 +00:00
L4C1B lda #MLI.E.INCFF file incompatible
jsr GP.P8errv
fcbused pha mark fcb as dirty so the directory will be flushed on 'flush'.
tya save regs.
pha
ldy fcbptr
2020-09-17 15:29:41 +00:00
lda #$80 mark fcb as dirty.
2020-07-17 15:18:31 +00:00
sta FCBs+FCB.DIRTY,y save it back
2019-10-16 06:09:13 +00:00
pla and restore regs.
tay
pla
rts
2020-05-25 13:58:59 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
* 'detree' deallocates blocks from tree files. it is assumed that the device has
* been pre-selected and the 'gbuf' may be used.
*
* 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.
2020-09-19 16:48: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
2019-10-16 06:09:13 +00:00
L4C5E jsr drdfrst read specified first block into gbuf.
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
2019-10-16 06:09:13 +00:00
L4C6D lda gbuf,y addresses. fetch low block address
sta dealbufl,x and save it.
ora gbuf+$100,y is it a real block that is allocated?
beq L4C81 branch if phantom block.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda gbuf+$100,y fetch high block address
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
sta bloknml
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,
sta bloknml+1
2020-05-25 13:58:59 +00:00
jsr XDOS.ReadGBuf read sapling level into 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
jsr dealblk go free all data indexes in this block
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.
jsr dalblk1 (master index in gbuf)
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
2020-05-25 13:58:59 +00:00
lda gbuf,y otherwise, continue with partial, deallocation of last sapling index.
2019-10-16 06:09:13 +00:00
ora gbuf+$100,y is there such a sapling index block ?
beq L4CC2 all done if not.
2020-05-13 17:00:37 +00:00
2020-05-25 13:58:59 +00:00
lda gbuf,y
ldx gbuf+$100,y read in sapling level to be modified.
jsr XDOS.ReadGBufAX read highest sapling index into 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
bcs L4CC2 into 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
2019-10-16 06:09:13 +00:00
jsr dalblk1 deallocate all indexes above specified.
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
2019-10-16 06:09:13 +00:00
L4D0A lda gbuf,y fetch low order data block address.
ora gbuf+$100,y is it a real block ?
beq L4CC2 if not, then done.
2020-05-13 17:00:37 +00:00
2020-05-25 13:58:59 +00:00
lda gbuf,y
ldx gbuf+$100,y
jsr XDOS.ReadGBufAX go read data block into 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
2019-10-16 06:09:13 +00:00
L4D3B sta gbuf+$100,y zero out unwanted data
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
2019-10-16 06:09:13 +00:00
L4D49 sta gbuf,y
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
2019-10-16 06:09:13 +00:00
drdfrst lda firstbl read specified 1st block into gbuf
ldx firstbh
2020-05-25 13:58:59 +00:00
jmp XDOS.ReadGBufAX go read it
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.
shrink ldx firstbh first deallocate top index block
txa
pha
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
sta bloknml set master of sapling
pla index block address.
sta bloknml+1
2020-05-25 13:58:59 +00:00
bcs L4D1E report errors.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda gbuf get # of new 1st block from old index.
sta firstbl
lda gbuf+$100
sta firstbh
ldy #$00
jsr swapme flip that one entry in old top index.
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.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
dealblk ldy #$00 start at beginning.
dalblk1 lda bloknml save disk address of gbuf's data.
pha
lda bloknml+1
pha
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4D96 sty saptr save current index.
lda gbuf,y get low address of block to deallocate.
cmp #$01 test for null block into carry.
ldx gbuf+$100,y get remainder of block address.
bne L4DA5 branch if not null.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
bcc L4DB0 was the low part null too ?
2020-05-13 17:00:37 +00:00
2020-08-28 10:47:41 +00:00
L4DA5 jsr XDOS.DeallocAX free it up on volume bitmap.
2019-10-16 06:09:13 +00:00
bcs L4DB4 return any error.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldy saptr get index to sapling level index block.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr swapme
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4DB0 iny next block address.
bne L4D96 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.
L4DB4 tax save error code, if any.
pla restore blocknm (16 bit)
sta bloknml+1
pla
sta bloknml
txa restore return code
rts
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
swapme lda delflag swapping or zeroing ?
bne L4DC5 skip if swapping.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
tax make x = 0.
beq L4DCB zero the index (always taken).
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4DC5 ldx gbuf+$100,y index high
lda gbuf,y index low
L4DCB sta gbuf+$100,y save index high
txa
sta gbuf,y save index low
rts done.
* MEMMGR memory manager
*
* allocate buffer in memory tables
alcbuffr ldy #$04 index to user specified buffer.
alcbufr1 lda (A3L),y this buffer must be on a page boundary.
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
2019-10-16 06:09:13 +00:00
sta datptr+1
dey
lda (A3L),y low address should be zero !
sta datptr
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.
jsr cmembit test for free buffer space
2019-11-09 12:19:41 +00:00
and MEMTABL,y P8 memory bitmap
2019-10-16 06:09:13 +00:00
bne L4E1E report memory conflict, if any.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
cpx datptr+1 test all 4 pages.
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
jsr cmembit
2019-11-09 12:19:41 +00:00
ora MEMTABL,y to mark it's allocation.
sta MEMTABL,y
2019-10-16 06:09:13 +00:00
cpx datptr+1 set all 4 pages
bne L4DFE
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldy fcbptr calculate buffer number
2020-05-28 21:13:52 +00:00
lda FCBs,y
2019-10-16 06:09:13 +00:00
asl buffer number = (entnum) * 2.
2020-07-17 15:18:31 +00:00
sta FCBs+FCB.BUFID,y save it in fcb.
2019-10-16 06:09:13 +00:00
tax use entnum * 2 as index to global
lda datptr+1 buffer addr tables. get addr already
sta buftbl-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.
2019-10-16 06:09:13 +00:00
lda buftbl-2,x
sta bufaddrl
lda buftbl-1,x
sta bufaddrh
2020-09-18 15:06:12 +00:00
beq relbuffr.8 branch if unallocated buffer space.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
stz buftbl-1,x take address out of buffer list.
stz buftbl-2,x (x was set up by getbufadr)
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
freebuf ldx bufaddrh get hi buffer address
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.
2019-10-16 06:09:13 +00:00
jsr cmembit get bit and position to memtable of
eor #$FF this page. invert mask.
2019-11-09 12:19:41 +00:00
and MEMTABL,y mark address as free space.
sta MEMTABL,y
2019-10-16 06:09:13 +00:00
cpx bufaddrh 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
*--------------------------------------
2019-10-16 06:09:13 +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
2019-11-10 18:28:06 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
cmembit 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.
2020-09-19 16:48:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
valdbuf lda usrbuf+1 high address of user's buffer
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 usrbuf calculate end of request address.
txa do high address.
adc usrbuf+1 the final address
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.
jsr cmembit
2019-11-09 12:19:41 +00:00
and 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
2019-10-16 06:09:13 +00:00
cpx usrbuf+1 was that the last (lowest) page ?
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
*--------------------------------------
XDOS.GetBuf ldy #$02 give user address of file buffer referenced by refnum.
2019-10-16 06:09:13 +00:00
lda bufaddrl
sta (A3L),y
iny
lda bufaddrh
sta (A3L),y
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
2019-10-16 06:09:13 +00:00
lda bufaddrh
sta usrbuf+1
lda bufaddrl
sta usrbuf
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
2019-11-23 15:24:55 +00:00
2019-10-16 06:09:13 +00:00
L4EB8 lda (usrbuf),y move all 4 pages of the buffer to
sta (datptr),y new location.
iny
bne L4EB8
2019-11-23 15:24:55 +00:00
2019-10-16 06:09:13 +00:00
inc datptr+1
inc usrbuf+1
dex
bpl L4EB8
2020-09-18 15:06:12 +00:00
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
XDOS.IsValidFirstChar.SEC
sec
rts
*--------------------------------------
2019-10-16 06:09:13 +00:00
* move 3 pages of dispatcher from 'displc2' to 'dispadr'
* this move routine must be resident above $E000 at all times
2019-11-09 12:19:41 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
calldisp lda RRAMWRAMBNK2 read/write RAM bank 2
lda RRAMWRAMBNK2
2019-11-06 20:48:15 +00:00
2019-10-16 06:09:13 +00:00
stz A1L
2019-11-06 20:48:15 +00:00
lda #$D1
sta A1L+1
stz A2L
lda #$10
sta A2L+1
2019-10-16 06:09:13 +00:00
ldy #$00
ldx #$03 3 pages to move.
2019-11-06 20:48:15 +00:00
.1 lda (A1L),y
2019-10-16 06:09:13 +00:00
sta (A2L),y
2019-11-06 20:48:15 +00:00
iny
bne .1
2019-10-16 06:09:13 +00:00
inc A1L+1 pointers to next page
inc A2L+1
dex move all pages needed
2019-11-06 20:48:15 +00:00
bne .1
2019-10-16 06:09:13 +00:00
lda RRAMWRAMBNK1 read/write RAM bank 1
lda RRAMWRAMBNK1 swap mli space back in
2019-11-06 20:48:15 +00:00
2019-10-16 06:09:13 +00:00
stz mliact MLI active flag
2019-11-06 20:48:15 +00:00
2019-10-16 06:09:13 +00:00
stz softev
2019-11-06 20:48:15 +00:00
lda #$10 point RESET to dispatch entry
2019-10-16 06:09:13 +00:00
sta softev+1
eor #$A5
sta pwredup power up byte
2019-11-06 20:48:15 +00:00
jmp $1000
2019-11-09 12:19:41 +00:00
*--------------------------------------
XDOS.SPREMAP ldx #$03 assume 3 parameters.
2019-10-16 06:09:13 +00:00
lda A4L command number
sta cmdnum
2019-11-09 12:19:41 +00:00
bne .1 taken if not status call
2019-10-16 06:09:13 +00:00
2020-04-13 17:04:02 +00:00
ldy #XDOS.SPStatus set up memory for the status list buffer
2019-10-16 06:09:13 +00:00
sty buf fake up the prodos parameters
2020-04-13 17:04:02 +00:00
ldy /XDOS.SPStatus
2019-10-16 06:09:13 +00:00
sty buf+1
stz bloknml set statcode = 0 for simple status call
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
lda 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
2019-10-16 06:09:13 +00:00
sta sp_vector+1 copy smartport entry address
2020-04-13 17:04:02 +00:00
lda XDOS.SPVectHi-1,x
2019-10-16 06:09:13 +00:00
sta sp_vector+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
.3 lda buf-1,x from prodos parameters
2020-04-13 17:04:02 +00:00
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
2019-10-16 06:09:13 +00:00
sp_vector jsr $0000 smartport call (entry address gets modified)
cmdnum .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
ldx cmdnum status call ?
2019-11-09 12:19:41 +00:00
bne .9 no...
2020-04-13 17:04:02 +00:00
ldx XDOS.SPStatus+1 else get the block count
ldy XDOS.SPStatus+2
lda XDOS.SPStatus 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
*--------------------------------------
2020-04-13 17:04:02 +00:00
XDOS.SPParams .HS 03 # of parms (always 3 except format)
XDOS.SPParams.U .HS 00 unit number
XDOS.SPParams.B .HS 0000 data buffer
2019-10-16 06:09:13 +00:00
.HS 000000 block number (3 bytes)
2021-03-11 21:40:55 +00:00
*--------------------------------------
.DO XRWDBG=1
XRW.DEBUG sta CLRPAGE2
lda #"R"
bit XRW.bWrite
bpl .1
lda #"W"
.1 sta $723
ldx #$24
lda XRW.ReqTrack
jsr .6
lda XRW.ReqSector
.6 pha
lsr
lsr
lsr
lsr
jsr .7
pla
.7 and #$0F
ora #$B0
cmp #"9"+1
bcc .8
adc #6
.8 sta $700,x
inx
rts
.FIN
2019-11-09 12:19:41 +00:00
*--------------------------------------
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
*--------------------------------------
2019-10-16 06:09:13 +00:00
own_blk .HS 0000
own_ent .HS 00
own_len .HS 00
2020-05-28 21:13:52 +00:00
*--------------------------------------
2019-12-06 07:15:51 +00:00
.DO ACL=1
h_acl .BS 8
.FIN
2019-10-16 06:09:13 +00:00
h_credt .HS 0000 directory creation date
.HS 0000 directory creation time
.HS 00 version under which this dir created
.HS 00 earliest version that it's compatible
h_attr .HS 00 attributes (protect bit, etc.)
h_entln .HS 00 length of each entry in this directory
h_maxent .HS 00 maximum number of entries per block
2020-07-10 13:59:56 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
h_fcnt .HS 0000 current # of files in this directory
h_bmap .HS 0000 address of first allocation bitmap
h_tblk .HS 0000 total number of blocks on this unit
2020-05-23 18:45:32 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
d_dev .HS 00 device number of this directory entry
d_head .HS 0000 address of <sub> directory header
d_entblk .HS 0000 address of block which contains entry
d_entnum .HS 00 entry number within block
2020-05-28 21:13:52 +00:00
*--------------------------------------
2019-11-09 12:19:41 +00:00
d_stor .BS 16 file name
2019-10-16 06:09:13 +00:00
d_filid .HS 00 user's identification byte
d_frst .HS 0000 first block of file
d_usage .HS 0000 # of blocks allocated to this file
d_eof .HS 000000 current end of file marker
d_credt .HS 0000 file creation date
.HS 0000 file creation time
d_sosver .HS 00 sos version that created this file
d_comp .HS 00 backward version compatibility
d_attr .HS 00 attributes (protect, r/w, enable, etc.)
d_auxid .HS 0000 user auxilliary identification
d_moddt .HS 0000 file's last modification date
.HS 0000 file's last modification time
d_dhdr .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
xvcbptr .HS 00 used in 'cmpvcb' as a temp
vcbptr .HS 00
fcbptr .HS 00
fcbflg .HS 00
reql .HS 00
reqh .HS 00
levels .HS 00
totent .HS 00
entcntl .HS 00
entcnth .HS 00
cntent .HS 00
nofree .HS 00
bmcnt .HS 00
saptr .HS 00
pathcnt .HS 00
p_dev .HS 00
p_blok .HS 0000
bmptr .HS 00
basval .HS 00
half .HS 00
* bitmap info tables
bmastat .HS 00
bmadev .HS 00
bmadadr .HS 0000
bmacmap .HS 00
tposll .HS 00
tposlh .HS 00
tposhi .HS 00
rwreql .HS 00
rwreqh .HS 00
nlchar .HS 00
nlmask .HS 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
duplflag .HS 00
vcbentry .HS 00
* xdos temporary variables
namcnt .HS 00
rnptr .HS 00
namptr .HS 00
vnptr .HS 00
prfxflg .HS 00
cferr .HS 00
* deallocation temporary variables
firstbl .HS 00
firstbh .HS 00
stortyp .HS 00
deblock .HS 0000
dtree .HS 00
dsap .HS 00
dseed .HS 0000
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
bufaddrl .HS 00
bufaddrh .HS 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
2019-11-09 12:19:41 +00:00
.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
2020-04-23 15:36:51 +00:00
XDOS.SPStatus .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
2019-11-09 12:19:41 +00:00
.LIST OFF
2019-11-04 07:21:40 +00:00
.ED
2021-03-11 21:40:55 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
* zero fill to page boundary - 3 ($FEFD). so that cortland flag stays within page boundary.
.LIST ON
2019-11-23 15:24:55 +00:00
XDOS.FREE .EQ $FEFD-*-XDOS.DATA.LEN (2.0.3 = $0C)
2019-10-16 06:09:13 +00:00
.LIST OFF
2019-11-06 16:25:00 +00:00
cortdisp .EQ $FEFD
cortflag .EQ $FEFF cortland flag. 1 = Cortland system (must stay within page boundary)
2019-10-16 06:09:13 +00:00
*--------------------------------------
2020-05-25 13:58:59 +00:00
XDOS.LEN .EQ *-XDOS
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
ASM