Using Random Files (Advanced); Chapter 8: Internal Disk Commands - Commodore 1541 User Manual

Hide thumbs Also See for 1541:
Table of Contents

Advertisement

EXAMPLE:
To free the sector in which we wrote our name in the Block Write
example,
and
allocated in the first Block-Allocate example, we could use the following
command:
PRINT#l5,
"B-F";O;l ;l
USING RANDOM FILES (ADVANCED
U~ERS
ONLY)
By combining the commands in this chapter, it is possible to develop a
file.
handing program that uses random files. What you need to know now is how
to
keep track of which blocks on the disk such a file has used. (Even though you know
a sector has not been allocated by your random file, you must also be sure it wasn't
allocated by another unrelated file on the diskette.)
The most common way of recording which
sectors
have been used by a random
file
is
in a sequential file. The sequential file stores a list of record numbers, with the
track,
sector, and byte location of each record
.
This means three channels are needed
by a
random file: one for the command channel, one for the random data, and the last
for the
sequential data.
72
CHAPTERS
INTERNAL DISK COMMANDS
Expert programmers can
give commands
that directly
alter
the
workings of
the 15~ I,
h
as skilled programmers
can alter
the workings
of
Basic
inside
the
computer
with
mucks
Pokes and Sys
calls.
It is also possible to write machine language prograivs that
~
a'nd run
entirely
within the
_
1541
,
either
~y writ~ng
them
in~o dis~
memory from the
Pu ter
or by londing them directly from diskette into the desired
disk
memory buffer.
com
.
.
·
Se this is
similar
to loading
and
running machine language programs in
your
In u
computer.
.
.
.
As when learning to use Peek()
,
Poke and
Sys
in
your computer, extreme caution
is
advised in using the commands in this
chapter.
They
~e
essentially
machine language
commands,
and lack all of
Basic's
safeguards
.
If
anyth1~g
goes wrong
..
you
may have to
the
disk drive
off
and on again
(after
removing the diskette) to regain
control.
Do not
WC:tice
these commands on any
important
diskette
. Rather,
make
a
spare
copy
and work
~th
that.
Knowing how to program a 6502 in machine language
will
help
greatly, and
you will
also need a good memory map
of
the 1541
.
A brief 1541 map
appears
below
.
Location
0000-00FF
0100-0IFF
0200-02FF
0300-07FF
1800-ISOF
lCOO-ICOF
Cl00-F258
F259-FE66
FE67-FE84
FE85-FEE6
FEE7-FFOF
FFE6-FFFF
1541 MEMORY MAP
Purpose
2K of RAM
memory
Zero page work
area:
job queue
,
important
variables & pointers
Stack work area
Command buffers &
tables:
channels,
parser, output,
variables
Data buffers 0-4, I per page of memory
.
lnput/Output chips
6522 VIA: I/O to
computer
65f2
VIA:
I/O to disk controller
Two
SK
Disk Operating System
ROMs
Interface
Processor:
receive
&
interpret
commands from computer
Floppy Disk Controller:
executes
IP's
commands, controls
mecha-
nism
IRQ
handler:
switches
from IP to FDC
&
back
every
10 ms
.
ROM tables
&
constants
Patch area
JMP
table:
User command vectors
73

Advertisement

Table of Contents
loading

Table of Contents