
Three more things a program does to files: throw one away, give one a new name, and change part of one without rewriting the rest.
The FCB names the file; function 19 marks each of its directory entries deleted by setting byte 0 to E5h - and nothing else. A is 0, or FFh if there was no such file. The data stays where it was until another file needs the blocks.
Rename needs two names in one FCB: the old one in bytes 0-15 as usual, and the new one from byte 16 - a drive byte (0) and then the name and extension. The BDOS renames every entry of the file, so all its extents keep together. N builds the second name in FCB2 and copies its first 16 bytes up.
Function 34 is S9's read random the other way round: record number in bytes 33-35, the record at the DMA address, and only that record is written. A record past the end makes the file longer. Close afterwards, as always, so that the directory knows.
After the line JP Z,CMDW, add:
CP 'E'
JP Z,CMDE
CP 'N'
JP Z,CMDN
CP 'P'
JP Z,CMDP
After the last line of TR3 (RET), add:
; E name: erase a file.
CMDE: CALL NEEDDOS
LD DE,FCB
CALL GETNAME
JP C,WHAT
LD DE,FCB
LD C,19
CALL 5
CP 0FFH
LD HL,NOTFM
JP Z,DONE
LD HL,ERASEM
JP DONE
; N old new: rename. The new name goes in FCB bytes 16-31.
CMDN: CALL NEEDDOS
LD DE,FCB
CALL GETNAME
JP C,WHAT
LD DE,FCB2
CALL GETNAME
JP C,WHAT
LD HL,FCB2
LD DE,FCB+16
LD BC,16
LDIR
XOR A
LD (FCB+16),A ; the new name's drive byte: 0
LD DE,FCB
LD C,23
CALL 5
CP 0FFH
LD HL,NOTFM
JP Z,DONE
LD HL,RENM
JP DONE
; P name n text: write the text as record n, with write random.
CMDP: CALL NEEDDOS
CALL OPENIT
CALL GETNUM
JP C,WHAT
LD (FCB+33),HL
XOR A
LD (FCB+35),A
CALL TEXTREC
LD DE,RECBUF
LD C,26
CALL 5
LD DE,FCB
LD C,34 ; write random
CALL 5
LD DE,FCB
LD C,16
CALL 5
LD HL,WROTEM
JP DONE
After the line WROTEM: DEFB 'WRITTEN',13,10,0, add:
FCB2: DEFS 36
ERASEM: DEFB 'ERASED',13,10,0
RENM: DEFB 'RENAMED',13,10,0
Run it on a fresh work.mfi made from PRIMER.DSK (S10):
W 1:SCRAP.TXT GONE SOON
E 1:SCRAP.TXT
N 1:ROOMS.DAT PLACES.DAT
P 1:POEM.TXT 2 THE END.
T 1:POEM.TXT
Q
What you should see
> W 1:SCRAP.TXT GONE SOON
WRITTEN
> E 1:SCRAP.TXT
ERASED
> N 1:ROOMS.DAT PLACES.DAT
RENAMED
> P 1:POEM.TXT 2 THE END.
WRITTEN
> T 1:POEM.TXT
THE DISC
Forty tracks go round and round,
ten sectors on each one;
the directory shows what can be found,
and blocks say where they've gone.
Ask the DOS and it will look
the name up for you, line by line;
or read the sectors like a book
and all tTHE END.
3 RECORDS
>
Record 2 of POEM.TXT - the last third of the poem - is now THE END.; records 0 and 1 are untouched. In a fresh start of MAME with the same work.mfi:
0:DIR 1:
1: POEM .TXT : PLACES .DAT
1: DISKMON .COM
30k Size, 158k Free, 190k Total
0:
E a file, then look at the directory sector with edisc.py dump after.dsk 2 0 (after mfi2dsk.py). Which byte of its entry changed?P 1:POEM.TXT 5 MORE writes past the end. What record count will O 1:POEM.TXT show afterwards - and what is in records 3 and 4?Function 19 deletes (status byte E5h), 23 renames every extent, 34 writes one record anywhere. With S10 that is everything a program needs to keep its own files.
S12: what DISKMON can - and cannot - do when the BDOS says no.
This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.