Freeing Blocks - Commodore 1551 User Manual

Table of Contents

Advertisement

ALTERNATE FORMAT:
PRINT#15,"B-A:";drive #; track #;sector #
EXAMPLE:
If you try to allocate a block that isn't available, the DOS will set the error message
to number 65, NO BLOCK, and set the track and block numbers in the error message to
the next available track and block number. Therefore, before selecting a block to write,
try to allocate that block. If the block isn't available, read the next available block from
the error channel and allocate it instead. However, do not allocate data blocks in the
directory track. If the track number returned is 0, the diskette is full.
Here is a program that allocates a place to store a message on a diskette.
100 OPENI5,8, 15
110 OPEN5,8,5, "#"
120 PRINT#5,"1 THINK
THEREFORE I AM"
130T=I:S=1
140 PRINT#15,"B-A";0;T;S
150INPUT#15,EN,EM$,ET,ES
160 IF EN =0 THEN 210
170 IF EN<>65 THEN PRINT
EN ,EM$,ET ,ES:STOP
180 IF ET = 0 THEN PRINT
"DISK FULL":STOP
190 IF ET= 18 THEN ET= 19:ES=0
200T=ET:S=ES:GOTO 140
210 PRINT#15,"U2";5;0;T;S
220 PRINT "STORED AT:",T,S
230 CLOSE 5:CLOSE 15
240 END
FREEING BLOCKS
Open command channel
" direct access "
Write a message to buffer
Start at first track & sector
Try allocating it
See if it worked
If so, we're almost done
"NO BLOCK" means already allocated
If next track is 0, we're out of room
Don't allocate the directory!
Try suggested track
&
sector next
Write buffer to allocated sector
Say where message went
and tidy up
The Block-Free command is the opposite of Block-Allocate. It frees a block that you
don't need any more, for re-use by the OOS. Block-Free updates the BAM to show a
particular sector is not in use, rather than actually erasing any data.
FORMAT FOR BLOCK-FREE COMMAND:
PRINT#15,"BLOCK-FREE";drive #;track #;sector #
abbreviated as: PRINT#15,"B-F";drive #;track #;sector #
61

Advertisement

Table of Contents
loading

Table of Contents