You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
FALL <strong>1980</strong><br />
THE APPLE ORCHARD<br />
PAGE 51<br />
stage of INIT, why bother with the<br />
data block at all Instead, RWTS<br />
simply fills enough disk space with<br />
$FF's to allow room for a data block.<br />
Then RWTS proceeds on to the<br />
next sector. Since the fake data<br />
block just written has no beginning<br />
marks, the DOS won't be able to<br />
find data in the sector. Therefore an\<br />
initialized sector can't be read (1/0<br />
ERROR) until properly written to.<br />
As far as DOS is concerned, there's<br />
absolutely nothing there.<br />
Once a sector gets formatted,<br />
RWTS goes on to format the next<br />
sector. As you might expect by<br />
now, sectors aren't put on the disk<br />
in a straightforward linear fashion<br />
(0, 1, 2, 3 ... ). Instead they are interleaved<br />
(0, 10, 7, 4, 1, 11, 8, 5, 2, 12, 9,<br />
6, 3) to give the computer thinking<br />
time between sectors, DOS uses<br />
this time to handle data encoding<br />
and decoding, as well as to find out<br />
what sector to process or command<br />
to interpret next. Thus sector 2 is<br />
actually four sectors behind sector<br />
1. Reading an entire track actually<br />
takes four revolutions of the<br />
diskette rather than one (.13 sec vs.<br />
.03 sec).<br />
Once each sector has been formatted<br />
on a track, RWTS's formatter<br />
performs a quick check to<br />
insure that the next sector coming<br />
past the read head is really sector<br />
zero. If sector zero wasn't there,<br />
then RWTS must have gotten its<br />
timing wrong, so it adjusts the<br />
number of timing bytes between<br />
sectors and starts over. When sector<br />
zero can be found on cue, the<br />
timing is correct. Then RWTS<br />
moves on to the nex-.t track.<br />
After formatting all tracks, INIT<br />
returns to command level DOS.<br />
There, the DOS copies itself out<br />
onto the diskette, writes out a<br />
catalog, a Volume Table Of Contents,<br />
or "VTOC", and executes a<br />
"SAVE" command for the Hello<br />
program. The entire initialization<br />
takes two to three minutes or more,<br />
depending on the length of your<br />
Hello program.<br />
There are several places in the<br />
format routine to cut corners and<br />
get away with it. The first place that<br />
springs to mind is the routine which<br />
calibrates the read/write head to<br />
track 0. Adventurous souls can try<br />
POKEing new numbers into 48801<br />
($BEA1) to see what happens; just<br />
keep the number above 35. I've<br />
seen too many instances where the<br />
drive's head only hit the stop once<br />
or twice to muck about here. On<br />
most systems the maximum time<br />
savings would only be about five<br />
seconds, anyway.<br />
Another, safer number to change<br />
is the number of timing bytes which<br />
begin each sector. When first formatting<br />
track 0, RWTS puts 60 bytes<br />
between each sector. This is clearly<br />
too much to fit onto one track<br />
causing the last sectors to overwrite<br />
sector 0. An error handling routine<br />
decrements the number of timing<br />
bytes by one and tries again. If the<br />
number of timing bytes falls below<br />
16, the error handler will quit with<br />
an error message. Normally the<br />
routine finds a number of timing<br />
bytes that works and sticks with that<br />
number for the rest of initialization.<br />
A well-adjusted drive will have<br />
about 40 timing bytes between<br />
each sector, so you can speed<br />
things up by starting the countdown<br />
with a lower number. Try<br />
POKE 48817,48 ($BEB1 :30). Fortyeight<br />
bytes will work with any disk<br />
drive within 30 speed units of zero<br />
as measured on <strong>Apple</strong>'s Disk Speed<br />
Adjust program. This change will<br />
shave about ten seconds from the<br />
beginning of INIT.<br />
Both changes so far have just<br />
nibbled at the speed problem. Now<br />
get ready for the Big Fix. Since the<br />
timing bytes between sectors<br />
together with the sectors themselves<br />
fill up each track, there's no<br />
need to erase the whole track<br />
beforehand. Rather, one need only<br />
erase enough to cover the gap<br />
between the end of the last sector<br />
(sector 3, remember) and the start<br />
of sector O's timing marks. POKE<br />
48821,4 does the trick ($BEB5:04).<br />
My own trials showed that any<br />
number less than four yields flakey<br />
disks that can't be trusted. This<br />
change, together with the preceeding<br />
one, cuts initialization<br />
time from two minutes to 45<br />
seconds.<br />
Another change to the DOS can<br />
speed up disk access, although it<br />
doesn't help speed INIT. The<br />
change must be effected prior to<br />
initializing a diskette for the new<br />
diskette to work faster, so I'll<br />
include it with the rest of this<br />
discussion on INIT.<br />
Remember our old friend, sector<br />
interlacing Well, it turns out that<br />
RWTS doesn't need all of that extra<br />
time to think after all. If you POKE<br />
48998,7 ($BF66:7) before initializing<br />
a diskette you will change the interleaving<br />
sequence from every<br />
fourth sector to every other sector.<br />
This effectively doubles machine<br />
level access to the disk. You won't<br />
believe how fast a disk created this<br />
way will boot, for example. Unfortunately<br />
much of the DOS itself is a<br />
very slow program, so you can't<br />
double the speed of everything.<br />
This interleaving change will help<br />
machine language access via RWTS<br />
tremendously. Access time through<br />
command-level DOS will only be<br />
improved 10%, however. Curiously,<br />
the alternate interleaving scheme<br />
seems to be the scheme originally<br />
intended by <strong>Apple</strong>. The formula<br />
given in the original Wozpak documentation<br />
support this interleaving<br />
scheme. However, the<br />
actual scheme used is the slower<br />
one described above.<br />
All is not lost if you still would<br />
like to read programs and data off<br />
the disk at a reasonable speed.<br />
Mark Pump (ABBS Illinois Microcomputers,<br />
Inc.) has discovered<br />
that by POKEing 48998,2 ($BF66:02),<br />
file read time can be speeded up by<br />
almost 30%. Boot time wil be<br />
slightly increased from normal,<br />
however. This interleaves the sectors<br />
such that any two consecutively<br />
numbered sectors are 180<br />
degrees apart on the disk. Evidently<br />
this interleaving synchronizes<br />
just right with the delays in command-level<br />
DOS. Any slave diskette<br />
created by a DOS containing<br />
the above changes will retain those<br />
changes for initializing its offspring.<br />
Everyone kn·ows that Language<br />
System disks pack data with higher<br />
density. There are many misconceptions<br />
about what changes were<br />
made. Since I'm discussing disk<br />
formatting, I might as well clear<br />
some up. Many people think the<br />
Language System achieves higher<br />
density by going from 256 byte to<br />
512 byte sectors. The 512 byte<br />
blocks used in Pascal actually are<br />
two 256 byte sectors grouped<br />
together by the Pascal operating<br />
system. On disk the sectors still<br />
represent 256 bytes. Unlike DOS<br />
3.2.1, however, each track has 16<br />
sectors instead of 13. Therefore the<br />
data in each sector must be denser.<br />
(continued on page 52)