EasyManua.ls Logo

Commodore VIC-20 - Page 286

Commodore VIC-20
404 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...
272
The
VIC
20
User
Guide
Here
is
the whole BLOCK-READ program.
10
OPEN
15,8,15
20
OPEN
2,8,4,
"tI"
30
INPUT
"TRACK";
A
40
INPUT
"SECTOR";
B
50
PRINTtU5,
"B-R: "4;
9;
A;
B
60
OEnt2,
AI
70
IF
ST-0
THEN
PRINT
A$;:
OOTO
60
80
CLOSE
2:
CLOSE
15
BLOCK-ALLOCATE
The BAM keeps a record of all blocks
that
have been allocated (contain
data). In the higher-level instructions (SAVE and so forth) the DOS (Disk
Operating System) uses this information to determine where data can be
written on the diskette.
When you are using the direct-access functions, however, the DOS does
not use the BAM and you can write anything into any block on the diskette,
whether or not it already contains data. You can write data anywhere, even
over the directory and BAM,
but
you should avoid this. You can lose
normal access to everything on your diskette if you write to it indiscrimi-
nately.
It
is
therefore advisable to perform a BLOCK-ALLOCATE instruc-
tion before attempting to write a block.
The BLOCK -ALLOCATE instruction checks a sector to determine if it
already contains data.
If
it
is
available (as indicated in the BAM), it marks
the sector as allocated.
If
it
is
already allocated, it leaves the BAM
unchanged and indicates the next available sector in the error channel.
Here
is
a routine to perform a BLOCK-ALLOCATE.
10
OPE~l
15,
a,
15
20
INPUT
"TRACK";
A
30
INPUT
"SECTOR";
B
40
PRINTtl15,
"B-A:"0;A;B
The components of the BLOCK-ALLOCATE instruction are as follows:
PRINT#15. activates the command channel
"B-A:"
is
the BLOCK-ALLOCATE instruction
o
is
the drive number
A
is
the track number
B
is
the sector number.

Other manuals for Commodore VIC-20

Related product manuals