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

699 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
2019-10-16 06:09:13 +00:00
ldy fcbptr request to read until just before eof.
2020-07-17 15:18:31 +00:00
lda FCBs+FCB.EOF,y result = (eof-1) - position
2019-10-16 06:09:13 +00:00
sbc tposll
sta cbytes
sta rwreql
2020-07-17 15:18:31 +00:00
lda 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
2019-10-16 06:09:13 +00:00
jsr gfcbstyp get storage type
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 usrbuf thru all dev handler checking. make
sta datptr the data buffer the user's space.
lda usrbuf+1
sta datptr+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
2019-10-16 06:09:13 +00:00
L424E inc datptr+1 incll ptrs by one block (512 bytes)
inc datptr+1
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.
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
2019-10-16 06:09:13 +00:00
lda tposhi get index to next block address
lsr
lda tposlh
ror
tay index to address = int(pos/512)
lda (zpt),y get low address
sta bloknml
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
2019-10-16 06:09:13 +00:00
sta bloknml+1
lda ioaccess has 1st call gone to device yet ?
beq L4249 no, go thru normal route
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
lda datptr+1 reset hi buffer address for dev handler
sta buf+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
sta (A3L),y
iny
lda cbytes+1
sbc rwreqh
sta (A3L),y
jmp rdposn leave with valid position in fcb.
2020-09-19 16:48:28 +00:00
*--------------------------------------
2019-10-16 06:09:13 +00:00
preprw ldy fcbptr adj pointer to user's buffer to make
sec the transfer
lda usrbuf
sbc tposll
sta usrbuf
bcs L42E9 if no adjustment to hi address needed
dec usrbuf+1
2020-07-17 15:18:31 +00:00
L42E9 lda FCBs+FCB.NLMASK,y test for new line enabled.
2019-10-16 06:09:13 +00:00
clc
beq L42F9 if new line not enabled.
sec carry indicates new line enabled
sta nlmask
2020-07-17 15:18:31 +00:00
lda 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
2019-10-16 06:09:13 +00:00
L42F9 ldy tposll index to 1st data.
lda datptr reset low order of position pointer to
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 (usrbuf),y
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 satified...
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 usrbuf+1 adjust user buffer pointer
inc tposlh and position
bne L4329
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inc tposhi
L4329 inc sos+1 and sos buffer high address.
eor datptr+1 (carry is undisturbed)
beq L4310 branch if more to read in buffer.
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.
iny done with this block of data ?
bne L4340 no, adjust high byte of request.
lda sos+1 maybe, check for end of block buffer.
eor datptr+1 (don't disturb carry).
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
2019-10-16 06:09:13 +00:00
inc usrbuf+1 inc pointers
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 usrbuf
sta usrbuf
bcc L4374
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inc usrbuf+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
*--------------------------------------
2019-10-16 06:09:13 +00:00
fxdatptr lda datptr put current user buffer address back to normal
sta usrbuf
lda datptr+1
sta usrbuf+1 bank pair byte should be moved also.
2020-09-18 15:06:12 +00:00
ldx fcbptr restore buffer address
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
jsr zipdata 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 fcbptr re-position. x = hi byte of last block
2020-05-13 17:00:37 +00:00
2020-07-17 15:18:31 +00:00
L43A6 lda FCBs+FCB.DBLK,x
2019-10-16 06:09:13 +00:00
sta (datptr),y
2020-07-17 15:18:31 +00:00
stz 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
lda (A3L),y
sta cbytes
sta rwreql
iny
lda (A3L),y
sta cbytes+1
sta rwreqh
ldy fcbptr return y = val(fcbptr),
2020-07-17 15:18:31 +00:00
lda 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
lda (A3L),y to the block file manager
sta usrbuf z-page area
iny
lda (A3L),y
sta usrbuf+1
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
gfcbstyp ldy fcbptr return storage type
2020-07-17 15:18:31 +00:00
lda 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 fcbptr
clc
2020-07-17 15:18:31 +00:00
L43EE lda 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.
2020-07-17 15:18:31 +00:00
cmp 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
2020-07-17 15:18:31 +00:00
sta FCBs+FCB.EOF,y
2019-10-16 06:09:13 +00:00
lda oldmark,x also reset mark to last best
2020-07-17 15:18:31 +00:00
sta 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=fcbptr+2, x=2, a=y.
2020-05-13 17:00:37 +00:00
2020-07-17 15:18:31 +00:00
L4434 lda 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.
2020-07-17 15:18:31 +00:00
sta 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
2019-10-16 06:09:13 +00:00
plus2fcb lda #$02 on exit both a and y = fcbptr+2.
tax x = 2
ora fcbptr
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
2019-10-16 06:09:13 +00:00
L445E lda #$4E illegal access error.
bne L44A2
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4462 jsr tstwprot otherwise, make sure device is not
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 tstfrblk
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
2019-10-16 06:09:13 +00:00
lda tposhi calculate position within index block.
lsr
lda tposlh
ror
tay now put block address into index block.
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
2019-10-16 06:09:13 +00:00
ldy fcbptr update fcb to indicate that this block
2020-07-17 15:18:31 +00:00
sta FCBs+FCB.DBLK,y is allocated.
2019-10-16 06:09:13 +00:00
txa get high address again.
2020-07-17 15:18:31 +00:00
sta 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 (usrbuf),y move data from user's buffer
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 usrbuf+1 but first adjust user buffer pointer
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
eor datptr+1 (carry is undisturbed)
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
eor datptr+1 adjustment of request count
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
2019-10-16 06:09:13 +00:00
inc usrbuf+1 inc pointers
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 usrbuf
sta usrbuf
bcc L4564
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
inc usrbuf+1 adjust high address as needed.
2020-05-13 17:00:37 +00:00
2019-10-16 06:09:13 +00:00
L4564 jsr fcbused set directory flush bit.
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
2019-10-16 06:09:13 +00:00
jsr gfcbstyp get storage type
* 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 fcbptr make newly allocated block the current
2020-07-17 15:18:31 +00:00
sta FCBs+FCB.IBLK+1,y index block.
2019-10-16 06:09:13 +00:00
txa
2020-07-17 15:18:31 +00:00
sta 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
*--------------------------------------
zeroindex lda #$00
tay
L3F30 sta (zpt),y zero out the index half of the user's
iny i/o buffer
bne L3F30
2020-05-13 17:00:37 +00:00
2020-09-19 16:48:28 +00:00
inc zpt+1
2019-10-16 06:09:13 +00:00
2020-09-19 16:48:28 +00:00
L3F37 sta (zpt),y
iny
bne L3F37
dec zpt+1 restore proper address
rts
*--------------------------------------
2019-10-16 06:09:13 +00:00
sapdown jsr gfcbstyp find out if dealing with a tree.
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
2019-10-16 06:09:13 +00:00
ldy fcbptr get previous first block
2020-07-17 15:18:31 +00:00
lda 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
2020-07-17 15:18:31 +00:00
sta FCBs+FCB.1stBLK,y
lda FCBs+FCB.1stBLK+1,y
2019-10-16 06:09:13 +00:00
pha
lda scrtch+1 and high address too
2020-07-17 15:18:31 +00:00
sta FCBs+FCB.1stBLK+1,y
sta 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.
2020-07-17 15:18:31 +00:00
sta 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
2020-09-17 15:29:41 +00:00
inc 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
*--------------------------------------
alcwblk jsr alc1blk
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
2020-09-17 15:29:41 +00:00
inc FCBs+FCB.UBLK,x
bne .9
2020-07-17 15:18:31 +00:00
2020-09-17 15:29:41 +00:00
inc FCBs+FCB.UBLK+1,x
2019-10-16 06:09:13 +00:00
2020-09-17 15:29:41 +00:00
.9 rts
*--------------------------------------
2020-09-18 15:06:12 +00:00
tstwprot jsr XDOS.GetFCBStatus check for 'never been modified' condition
2019-10-16 06:09:13 +00:00
and #$F0
2020-09-17 15:29:41 +00:00
bne tstwprot.8 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
twrprot1 sta unitnum make the device status call
2020-09-17 15:29:41 +00:00
2019-10-16 06:09:13 +00:00
lda bloknml+1
pha
lda bloknml save the current block values
pha
stz A4L
stz bloknml zero the block #
stz bloknml+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
2020-09-17 15:29:41 +00:00
.1 plx
stx bloknml restore the block #
plx
stx bloknml+1
2020-05-13 17:00:37 +00:00
2020-09-17 15:29:41 +00:00
rts
2020-05-13 17:00:37 +00:00
2020-09-17 15:29:41 +00:00
tstwprot.8 clc
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