EasyManua.ls Logo

Commodore 1541-II - Freeing Blocks

Commodore 1541-II
104 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
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.
100OPEN15,8,15
110OPEN5,8,5,"#"
120
PRINT#5,"I
THINK
THEREFORE
I
AM"
130T=l:S
=
l
140
PRINT#15,"B-A";0;T;S
150
INPUT#15,EN,EM$,ET,ES
160
IF
EN
=
0
THEN
210
170
IF
ENO65
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
200
T =
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
DOS.
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
#
where
"drive
#"
is
the
drive
number
(always
0
on
the
1541),
and
"track
#"
and
"sector
#"
are
respectively
the
track
and
sector
numbers
containing
the
desired
block
of
data
to
be
read
into
the
file
buffer.
ALTERNATE
FORMAT:
PRINT#15,"B-F:";drive
#;track
#;sector
#
71

Table of Contents

Related product manuals