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

700 lines
19 KiB
Plaintext
Raw Normal View History

2019-10-16 06:09:13 +00:00
NEW
AUTO 3,1
2019-11-20 07:04:00 +00:00
*--------------------------------------
XDOS.Read jsr mvdbufr xfer buffer address and request count
2019-10-16 06:09:13 +00:00
jsr mvcbytes to a more accessable location, also
pha get fcb attributes and save on stack.
jsr calcmrk calc mark after read, test if mark > eof
pla carry set means end mark > eof.
and #$01 test for read enabled.
2019-11-20 07:04:00 +00:00
beq .9
bcc L4205 branch if result mark < eof. adjust
2020-05-13 17:00:37 +00:00
ldy XDOS.FCBPtr request to read until just before eof.
2023-11-04 14:42:28 +00:00
lda XDOS.FCBs+FCB.EOF,y result = (eof-1) - position
2019-10-16 06:09:13 +00:00
sbc tposll
sta cbytes
sta rwreql
2023-11-04 14:42:28 +00:00
lda XDOS.FCBs+FCB.EOF+1,y
2019-10-16 06:09:13 +00:00
sbc tposlh
sta cbytes+1
sta rwreqh
ora cbytes if both bytes = 0 then eof error
bne L4210
2019-11-20 07:04:00 +00:00
lda #MLI.E.EOF
.HS 2C
.9 lda #MLI.E.LOCKED
2019-10-16 06:09:13 +00:00
L4202 jmp errfix1
2019-11-20 07:04:00 +00:00
2019-10-16 06:09:13 +00:00
L4205 lda cbytes
ora cbytes+1
bne L4210 if read request definitely non-zero.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L420D jmp rwdone do nothing.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4210 jsr valdbuf validate user's data buffer range.
bcs L4202 branch if memory conflict.
2019-11-20 07:04:00 +00:00
2023-11-05 15:26:06 +00:00
jsr XDOS.GetFCB.ST get storage type
2019-10-16 06:09:13 +00:00
cmp #$04 and find out if it's a tree or other.
bcc L421F branch if a tree file
2020-05-13 17:00:37 +00:00
2020-09-18 15:06:12 +00:00
jmp XDOS.ReadDir otherwise assume it's a directory.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L421F jsr rdposn set up data pointer.
bcs L4202 errors.
2019-11-20 07:04:00 +00:00
2019-10-16 06:09:13 +00:00
jsr preprw test for newline, setup for partial
jsr readpart read. move current data buffer contents
bvs L420D to user area. branch if satisfied.
bcs L421F indicates newline is set.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda rwreqh how many blocks are to be read ?
lsr if < 2 then use the slow way.
beq L421F
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
sta cmdtemp save bulk block count.
2020-09-19 16:48:28 +00:00
jsr XDOS.GetFCBStatus make sure current data area doesn't
2019-10-16 06:09:13 +00:00
and #$40 need writing before resetting ptr to
bne L421F read into user's area. branch if data
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
sta ioaccess needs to be written to force 1st call
lda ZP.UserBuf thru all dev handler checking. make
2023-11-05 15:26:06 +00:00
sta ZP.DataPtr the data buffer the user's space.
lda ZP.UserBuf+1
2023-11-05 15:26:06 +00:00
sta ZP.DataPtr+1
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4249 jsr rdposn get next block directly into user space.
bcs L42B7 if error.
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
L424E inc ZP.DataPtr+1 incll ptrs by one block (512 bytes)
inc ZP.DataPtr+1
2019-10-16 06:09:13 +00:00
dec rwreqh
dec rwreqh
inc tposlh
inc tposlh
bne L4269 if pos'n doesn't get to a 64k boundary
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inc tposhi otherwise, must check for a 128k one.
lda tposhi carry set if 128k boundary reached.
eor #$01
lsr
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4269 dec cmdtemp has all been read fast ?
bne L427B branch if more to read.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr fxdatptr go fix up data pointer to xdos buffer.
lda rwreql test for end of read.
ora rwreqh are both 0 ?
beq rwdone yes, done.
2019-10-16 06:09:13 +00:00
bne L421F no, read last partial block
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L427B bcs L4249
2020-05-13 17:00:37 +00:00
jsr XDOS.Tpos2Y get index to next block address
2019-10-16 06:09:13 +00:00
lda (zpt),y get low address
2023-11-04 14:42:28 +00:00
sta ZP.BLKNUM
2019-10-16 06:09:13 +00:00
inc zpt+1
cmp (zpt),y are hi and low address the same?
bne L4299 no, it's a real block address.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
cmp #$00 are both bytes 0 ?
bne L4299 no, must be real data.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
sta ioaccess don't do repeat io just after sparse.
beq L429C branch always (carry set).
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4299 lda (zpt),y get high address
clc
L429C dec zpt+1
bcs L4249 if no block to read.
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
sta ZP.BLKNUM+1
2019-10-16 06:09:13 +00:00
lda ioaccess has 1st call gone to device yet ?
beq L4249 no, go thru normal route
2020-05-13 17:00:37 +00:00
lda ZP.DataPtr+1 reset hi buffer address for dev handler
2023-11-04 14:42:28 +00:00
sta ZP.BUFPTR+1
2020-09-17 15:29:41 +00:00
jsr XDOS.DevCall
bcc L424E no errors, branch always.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L42B7 pha save error code.
jsr fxdatptr go restore data pointers, etc.
pla
2019-11-20 07:04:00 +00:00
2019-10-16 06:09:13 +00:00
errfix1 pha save error code
jsr rwdone pass back # of bytes actually read
pla
sec error
rts
2020-09-19 16:48:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
rwdone ldy #$06 return total # of bytes actually read
sec derived from cbytes-rwreq.
lda cbytes
sbc rwreql
2023-11-04 14:42:28 +00:00
sta (ZP.A3L),y
2019-10-16 06:09:13 +00:00
iny
lda cbytes+1
sbc rwreqh
2023-11-04 14:42:28 +00:00
sta (ZP.A3L),y
2019-10-16 06:09:13 +00:00
jmp rdposn leave with valid position in fcb.
2020-09-19 16:48:28 +00:00
*--------------------------------------
preprw ldy XDOS.FCBPtr adj pointer to user's buffer to make
2019-10-16 06:09:13 +00:00
sec the transfer
lda ZP.UserBuf
2019-10-16 06:09:13 +00:00
sbc tposll
sta ZP.UserBuf
2023-11-05 15:26:06 +00:00
bcs .1 if no adjustment to hi address needed
2023-11-04 14:42:28 +00:00
dec ZP.UserBuf+1
2020-07-17 15:18:31 +00:00
2023-11-05 15:26:06 +00:00
.1 lda XDOS.FCBs+FCB.NLMASK,y test for new line enabled.
2019-10-16 06:09:13 +00:00
clc
2023-11-05 15:26:06 +00:00
beq .2 if new line not enabled.
2023-11-04 14:42:28 +00:00
2019-10-16 06:09:13 +00:00
sec carry indicates new line enabled
sta nlmask
2023-11-04 14:42:28 +00:00
lda XDOS.FCBs+FCB.NLBYTE,y move newline character to more
2019-10-16 06:09:13 +00:00
sta nlchar accesible spot.
2020-09-17 15:29:41 +00:00
2023-11-05 15:26:06 +00:00
.2 ldy tposll index to 1st data.
lda ZP.DataPtr reset low order of position pointer to
2019-10-16 06:09:13 +00:00
sta sos beginning of page.
ldx rwreql get low order count of requested bytes.
rts return statuses.
2020-09-19 16:48:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
readpart txa x = low count of bytes to move.
bne L430F branch if request is not an even page.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda rwreqh a call of 0 bytes should never get here!
beq L435D branch if nothing to do.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
dec rwreqh
2020-09-19 16:48:28 +00:00
2019-10-16 06:09:13 +00:00
L430F dex
2020-09-19 16:48:28 +00:00
2019-10-16 06:09:13 +00:00
L4310 lda (sos),y move data to user's buffer
sta (ZP.UserBuf),y
2019-10-16 06:09:13 +00:00
bcs tstnewl test for newline 1st !
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4316 txa note: x must be unchanged from tstnewl !
beq L4332 go see if read request is satisfied...
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4319 dex dec # of bytes left to move.
iny page crossed ?
bne L4310 no, move next byte.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda sos+1 test for end of buffer, but first
inc ZP.UserBuf+1 adjust user buffer pointer
2019-10-16 06:09:13 +00:00
inc tposlh and position
bne L4329
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inc tposhi
2019-10-16 06:09:13 +00:00
L4329 inc sos+1 and sos buffer high address.
2023-11-05 15:26:06 +00:00
eor ZP.DataPtr+1 (carry is undisturbed)
2019-10-16 06:09:13 +00:00
beq L4310 branch if more to read in buffer.
2019-10-16 06:09:13 +00:00
clv indicate not finished.
bvc L4360 always.
2019-11-20 07:04:00 +00:00
2019-10-16 06:09:13 +00:00
L4332 lda rwreqh
beq L4350 branch if request is satisfied.
2019-10-16 06:09:13 +00:00
iny done with this block of data ?
bne L4340 no, adjust high byte of request.
2019-10-16 06:09:13 +00:00
lda sos+1 maybe, check for end of block buffer.
2023-11-05 15:26:06 +00:00
eor ZP.DataPtr+1 (don't disturb carry).
2019-10-16 06:09:13 +00:00
bne L4343 if hi count can be dealt with next time
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4340 dec rwreqh
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4343 dey restore proper value
bra L4319
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
tstnewl lda (sos),y get last byte transferred again.
and nlmask only bits on in mask are significant.
eor nlchar does it match newline character?
bne L4316 no, read next.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4350 iny adjust position.
bne L435D
2020-05-13 17:00:37 +00:00
inc ZP.UserBuf+1 inc pointers
2019-10-16 06:09:13 +00:00
inc tposlh
bne L435D
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inc tposhi
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L435D bit setvflg (sets v flag)
2020-09-17 15:29:41 +00:00
2019-10-16 06:09:13 +00:00
L4360 sty tposll save low position
bvs L4366
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inx leave request as +1 for next call
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4366 stx rwreql and remainder of request count.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
php save statuses
clc adjust user's low buffer address
tya
adc ZP.UserBuf
sta ZP.UserBuf
2019-10-16 06:09:13 +00:00
bcc L4374
2020-05-13 17:00:37 +00:00
inc ZP.UserBuf+1 adjust hi address as needed.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4374 plp restore return statuses.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
setvflg rts this byte ($60) is used to set v flag.
2020-09-19 16:48:28 +00:00
*--------------------------------------
2023-11-05 15:26:06 +00:00
fxdatptr lda ZP.DataPtr put current user buffer address back to normal
sta ZP.UserBuf
2023-11-05 15:26:06 +00:00
lda ZP.DataPtr+1
sta ZP.UserBuf+1 bank pair byte should be moved also.
2019-10-16 06:09:13 +00:00
ldx XDOS.FCBPtr restore buffer address
2020-09-18 15:06:12 +00:00
jmp XDOS.GetFCBBufX
*--------------------------------------
XDOS.ReadDir jsr rdposn
2019-10-16 06:09:13 +00:00
bcs L43B8 pass back any errors.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr preprw prepare for transfer.
jsr readpart move data to user's buffer.
2020-09-18 15:06:12 +00:00
bvc XDOS.ReadDir repeat until request is satisfied.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr rwdone update fcb as to new position.
bcc L43B6 branch if done with no errors.
2020-05-13 17:00:37 +00:00
cmp #MLI.E.EOF was last read to end of file ?
2019-10-16 06:09:13 +00:00
sec anticipate some other error.
bne L43B7 branch if not eof error.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr svmark
2023-11-05 15:26:06 +00:00
jsr XDOS.ZeroData clear out data block.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldy #$00 provide dummy back pointer for future
ldx XDOS.FCBPtr re-position. x = hi byte of last block
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
L43A6 lda XDOS.FCBs+FCB.DBLK,x
2023-11-05 15:26:06 +00:00
sta (ZP.DataPtr),y
2023-11-04 14:42:28 +00:00
stz XDOS.FCBs+FCB.DBLK,x mark current block as impossible
2019-10-16 06:09:13 +00:00
inx
iny inc indexes to do both hi and low bytes
cpy #$02
bne L43A6
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L43B6 clc no error
L43B7 rts
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L43B8 jmp errfix1 report how much xfer'd before error.
2020-09-19 16:48:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
mvcbytes ldy #$04 move request count to a more accessable location
2023-11-04 14:42:28 +00:00
lda (ZP.A3L),y
2019-10-16 06:09:13 +00:00
sta cbytes
sta rwreql
iny
2023-11-04 14:42:28 +00:00
lda (ZP.A3L),y
2019-10-16 06:09:13 +00:00
sta cbytes+1
sta rwreqh
ldy XDOS.FCBPtr return y = val(XDOS.FCBPtr),
2023-11-04 14:42:28 +00:00
lda XDOS.FCBs+FCB.ACCESS,y a = attributes
2019-10-16 06:09:13 +00:00
clc and carry clear...
rts
2020-09-19 16:48:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
mvdbufr ldy #$02 move the pointer to user's buffer
2023-11-04 14:42:28 +00:00
lda (ZP.A3L),y to the block file manager
sta ZP.UserBuf z-page area
2019-10-16 06:09:13 +00:00
iny
2023-11-04 14:42:28 +00:00
lda (ZP.A3L),y
sta ZP.UserBuf+1
2020-05-13 17:00:37 +00:00
XDOS.GetFCB.ST ldy XDOS.FCBPtr return storage type
2023-11-04 14:42:28 +00:00
lda XDOS.FCBs+FCB.STYPE,y
2019-10-16 06:09:13 +00:00
rts
2020-09-19 16:48:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
* this subroutine adds the requested byte count to mark and returns sum
* in scrtch and also returns mark in tpos and oldmark.
*
* on exit:
* y,x,a is unknown
* carry set indicates scrtch > eof
2020-09-19 16:48:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
calcmrk ldx #$00
ldy XDOS.FCBPtr
2019-10-16 06:09:13 +00:00
clc
2023-11-04 14:42:28 +00:00
L43EE lda XDOS.FCBs+FCB.MARK,y
2019-10-16 06:09:13 +00:00
sta tposll,x
sta oldmark,x
adc cbytes,x
sta scrtch,x
txa
eor #$02 cbytes+2 always=0
beq eoftest
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
iny
inx
bne L43EE always.
eoftest lda scrtch,x new mark in scrtch.
2023-11-04 14:42:28 +00:00
cmp XDOS.FCBs+FCB.EOF,y is new position > eof ?
2019-10-16 06:09:13 +00:00
bcc L4414 no, proceed.
bne L4414 yes, adjust 'cbytes' request
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
dey
dex all tree bytes compared ?
bpl eoftest no, test next lowest
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4414 rts
2020-09-19 16:48:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
werreof jsr plus2fcb reset eof to pre-error position.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4418 lda oldeof,x place oldeof back into fcb
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.EOF,y
2019-10-16 06:09:13 +00:00
lda oldmark,x also reset mark to last best
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.MARK,y write position
2019-10-16 06:09:13 +00:00
sta scrtch,x and copy mark to scrtch for test of
dey eof less than mark.
dex
bpl L4418
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr plus2fcb get pointers to test eof < mark.
jsr eoftest carry set means mark > eof !!
* drop into wadjeof to adjust eof to mark if necessary
wadjeof jsr plus2fcb get y=XDOS.FCBPtr+2, x=2, a=y.
2020-05-13 17:00:37 +00:00
2023-11-04 14:42:28 +00:00
L4434 lda XDOS.FCBs+FCB.EOF,y copy eof to old eof
2019-10-16 06:09:13 +00:00
sta oldeof,x
bcc L4442 and if carry set...
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda scrtch,x then copy scrtch to fcb's eof.
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.EOF,y
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4442 dey
dex copy all 3 bytes
bpl L4434
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
plus2fcb lda #$02 on exit both a and y = XDOS.FCBPtr+2.
2019-10-16 06:09:13 +00:00
tax x = 2
ora XDOS.FCBPtr
2019-10-16 06:09:13 +00:00
tay
rts
2019-11-20 07:04:00 +00:00
*--------------------------------------
XDOS.Write jsr mvcbytes first determine if requested write is legal.
2019-10-16 06:09:13 +00:00
pha
jsr calcmrk save a copy of eof to old eof, set/clr
jsr wadjeof carry to determine if new mark > eof.
pla get attributes again.
and #$02 is write enabled ?
bne L4462 yes, continue...
2020-05-13 17:00:37 +00:00
L445E lda #MLI.E.LOCKED illegal access error.
2019-10-16 06:09:13 +00:00
bne L44A2
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
L4462 jsr XDOS.TestWP otherwise, make sure device is not
2019-10-16 06:09:13 +00:00
bcs L44A2 write protected. if so, branch to abort.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda cbytes
ora cbytes+1 anything to write ?
bne L4472 branch if so,
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jmp rwdone else do nothing.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4472 jsr mvdbufr move the user's buffer ptr to bfm zero
cmp #$04 page area, also get storage type.
bcs L445E if not tree, return an access error.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4479 jsr rdposn
bcs L44A2
2020-05-13 17:00:37 +00:00
2020-09-18 15:06:12 +00:00
jsr XDOS.GetFCBStatus
2019-10-16 06:09:13 +00:00
and #$07
beq L44E9
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
ldy #$00 is enough disk space available for
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4487 iny indexes and data block ?
lsr
bne L4487
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
sty reql
sta reqh
jsr XDOS.CheckFree
2019-10-16 06:09:13 +00:00
bcs L44A2 pass back any errors.
2020-05-13 17:00:37 +00:00
2020-09-19 16:48:28 +00:00
jsr XDOS.GetFCBStatus now get more specific.
2019-10-16 06:09:13 +00:00
and #$04 are we lacking a tree top ?
beq L44AC no, test for lack of sapling level index
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr topdown go allocate tree top and adj file type.
bcc L44B8 continue with allocation of data block.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L44A2 pha save error.
jsr errfix1 error return.
jsr werreof adjust eof and mark to pre-error state.
pla restore error code.
sec
rts
2020-05-13 17:00:37 +00:00
2020-09-18 15:06:12 +00:00
L44AC jsr XDOS.GetFCBStatus get status byte again.
2019-10-16 06:09:13 +00:00
and #$02 do we need a sapling level index block ?
beq L44B8 no, assume it's just a data block needed
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr sapdown go alloc an indx blk and update tree top
bcs L44A2 if error.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L44B8 jsr alcwblk go allocate for data block.
bcs L44A2
2020-05-13 17:00:37 +00:00
2020-09-18 15:06:12 +00:00
jsr XDOS.ClrFCBStatus clear allocation required bits in status
lda #FCB.F.IBLKMOD indicate index block is dirty.
jsr XDOS.SetFCBStatus
jsr XDOS.Tpos2Y now put block address into index block.
2019-10-16 06:09:13 +00:00
inc zpt+1 high byte first.
lda scrtch+1
tax
sta (zpt),y
dec zpt+1 restore pointer to lower page of index
lda scrtch block. get low block address.
sta (zpt),y store low address.
2020-09-18 15:06:12 +00:00
ldy XDOS.FCBPtr update fcb to indicate that this block
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.DBLK,y is allocated.
2019-10-16 06:09:13 +00:00
txa get high address again.
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.DBLK+1,y
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L44E9 jsr preprw
jsr wrtpart
bvc L4479
jmp rwdone update fcb with new position
wrtpart txa
bne L44FF branch if request is not even pages
lda rwreqh a call of 0 bytes should never get here!
beq L4546 do nothing
dec rwreqh
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L44FF dex
lda (ZP.UserBuf),y move data from user's buffer
2019-10-16 06:09:13 +00:00
sta (sos),y
txa
beq L4525
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4507 iny page crossed ?
bne L44FF no, keep moving.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda sos+1 test for end of buffer
inc ZP.UserBuf+1 but first adjust user buffer pointer
2019-10-16 06:09:13 +00:00
inc tposlh and position
bne L451C
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inc tposhi
bne L451C
2020-05-13 17:00:37 +00:00
lda #MLI.E.BEYEOF out of range if > 32MB
2019-10-16 06:09:13 +00:00
bne L44A2
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L451C inc sos+1 adjust sos buffer high address
2023-11-05 15:26:06 +00:00
eor ZP.DataPtr+1 (carry is undisturbed)
2019-10-16 06:09:13 +00:00
beq L44FF branch if more to write to buffer.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
clv indicates not finished.
bvc L4549 always.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4525 lda rwreqh
beq L4539 branch if request satisfied.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
iny done with this block of data ?
bne L4533 if not.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda sos+1 this is necessary for proper
2023-11-05 15:26:06 +00:00
eor ZP.DataPtr+1 adjustment of request count
2019-10-16 06:09:13 +00:00
bne L4536
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4533 dec rwreqh
L4536 dey reset modified y
bra L4507
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4539 iny and position
bne L4546
2020-05-13 17:00:37 +00:00
inc ZP.UserBuf+1 inc pointers
2019-10-16 06:09:13 +00:00
inc tposlh
bne L4546
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inc tposhi
2020-09-17 15:29:41 +00:00
2019-10-16 06:09:13 +00:00
L4546 bit setvflg set v flag
2020-09-17 15:29:41 +00:00
2019-10-16 06:09:13 +00:00
L4549 sty tposll save low position
stx rwreql and remainder of request count.
php save statuses
2020-09-17 15:29:41 +00:00
lda #$50
jsr XDOS.SetFCBStatus
2019-10-16 06:09:13 +00:00
clc adjust user's low buffer address
lda tposll
adc ZP.UserBuf
sta ZP.UserBuf
2019-10-16 06:09:13 +00:00
bcc L4564
2020-05-13 17:00:37 +00:00
inc ZP.UserBuf+1 adjust high address as needed.
2020-05-13 17:00:37 +00:00
L4564 jsr XDOS.SetFCB.DIRTY set directory flush bit.
2019-10-16 06:09:13 +00:00
plp restore return statuses
rts
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
topdown jsr swapdown make current 1st block an entry in new
bcs L45B1 top. branch if errors.
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
jsr XDOS.GetFCB.ST get storage type
2019-10-16 06:09:13 +00:00
* has storage type been changed to 'tree' ? if not, assume it was originally
* a seed and both levels need to be built. otherwise, only an index needs
* to be allocated.
cmp #$03 tree type
beq L457A
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr swapdown make previous swap a sap level index
bcs L45B1 block. branch if errors.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L457A jsr alcwblk get another block address for the sap
bcs L45B1 level index. branch if errors.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda tposhi calculate position of new index block
lsr in the top of the tree.
tay
lda scrtch get address of newly allocated index
tax block again.
sta (zpt),y
inc zpt+1
lda scrtch+1
sta (zpt),y save hi address
dec zpt+1
ldy XDOS.FCBPtr make newly allocated block the current
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.IBLK+1,y index block.
2019-10-16 06:09:13 +00:00
txa
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.IBLK,y
2019-10-16 06:09:13 +00:00
jsr wfcbfst save new top of tree
bcs L45B1
2020-09-19 16:48:28 +00:00
*--------------------------------------
2023-11-05 15:26:06 +00:00
XDOS.ZeroIndex lda #$00
2020-09-19 16:48:28 +00:00
tay
2020-05-13 17:00:37 +00:00
2020-09-19 16:48:28 +00:00
inc zpt+1
2023-11-05 15:26:06 +00:00
jsr .1
dec zpt+1
2019-10-16 06:09:13 +00:00
2023-11-05 15:26:06 +00:00
.1 sta (zpt),y
2020-09-19 16:48:28 +00:00
iny
2023-11-05 15:26:06 +00:00
bne .1
2020-09-19 16:48:28 +00:00
rts
*--------------------------------------
2023-11-05 15:26:06 +00:00
sapdown jsr XDOS.GetFCB.ST find out if dealing with a tree.
2019-10-16 06:09:13 +00:00
cmp #$01 if seed then adj to file type is needed.
beq swapdown branch if seed
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
jsr rfcbfst otherwise read in top of tree.
bcc L457A if no error.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L45B1 rts return errors.
2020-09-17 15:29:41 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
swapdown jsr alcwblk make current seed into a sapling, allocate a block before swap.
2020-09-17 15:29:41 +00:00
bcs .9 return errors.
2020-05-13 17:00:37 +00:00
ldy XDOS.FCBPtr get previous first block
2023-11-04 14:42:28 +00:00
lda XDOS.FCBs+FCB.1stBLK,y address into index block.
2019-10-16 06:09:13 +00:00
pha save temporarily while swapping in new
lda scrtch top index. get new block address (low)
tax
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.1stBLK,y
lda XDOS.FCBs+FCB.1stBLK+1,y
2019-10-16 06:09:13 +00:00
pha
lda scrtch+1 and high address too
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.1stBLK+1,y
sta XDOS.FCBs+FCB.IBLK+1,y make new top also the current index in
2019-10-16 06:09:13 +00:00
txa memory. get low address again.
2023-11-04 14:42:28 +00:00
sta XDOS.FCBs+FCB.IBLK,y
2019-10-16 06:09:13 +00:00
inc zpt+1 make previous the 1st entry in sub index
pla
sta (zpt)
dec zpt+1
pla
sta (zpt)
jsr wfcbfst save new file top.
2020-09-17 15:29:41 +00:00
bcs .9 if error.
2020-05-13 17:00:37 +00:00
2020-09-17 15:29:41 +00:00
lda #FCB.F.STMOD
jsr XDOS.SetFCBStatus
2019-10-16 06:09:13 +00:00
2023-11-04 14:42:28 +00:00
inc XDOS.FCBs+FCB.STYPE,x
2020-05-13 17:00:37 +00:00
2020-09-17 15:29:41 +00:00
* clc no error
.9 rts
*--------------------------------------
2023-11-12 13:20:15 +00:00
alcwblk jsr XDOS.GetFreeBlk
2020-09-17 15:29:41 +00:00
bcs .9
2020-05-13 17:00:37 +00:00
2020-09-17 15:29:41 +00:00
lda #FCB.F.UMOD
jsr XDOS.SetFCBStatus
2020-07-17 15:18:31 +00:00
2023-11-04 14:42:28 +00:00
inc XDOS.FCBs+FCB.UBLK,x
2020-09-17 15:29:41 +00:00
bne .9
2020-07-17 15:18:31 +00:00
2023-11-04 14:42:28 +00:00
inc XDOS.FCBs+FCB.UBLK+1,x
2019-10-16 06:09:13 +00:00
2020-09-17 15:29:41 +00:00
.9 rts
*--------------------------------------
2023-11-05 15:26:06 +00:00
XDOS.TestWP jsr XDOS.GetFCBStatus check for 'never been modified' condition
2019-10-16 06:09:13 +00:00
and #$F0
clc
2023-11-05 15:26:06 +00:00
bne XDOS.Tpos2Y.RTS ordinary rts if known write ok.
2020-05-13 17:00:37 +00:00
2020-09-19 16:48:28 +00:00
jsr XDOS.FCBDevIDSelect
2019-10-16 06:09:13 +00:00
2023-11-05 15:26:06 +00:00
XDOS.TestWPA sta ZP.UNITNUM make the device status call
2020-09-17 15:29:41 +00:00
2023-11-12 13:20:15 +00:00
lda ZP.BLKNUM
2019-10-16 06:09:13 +00:00
pha
2023-11-12 13:20:15 +00:00
lda ZP.BLKNUM+1 save the current block values
2019-10-16 06:09:13 +00:00
pha
2023-11-04 14:42:28 +00:00
stz ZP.CMDNUM
stz ZP.BLKNUM zero the block #
stz ZP.BLKNUM+1
2020-05-13 17:00:37 +00:00
2020-09-17 15:29:41 +00:00
jsr XDOS.DevCall
2019-10-16 06:09:13 +00:00
bcs .1 branch if write protect error
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda #$00 otherwise, assume no errors.
2020-05-13 17:00:37 +00:00
2023-11-05 15:26:06 +00:00
.1 jmp XDOS.PopBlkNumRTS restore the block #
*--------------------------------------
XDOS.Tpos2Y lda tposhi get index to next block address
lsr
lda tposlh
ror
tay index to address = int(pos/512)
2023-11-05 15:26:06 +00:00
XDOS.Tpos2Y.RTS rts
2019-11-20 07:04:00 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
MAN
2020-05-23 18:45:32 +00:00
SAVE usr/src/prodos.fx/prodos.s.xdos.d
LOAD usr/src/prodos.fx/prodos.s
2019-10-16 06:09:13 +00:00
ASM