Text content (OCR)
Open-Apple
Releasing the power to everyone.
June 1985
Vol. 1, No.5
Up where Applesoft lives
Hiking boots and backpacks, please. Fill your water bottles. This month
we're going ona trek to the high reaches of your Apple's memory. There have
been some changes up where Applesoft lives and an expedition is in order.
First let’s get our bearings. The machine language instructions that tell
your Apple's microprocessor everything it knows about Applesoft appear in
memory from byte $D000 (53248) to byte $F7FF (65487). The 10,240 bytes
of code in this area first appeared in 1979, when the Apple II-Plus was
introduced. They remained untouched — totally unchanged —for five years.
‘Then the Apple IIc appeared in 1984 and suddenly there were differences.
More changes showed up in the enhanced Ile, which Apple introduced in
March.
On this month's outing we are going to take a close look at these three
versions of Applesoft and determine exactly what the differences are. It isn't
necessary that you have your own maps of the territory — there is little doubt
that we will return home safely—nonetheless, if you'd like to make some,
here's how,
Basic map making. To make maps, you'll need to get momentary access
to the two types of computers you don't already have. If you have a Ile, for
example, you'll need to momentarily borrow the neighbor's IIc and the
school's new enhanced Ile. Boot the borrowed computer with standard DOS
3.3. Don't use ProDOSand don'tuse a version of DOS 3.5 that moves itselfto
the upper reaches of memory. Then simply take a snapshot of Dr. Basic by
BSAVEing the image of Applesoft in the borrowed machine. Here's how:
BSAVE TIC APPLESOFT IMAGE, ASD000, 82600
The reason you don’t want to boot with ProDOS (or a version of DOS 3.3.
that moves Itself) is that it will spoil your picture. Instead of Dr. Basic’s gruff
visage you'll get a smiling image of Uncle DOS.
Ifyou havea Ilcor an enhanced Ile and a DOS 3.3 System Master disk, you
don't even have to borrow a II-Plus or Ile, The original image of Applesoft
appears on the System Master disk in a file called FPBASIC. (On old System
Master disks, this fileis 50 sectors long—it includes an image of the Monitor
as well as Applesoft. On newer System Masters, it is 42 sectors long and
includes only Applesoft.)
Once you have your images, you make maps like this:
JBLOAD I1C APPLESOFT IMAGE, A202
JCAL -151
(Load image at $2000.)
(Enter Monitor.)
+2000<0000.D010V (Verify that the first few bytes
are Identical.)
*PREL
#2000¢0000.F7FFV
(Turn on printer.)
(Use the Monitor's Verify command
to get a list of the differences
between the image at $2000 and
the one built into your Apple.)
Ifyou get alist of discrepancies from the first Verify command, you've done
something wrong — don't print or you'll waste a ton of paper. Just start over.
The second Verify command will send a listing to your printer of the
differences between the borrowed Applesoft image you have loaded at
$2000 and the Applesoft image built into your machine. The listing will show
you the address of each discrepancy, the value at that byte in your built-in
‘Applesoft, and, in parentheses, the value at that byte in the image loaded at
$2000, For example, if you do this on a llc with the FPBASIC file from a
System Master disk, your listing will begin like this:
2000<0000.F7FFV
0034-F4 (74)
0035-03 (F?)
Dode-F4 (6B)
DosF-03 (F3)
The listing will go on for several pages. There are 384 bytes of differences
(6 printed pages) between FPBASIC and IIc Basic; 326 bytes of differences (6
pages) between the enhanced Ile and the lic versions; and 179 bytes of
differences (3 pages) between the enhanced Ile version and the original
FPBASIC. As a percentage, the differences between the three versions are
quite minor —at most, less than 4 per cent of the original Applesoft image is
changed.
Ampersand valley. As we begin our little amble, the first features we come
upon are those between $D034 and $DO6F, as shown above. (In assembly
language language, we say those addresses are on “page” $D0. In this way of
looking at things, the Apple II has 256 pages of memory, $00 through SFF,
and each page holds 256 bytes. The first two hexadecimal digits of an
address point to the page, the last two to the byte.) This particular area of
Applesoft is a table of addresses. The addresses point to the machine
language routines that actually execute the various Applesoft commands.
Atthe very back of Saveload Cave there is some strange new code.
The changes here affect the commands SHLOAD, RECALL, STORE, LOAD,
and SAVE. The thing these commands have in common are that they are all
cassette tape commands, You are probably more familiar with LOAD, SAVE,
and Basic.system’s STORE as DOS commands. When you put a filename
after these commands, Uncle DOS recognizes and executes them. If you
leave off the filename, Uncle DOS passes the command on to Dr. Basic, who
starts fiddling with the cassette tape jacks.
Since no one in their right mind uses cassette tape for storage anymore,
these commands are pretty useless. Worse than useless, really, because
when you execute them by mistake (by forgetting to put a filename after a
DOS command), your Apple will appear to hang, It's not really hung, of
course (Dr. Basic is purposefully fiddling), but it might as well be since you
have to press Reset to recover.
The IIc doesn’t have cassette tape jacks, so the code that executes these
commands was removed from the lic. As we'll see later, the space was used
for something else. However, though the code that executes the commands
was removed, the commands themselves are still there. The changes on
page $D0 point all five of them to the execution address of the ampersand
42 Open-Apple
(&) command. This gives assembly language programmers the possibility of
easily implementing six ampersand commands on the. llc. (To discem
between the six, an ampersand routine can refer to bytes $B8-$B9; they point
one byte beyond the token of the command that caused the ampersand
routine to be executed. The tokens you will find are:
A token table (for assenbly language prograsners only)
sHLOAD $98 ono $86
RECALL $87 SAVE 587
STORE $A6 2 SAF)
The enhanced Ile continues to support cassette tape, so there are no
changes in this area in an enhanced Ile’s Applesoft.
Lower-case Creek. The next discrepancies are on pages $D5, $D6, and
$D7. Scattered through this area are 21 bytes of differences. This part of
Applesoft contains the routines that parse (try to make sense of) your
commands. Also here are the routines that create program listings in
response to the LIST command. Most of the changes in this area consist of
hooks inserted into the command parser that cause new sections of code,
stored elsewhere, to be executed during the parsing process. This new code
allows lower-case input.
The changes are pretty intelligent. Ifyou enter programs in lower case ona
lic or an enhanced Ile, you'll find when you LIST the program that com-
mands and variable names have been converted to upper case. However,
stuff inside quotation marks, REM statements, and DATA statements will not
be. For example:
110 print “Open-Apple ¥:" + data June 1985 : rem issue date
hist
1 DATA June 1985
10 PRINT “Open-Apple REM issue date
This sample also illustrates the effect of the other changes in this area, but
they are more subtle. One of the patches causes program listings to begin
with a blank space. This makes “escape mode editing” much easier, since it
is no longer necessary to backspace over the line number. (Escape mode
editing involves pressing the escape key, followed by either the arrows or the
letters in the I-J-K-M diamond, to move the cursor to the beginning of the
Basic line you want to edit, pressing the space bar, and then using the right
arrow to re-enter the line.)
The final change allows Basic program listings to be 80 columns wide
when the Apple 80-column mode is turned on.
Saveload Cave. The next changes occur on pages $D8 and $D9. In the
original Applesoft, this area contained the routines that executed the
cassette SAVE and LOAD commands. On the enhanced He this area is
unchanged. On the IIc, however, the cassette routines have been removed. In
their place are the routines that perform lower-case and LIST conversions,
‘The hooks we lookedat earlier on pages $D5 through $D7 all point here ona
le.
At the very back of Saveload Cave, from $D8DD to $D911, there is some
strange new code. Itlooks kind of scary, so let's move right along...
Commatab Ridge. Proceeding onward, we next come to a series of
changes on pages $DA and $DB, This area of Applesoft has the code that
executes PRINT statements.
Under the PRINT umbrella are three functions for formatting output that
lots of people forget about. They are TAB(, SPC(, and comma tabbing, Not be
confused with HTAB and VTAB, these functions can only be used within a
PRINT statement.
The changes in this area of Applesoft fix these functions so they work on an
80-column screen. On an 80-column IIc or enhanced Ile, each of the
following lines does the same thing:
100 PRINT "THIS". “IS", “
11@ PRINT “THIS; SPC(12); “15
3 SPC(AS); “TEST.~
120 PRINT "THIS"; 198(17); “IS 3 TAB 49); “TEST.
RUN
THIS 15 A Test.
THIS 15 a TE:
THIS Is a Test.
Comma tabbing means using commas, rather than the usual semicolons,
between items in a PRINT statement. The items will be printed beginning in
columns 1 17,33, 49,and 65, as long as each item is less than 16 characters
long. Longer items cause columns to be skipped:
100 PRINT “THIS IS TEST NO™.2
110 PRINT “THIS IS TEST NO.”
Vol. 1, No.5
RUN
THIS IS TEST NO 2
THIS IS TEST NO. 2
The SPC( function prints the specified number of spaces. Note that the
value inside the parentheses can be a variable or a formula, as well as a
number. The TAB( function is similar, but it moves the output position to a
specified position on the output line.
Double-Low Forest. We are now approaching the most mysterious part
of our expedition. There are a number of changes upcoming in the IIc
version of Applesoft that, to the best of my knowledge, have never been
documented anywhere. Not by Apple itself, not by other writers, Firstthough,
climb up this small hill here and look ahead to byte $006.
The seven bytes at $000 to $£006 contain the start-up addresses for
Basic and an identification byte. A call to 57344 ($£000) coldstarts Basic
(this erases any program in memory). A call to 57347 ($E003) warmstarts it.
At57350 ($£006) there isa version identification byte that is never executed
or otherwise used for anything. Its contents are:
Contents of byte 57350 (3£006)
I1-Plus and original Ie @ (320)
Me 137 (389)
enhanced Ie 196 (804)
Now just in front of us, at bytes $DF03 and $DF04, isa change that causes
the IIc’s SCRN function to execute some new code stored elsewhere. SCRNis
one of Applesoft’s low-resolution graphic functions — it retums the screen
color at a specified coordinate. Up ahead, on pages $F 1, $F2, and $F3, area
number of other changes, in the IIc version only, that point to new code,
‘These pages hold the code that executes the low-res GR, PLOT, HLIN, and
VLIN commands. Have you ever heard anything strange and wonderful about
the IIc’s low-resolution graphics commands? Let's study these things more
Closely on our return trip.
Storerecall Cave. Forging ahead, we next come to Storerecall Cave, also
in page $F3. This is where the cassette tape commands STORE and RECALL
live in the original and enhanced Ile versions of Applesoft. In the IIc version,
however; well, poke your head in—you'll see that this is where someone has
stored all the new code that the low-res commands now use.
Shloadhtab Cave. The final area of differences is on page $F7. The first
part of this area is home to the cassette command SHLOAD in the original
I-Plus Applesoft. The last 25 bytes or so belong to HTAB.
What can be confusing is that there are three “caves” in the IIc version of
Applesoft, all formed by removing the code that executes cassette tape
commands— but there is only one cave on the enhanced Ile. You may
wonder how even this cave was hollowed out, since the enhanced Ile still
supports the SHLOAD command,
Aclose examination of the machine language code at $F775-F786 reveals
that SHLOAD was pushed down a rabbit hole. Itnow lives below ground in the
area where the original Ile had diagnostic routines (invoked by pressing
solid-apple/control/reset). The enhanced Ile still does diagnostics, but not
as many as the original Ile.
This rabbit hole is an underground version of pages $C1 through $C7, the
area where the firmware on peripheral cards normally appears. SHLOAD
itself now starts at $C500. To access this area, you have to throw the
“SLOTCXROM" softswitches. A poke to $C007 (49159) lets you see the
underground ROM in this address range, a poke to $C006 (49158) lets you
see what's on peripheral cards. (By the way, Table 6-5 in Apple's Ile reference
manual, page 133, has these softswitches backwards.)
Come back to the main level now and walk all the way back to the end of
this cave. Here, at the very top of Applesoft, we find some changes to the
HTAB command. The changes make HTAB work correctly in 80-column
mode.
An extremely interesting feature of the HTAB modifications is right at the
end of Applesoft—byte $F7FE. On the Ilc, this byte holds the code for the
assembly language command “branch always.” This is one of the new
commands only available on the 65C02 microprocessor — the earlier 6502
doesn’t support it. Of course, the 65C02 is built into the IIc, thus you would
expect it to use some of the new commands, The strange part is that on the
enhanced Ile, this byte holds the command for “branch on not equal,’ which
also happens to work here. But this is an old instruction — available in the
standard 6502 command set—even though the enhanced Ile also has the
newer 65C02.
Thinking back, however, you'll be hardpressed to remember seeing any of
the new 65C02 commands in enhanced Ile Applesoft. That's because there
Downloaded from www.Apple2Online.com
dune 1985
aren't any. I've been told there aren't any in the rest of the enhanced Ile
firmware, either, though I haven't checked that out myself. If Apple doesn’t
use the new 65C02 commands in the software that’s built into the machine,
who do you suppose will use them?
Let's go back now to the front of this cave. With SHLOAD out of the way—
simply gone on the IIc and down the rabbit hole on the enhanced Ile—we
find the cave filled with different things depending on which computer we're
looking at. The enhanced Ile has all the lower-case and LIST patches in this
cave. On the IIc, we found these earlier, in Saveload Cave.
The Double-Low-Res Spectacular, On the IIc, this area contains still
more changes to the low-res graphics commands. To find out what these
changes are all about, let's return to the Double-Low Forest and Storerecall
Cave. A very interesting little routine lies at $F3CB on the lic. It is called from
several different places in the new code. This routine reads an undocu-
mented softswitch at$C079, as well as softswitches that indicate whether the
80-column screen is being used.
Alittle experimentation with the unknown softswitch at $CO79 shows that
it indicates whether the IIc’s double-resolution graphics have been tumed
on (high bit set, single-resolution; clear, double-resolution). According the
llc reference manual's Table 5-8, the softswitch for this is supposed to be at
$CO7F not $C079; both addresses seem to work, however — on the Apple lic.
On Iles, both original and enhanced, these softswitches don’t exist.
The routine we have under the microscope, the one at $F3CB, retums with
the cany set if both double-resolution and an 80-column screen display are
tured on; the carry is cleared otherwise. By looking at the routines that call
this one, we can ascertain that they appear to allow the low-resolution
graphics commands to work in an 80 by 48 mode if double-resolution
graphics are tumed on. But there is no built-in command to invoke this new
mode,
Ifyou have a Ilc, try this series of commands:
PRES (turn on the 88-colum screen)
POKE 49246,0 (turn an double-resolution graphics)
aR (start-up low-res graphics)
coLor=3 (set colar to sorething other than black)
PLOT 50,10 (place a pixel at column $0, line 10)
X=SCRN(52, 10) (capture color at 50,10 in X)
HLIN 6,79 AT 20
VLIN 0,39 AT 40
Now how do you like that? Here's a completely new graphics mode,
complete with Applesoft support, and Apple's manuals don't breathe a
word about it.
Since it's probably been awhile since most of you worked with low-
resolution graphics commands, here are some tips for experimenting with
this new mode. First, don’t forget to set the color to something. If you
forget to use the COLOR command, your PLOTs and LINs will be invisible.
‘You'll insist there isn‘tany such thing as double-low-resolution graphics, but
there is. Second, beware of putting an E at the end of the HLIN and VLIN
commands. Ifyou do, Applesoft thinks the E isa variable and draws all lines
beginning at whatever value E is (usually zero).
The primary advantage of double-low-resolution graphics, compared to
the high-resolution graphics that Applesoft also supports, is that double1ow
supports sixteen complete colors rather than the six sort-of available in hi-
res, Of course, double-high graphics can also do 16 colors (at 140 by 192
resolution), but Applesoft can’t help you with that—it has no double-high-
resolution commands.
A Double-Low Bug, The spectacular, hidden double-ow-resolution
graphics routines in the Apple Iiceven havea spectacular, hidden bug, Since,
in our graphic try-out earlier we said COLOR=3, and since we did a PLOT
50,10, the X=SCRN(50,10) command should have set X to 3. But now enter
PRINT X. You'll find it equals 2. Try this:
10 444 SERN Tester 1X
(draw @ Line acrass the screen)
(rau a Line dosn the screen)
100 GR
11@ COLOR=S
120 HLIN 8,20 AT 10
150 FOR 1-@ TO 20 : PRINT SORN(I,10);" *; :
When you run this program it gives youa series of fours and fives. Itshould
give you a series of fives without fours. The SCRN command doesn’t work
right in double-low-resolution. The reason is pretty complicated. It begins
with the fact that doubleJow-esolution color bytes that are stored in the
auxiliary display page have to be rolled one bit to the right to compensate for
some shortcomings in the Apple's color abilities. The new SCRN code has to
Next
Open-Apple 43
take this into account when fetching values from the auxiliary page, and it
does. Except that it shifts left when it should roll left (this is assembly
language talk, for those of you who are puzzled by this paragraph). Conse-
quently, SCRN always gets odd-numbered colors wrong when they are stored
in the auxiliary display page.
Since we've gone this far, we might as well fix it, don’t you think? Try this
little program:
10 REN #*# Applesoft Tune-up 1¥
VIRB 12 : PRINT “Just a minute here...
+ X=PEEK( 49281)
100 TEXT : HONE =
110 X+PEEK (49281)
+ PRINT
+ REM read fron $0000-SFFFF ROK, urite to RAM
129 FOR P=208 TO 255,
+ PRINT “Working on page “iP
(OR B=0 TO 255
B+ {P¥256)
POKE. T,PEEK(I)
NeXT
178:
180 NEXT
190 X=PEEK(49283) : X+PEEK(49283) : REM read RAM (suitches to RAM Applesoft)
200 POKE 63415,42 : REM change ASL to ROL
This program works by loading a copy of Applesoft into the “language
card” area of memory. This area of RAM shares the address range normally
used by Applesoft and the Monitor. The softswitches that control this
memory allow reading and writing to be activated independently
APPLESOFT TUNE-UP takes advantage of this in lines 120 to 180. At first
these lines may makeno sense at all. What they re doingis copying Applesoft
and the Monitor from their normal home in ROM to the equivalent address
range in RAM. Line 190 then tums on the new RAM version of Applesoft, and
line 200 modifies it to fix the problem with the SCRN command.
Now try SCRN TESTER again.
Home again, home again, jiggidy jig. As we return from our expedition
to the high reaches of Apple memory, consider the things inside Applesoft
that Apple's wizards didn’tchange. While Applesoftis a pretty solid language,
it does have some bugs in it. The surprise is that none of them, not even the
easy ones, were fixed.
For example, there is a well-documented bug at $D970 that causes a
RETURN WITHOUT GOSUB error when there isn’t one (see ? Applesoft
Error, by Comelis Bongers, in Call -A.PP.L.E. in Depth #1: All About Apple-
Soft, page 100). On the one hand, I can understand Apple's reluctance to
make more changes inside Applesoft—compatibility problems could arise.
On the other hand, however, the bug at $D970 could be fixed by changing the
value of one byte. | don’t think that would cause many compatibility prob-
lems, There are several other changes like this that could have been made.
But now that we have our own private version of Applesoft in RAM, what
Apple did or didn’t do doesn’t make much difference. We can fix this bug and
make any other changes we like as well. How about adding a DLGR (double-
low graphics) command that does a POKE 49246,0 and a GR automatically?
Add these lines to the end of the APPLESOFT TUNE-UP program:
210 Cs="0570:86" =
218 GOSUB Soo
REM fix RETURN MITHOUT GOSUB problen
220 C$="D012:35 FB" : REM adr table position of TEXT, use Monitor to make space
225 GOSUB 500
230 C$="DeEC:98 FI" =
235 Gosue 500
240 C$="D18C:44 4C 47 02" :
248 GOSUB 500
250 C$="D9@E:AD $3 CO G8" : REM GR and DLGR patches
255 GOSUB Seo
260 C$="F390:AD SF CO AD SG CO 4C EC 08 AD SE CO 40 93 FI
265 GOSUB 500
280 PRINT CHRS(4);“BSAVE FPBASIC IIC.1, A30000, $3000”
230 END
900 C$=C$+" N DSCEG” : REM S.H. Lam routine
510 FOR I=L TO LEN (C8) POKE Sil+T, ASC(MIOS(CS,1,1})+128 : NEXT
520 POKE 72,0 : CALL -144 : RETURN
After running the complete APPLESOFT TUNE-UP, you'll be able to switch
between double-low-resolution graphics and regular low-resolution with the
commands DLGR and GR, ifyou have the 80-column screen active. (I tried to
make DLGR tum on the 80-column screen, too, but DOS gets disconnected if
you doit the easy way. To tell DOS what you're doing takes more space than is
readily available — this is no doubt why the equivalent of DLGR wasn't built
into Hc Applesoft.)
REM adr table position of LOAD, use for OLGR
REM change ‘LOAD’ to “DLGR’ in cad nane table
44 Open-Apple
The program will also save an image of the modified Applesoft and the
Monitor in a file called FPBASIC IIC.L The purpose of this file is to speed up
reloading this new version of Applesoft (APPLESOFT TUNE-UP itself takes
over two-and-a-half minutes to execute). Here’s how it works:
10 REM Load My Basic #*
100 TEXT : HONE : VIP 12 : PRINT “Just a minute here...” : PRINT
110 X=PEEK( 45281) : ¥=PEEK(49281] : REM cead ROM, urite RAN
120 PRINT CHRS(4);"BLOAO FPBASIC T1C.1"
190 X=PEEK( 45280) : REN read RAM
Nowsuppose you ran LOAD MY BASIC ona Ile or Ii-Plus. Could you use the
IIc version of Applesoft to add double-low-res Basic commands to an older
machine? Since the II-Plus doesn’t support double-resolution, it's out imme-
diately. A Ile would need a 65C02 microprocessor to execute [lc Applesoft, so
an enhanced Ile is a possibility. But it doesn’t work. The problem is our old
friend $CO79. This is the byte that indicates whether double-resolution
Graphics are active on a IIc. On a Ile it fips back and forth pretty much at
random,
Nonetheless, the techniques we've looked at here can be used on alle ora
64K II-Plus to make special versions of Applesoft. Just remember you have
touse an unrelocated version of DOS 3.3 to do these tricks. ProDOS uses the
language card for its own purposes, so with it there's no room for your
personal version of Applesoft.
If this sounds interesting to you, | suggest you contract $-C Software (PO.
Box 280300, Dallas, Texas 75228; 214-324-2050) and get their program
called SC Documentor ($50). Using the Applesoft ROMS in your computer,
this program creates a complete, well-commented, source code listing of
Applesoft. The code is put into files formatted for the S-C Macro Assembler.
Modifications are much easier when you don't have to disassemble every
line of code yourself. This article, for example, would have been unimagin-
able without the Documentor's help.
ACP/M Primer
by Jim Whitehead
Editor's note: I would like to write everything in Open-Apple myself, but
there are some things I just don't have time to investigate. When I find
something that's really good in one of these areas, I'l try to publish it for
you. CP/M is an example of something I don’t know much about, but lots of
Apple users are interested init. The following is the first article I've everseen
on CP/M that doesn't use the word “BIOS.” It is reprinted, with permission,
from the March 1985 issue of NEAT Notes, the newsletter of New England
Apple Tree (P.O. Box 2519, Wobum, Mass. 01888).
At last month’s NEAT meeting, there was an emphasis on CP/M. However,
since CP/M is by no means easy to learn, there may be many club members
who are totally in the dark about what went on, or who don’t know how to use
the stuff they picked up at the meeting, Therefore, here is aCP/M tutorial.
CP/Misan operating system, such as DOS 3.3 or ProDOS. However, CP/M is
different. DOS 3.3 and ProDOS were primarily designed to take advantage of
Applesoft, which is bullt into the Apple. CP/M, on the other hand, was
designed to be independent of any particular language. Thus, while DOS 3.3
and ProDOS contain special features for the sake of Applesoft, CP/M is only
concerned with operating the hardware of your system—the disk drives,
printer, modem, and other peripherals. The full name for CP/M indicates the
limits of its functions — Control Program for Microprocessors.
CP/M is software—a program —just as DOS 3.3 is software. This often
confuses Apple owners because they have to buy a piece of hardware—a
“CP/M board” —to use it. The reason for this is that CP/M is written in 8080
machine language, not the 6502 machine language native to the Apple II. To
run 8080 programs, you need an 8080 (ora more advanced Z-80) micropro-
cessor. Most CP/M boards give your Apple a Z-80 microprocessor on a plug-
in card. What the card does is allow its onboard Z-80 microprocessor to
converse with the Apple's I/O slots and memory while executing CP/M. Some
boards contain their own memory in addition to other built-in functions, but
their purpose is basically the same—to allow CP/M programs to run on an
Apple Il computer.
Why should you want to run CP/M applications? Because much of the best
software available for microcomputers, particularly for business applica-
tions, executes only on CP/M machines. WordStar cannot be run on a 6502,
nor is dBase I! available for un-CP/M’ed Apples. Microsoft's Multiplan even
works correctly with your Videx 80-column card when running under CP/M.
Vol. 1, No.5
(Under DOS 3.3, the screen is shifted to the left about 1/2 inch, and is very
annoying to work with.) This brings up another highlight of CP/M. If you have
an 80-column card, you seldom need to worry whether it will work with CP/M.
software. In fact, unlike DOS 3.3, under CP/M it's the 40-column users who
are discriminated against—a satisfying feeling for those of us who have
plunked down good money for an 80-column card just to be left stranded by
most programs. For these and other good reasons, CP/M is well worth
purchasing.
However, like most computer products that actually do the neat things
they're supposed to do, CP/M can't be fully utilized without plowing through
long manuals full of computerese and double-talk. This tutorial will attempt
to convey basic mental attitudes needed for using CP/M. ifyou start thinking
the CP/M way, leaming new programs and utilities becomesa snap. However,
CP/M does things in a manner that differs greatly from DOS 3.3, so you'll
need to throw out all of your preconceptions of how an operating system
should be.
The first radical change between DOS 3.3 and CP/M is the way disk drives
are named. Say goodbye to drive 1 and drive 2, all drives are letters now. Old
drive 1 becomes drive A: (the colon is very important) and drive 2 becomes.
drive B:, etc. Plus, since there are no slots in CP/M, a third disk drive in slot 5
(a DOS 3.5 Slot 5, Drive 1) would be called drive C:.
The next difference between DOS 3.3 and CP/M is the hardest one to take.
CP/M limits filename lengths to only eight characters. This often necessi-
tates the creation of mnemonic file names, such as PADDPROG instead of
PADDLE PROGRAM. This also brings up one major problem with CP/M— after
a oe ‘or so, who can remember what the mnemonics RTATR4 or LIPSTR
stand for?
CP/M does have one other part to its filenames, however, called the
extension. Thisisa three letter suffix tacked onto the main filename with the
glue ofa dot (.). File extensions are supposed to give some idea of what is in
the file. For example, text files from a word processor should have an
extension of .TXT, standing for text. Basic files automatically have a .BAS
added to them, and other applications usually have their own specific
extensions. The filename extension is the only means within CP/M of
differentiating between separate file types.
Afull filename in CP/M hasall of the elements just discussed, exactly in the
following order:
{erive]f filenane} {extension}
In CP/M, the drive being referred to is placed before the filename, instead
of after it There is no" A:” syntax in CP/M like the “D1” syntax in DOS 3.3.0n
occasion, the beginning drive name can be omitted, thus automatically
referring to the default drive. Which one is the default drive? If you haven’t
figured it out by now, the CP/M prompt is significant. Upon booting up with
CP/M, the prompt is a “A>”. The “A” indicates the default drive, and the ">" is
for decoration. To change the default drive, type a “B:” (or any other valid
drive) at the CP/M prompt. (Make sure a disk is in the drive!) The default drive
is assumed every time you omita drive specification in a filename. Therefore,
if CP/M mysteriously can't find a file you know is there, check the disk drive
specified and make sure it wasn’t omitted.
Once the format for filenames is understood, the next most important
difference between DOS 3.3 and CP/M is the "=". In DOS 3.3, the "=" is often
used as a wildcard character, allowing any text to be automatically substi-
tuted in its place. In CP/M, the “*” is the wildcard character and "=" is used in
another way. It designates what file is to be acted upon and what file is to be
used in an action. As in the Basic statement A=A+ 1, in CP/M the "=" does not
indicate an equality, but tells the computer to "make these things equal.”
Following this definition, the "=" is interpreted as: make the first thing equal
to the second thing, The “things” are usually filenames.
In PIP, the FID of CP/M, the equality is straight. The second “thing”, a file on
adisk, is copied into the first “thing”, thus making them “equal”. In APDOS,
the DOS 3.3 to CP/M conversion program that comes with the Microsoft
Softcard, a straight equality is again made. The exception is that the first
“thing” is a CP/M file and it is made “equal” to the second “thing” by means
of a file conversion. Thus, while the “=” is used in both PIP and APDOS to
make an equality between files, what the programs are actually doing varies
tly.
oon let's look at some of the other frequently used CP/M commands.
Instead of CATALOG, CP/M has a DIR(ectory) command. This command is
entered in the form:
DIR {arive}{fitenane}
‘Typing DIR will catalog the default drive, typing DIR B: will catalog drive B:,
June 1985
etc. Typing DIR followed by a filename acts like the verify command under
ProDOS, simply demonstrating that a file exists.
Other useful commands are called using the format:
{comand} {filenane to act on}
These commands are:
TYPE—displays the contents of a .TXT or ASM file. (Or a file with any
extension, ifit contains text)
STAT—displays how much space a file uses on a disk. When called like
DIR, (i.e. STAT B:) itwill display only how much space is left on the designated
disk. This command also has many other functions, consult a manual for
more details.
ERA—Erases the filename specified. Type ERA *.* to completely erase a
disk of all files. In this example, the asterisks are wildcards and the default
drive is scrubbed.
As mentioned earlier, one program that is essential to using CPM is called
PIP (Peripheral Interchange Program). This program copies files from one
disk to another. It also has the ability to transfer files to the various devices
connected to your computer. Using PIP, a .TXT file can be transferred to a
printer or toa modem. For bare copying functions, use this program with the
like this:
PIP {roufite}=(oldFile}
This command gets PIP to copy oldfile onto newfile, just as our knowledge
of the "=" would indicate.
‘Another command that is used with the "=" is REN. REN is equivalent to
DOS 3.3's RENAME command, but it is called in a different fashion. With DOS
3.3, to change the name ofa file you enter RENAME {oldname},{newname},
and the file is renamed. To do the same thing under CP/M, you must enter
REN {newname}={oldname}.
‘There are many other commands available to CP/M. CP/M is limited only
by the machine it is running on. All CP/M files ending in “COM” are
commands. Hence, though syntactically PIP and REN are summoned the
same way, they are different because PIP is a COM’ file while REN is an
intrinsic command of CP/M. This is a powerful idea, for it allows a multitude
of commands to be added to and deleted from the CP/M vocabulary at will,
with only those commands that are necessary taking up precious memory
space.
Phe full power of this “nothing but the bare necessities” idea is evident in
Microsoft's MBASIC. This version of Basic is much more complex than
Applesoft and is a real joy to program in. Yet all of this extra power is
accomplished in less space than what Applesoft and DOS 3.3 take up. Disk
commands are a part of MBASIC, allowing easy programming with no
control-D’s and no machine language overhead devoted to interpreting
controFD’s.
For those of you who are unfamiliar with MBASIC, yet who want to run
MBASIC programs, here is a short explanation of how to get these programs
operating,
It is somewhat more difficult to start a Basic program under CP/M than
under DOS 3.3 and ProDOS. This is because you have to start up MBASIC by
hand, where Applesoft starts up automatically. To get an MBASIC program
running, you first have to boot CP/M. Then startup MBASIC. It's ina .COM file,
so just type "MBASIC’ at the CP/M prompt. After loading, MASIC will give a
weicome message and then print OK. Once you see this OK, you may place a
disk with programs on it in the other drive, drive B:. Then type:
LoAO “B: {program name}
‘There is no need toadd the BAS extension, as it will be done automatically,
but the quotation marks are essential. After the program is loaded, type
RUN’ to start it Use Control-C to exit a program at any time. Type “SYSTEM”
to get back to the CP/M prompt.
Ifyou don’t have two disk drives, the procedure is more complicated. First
you have to create a blank system disk. Then use PIP to copy both MBASIC-
“COM and the program you want to execute onto this disk.
‘Another thing that often confuses beginners is that while DIR is the
command for cataloging a disk from the CP/M prompt, inside MBASIC you
have to use another command. It goes like this:
FILES “B:”
Once again, the quotation marks are essential.
‘That wraps up this CP/M tutorial. Be aware that we have only scratched the
surface of CP/M here. Use this as a beginning. Consult at least two CP/M
books on points you are unfamiliar with. Two viewpoints often fill in what
each other missed. Good luck, and happy CP/Ming!
Miscellanea
‘The current version of AppleWorks is 1.2. Ifyou have an older version,
backup your disks and take the originals to your dealer and ask to have them
updated. Version 1.2 includes a way to modify printer interface card setup
strings and supports Apple's Scribe printer. Other changes are minor. Here
are some setup strings to try for various interface cards:
Printer interface card setup strings for Appleliorks
TyraciMicratek
Apple's oun cards
Grappler /Pxaso
Practical Peripherals
Apple surveyed software developers last August and the results,
though a little old already, are interesting, Apple sent its survey to 3,200
certified Apple II developers and 970—30 per cent—responded. At the
time, more respondents said they were developing software for the Apple II-
Plus than for the Apple llc. Over half the respondents said they were still
developing I!-Plus software and more than a third said they planned to
continue doing so.
Three times as many developers were using DOS 3.5 as either Pascal or
ProDOS. Basic was the development language used by most people, though
with first and second choices added together, assembly language nudged
into first place.
The most desired new features for the Apple II were larger floppies (29 per
cent), a faster microprocessor (19 per cent), and more RAM (10 per cent).
“Please indicate your feelings conceming 3-1/2 inch disk technology. Issues:
more capacity, no DOS 3.3 support, new disk media, compatibility” strongly
in favor, 48 per cent; neutral, 32 per cent; strongly opposed, 5 per cent.
Software Is a Cheap Business To Get Into —but Many Fail was the title
ofa recent Wall Street Journalarticle (April 29, page 21). The article gave the
results of yet another software developer survey —this one done by profes-
sors at the Georgia Institute of Technology. People who start software
companies are likely to be male, well educated, and optimistic, the survey
found. Most companies are started with a modest capital investment —more
than half the 193 respondents to this survey started with less than $10,000.
The researchers conclude that developing software for microcomputers is a
“dassic cottage industry.”
The article also quotes Beard Goldstein, a partner in a firm that special-
izes in software company mergers. Creating a new software product can’t
always be accomplished with lots of money and people, Goldstein says, The
ability to create new software is often lost at established firms, he contends,
because the talent that can do that has left or is occupied maintaining and
improving existing software. Often new products are developed by people
working in their spare time or in obscure businesses. Creating a software
product is like writing a book, Goldstein suggests. “If you consider what the
author ofa book receives if he is successful and what the successful software
author receives, | think the odds are better for the software author.’
lagree with Goldstein. would add that although stories abound of 13-year
olds who make a $100,000 a year selling software, precious few adult Apple I
‘software developers do anywhere near that well. However, you can make a
comfortable living at software development if you understand the impor-
tance and cost of marketing and you don't get greedy. Writing books, as
Goldstein suggests, is a pursuit best left to the independently wealthy.
Nibble magazine, long a profligate user of unpunctilious punctuation, is
primarily responsible for the shortage of exclamation points that is plaguing
the publishing industry. Nibble set a new record for computer magazines in
May when it used four (count’em—four!) exclamation points on its cover.
Many more were used inside. Publishing industry experts say it may be
months before exclamation point manufacturers are able to rebuild
supplies.
In Memoriam: Access: Apple, Time-Life’s newsletter for business users of
Apple computers, died with the May issue. Let us also momentarily bow our
heads for IBM's dreaded Apple I|-killer, the PC jr. It really was a peanut after
all.
contral-1 $9 N
control-I 8@.N
contral-1 @ N
control-1 N
46
Open-Apple
The customer is always right
Did you notice? Yes, the type is bigger in the front
section of this newsletter. That's because lots of
paying customers sald they couldn't read our old
type and because some wag reviewing Open-Apple
said the type was smaller than Epson's ultra-
condensed. I couldn'ttake it anymore.
Really quite expensive
Potential subscribers to Open-Apple, BEWARE! My
subscription has cost me $1,247.00. Because of arti-
cles in this crazy newsletter I have purchased a Sider
hard drive and Applied Engineering's RAMWORKS
with RGB.
Thave alle anda Il-Plus. | took the II-Plus to work to
prevent computer withdrawal. Is there anyway to trick
the IL-Plus into running AppleWorks? If so, then how
about getting it to take advantage of a 128K Saturn
card?
What do you suggest is the best way of backing up
the Sider in a fairly speedy and inexpensive way?
Gary Ward
Honolulu, Hawaii
If you think Open-Apple is expensive now, wait
until I review Apple's $7,000 LaserWriter printer. Don
Lancaster says it works better on a II running Apple
Writer than on the Macintosh.
I'm sorry about the dent in your wallet, but I think
you've made good choices, The ProDOS/Sider/Apple-
Works/RAMWORKS combination is the most signifi
cant thing to happen in the Apple Il world since the
He was introduced. Apple itself doesn’t push this
configuration because parts of it compete with
Apple's own present and future products. Few peo-
ple relying on the advice of dealers or the general
press will hear about it, either, Nonetheless, it
appears that thousands of experienced Apple users
are putting together systems like this and finding
themselves with more computer power than they
ever dreamed of.
Checkmate Technology (509 South Rockford Dr,
Tempe, AZ 85281, 800-325-7347) makes a $350 80/
160-column card that allows you to run AppleWorks
onalI-Plus. | have not tried the card, but lam inclined
to think that if your main goal is to run AppleWorks,
your $350 would be better spent making a down-
‘payment on another Ile or a lic. (You're right, this is
an expensive newsletter) II-Pluses are best used in
non-keyboard/screen intensive _tasks—making
copies of disks, running printers, and so on. I think
the future of the 1I-Plus sas a network controller, but
the required hardware and software hasn’t been
developed yet that | know of.
The Sider comes with a program for backing up
the DOS 3.3, CP/M, and Pascal areas of the disk.
Apple has a ProDOS program called Backup II,
which I got a review copy of sometime ago. Itseems
to wiork pretty well, however, it is currently only
available by buying Apple's Profile hard disk. If Apple
is smart they'll soon offer it separately, since few
people are going to pay $1,300 extra for a Profile just
to get it. It would make a great $40 to $50 stand-
alone package, however.
Breaking the AppleWorks barrier
Thave been using the data-base module of Appie-
Works for the past month and agree with your recent
comments regarding its usefulness. Extra memory
on a RAM card increases the size of the desktop, but
is there any way to increase the 1350 limit on the
number of records per data base file that AppleWorks
will accept?
Martin Kalman
Friday Harbor, Wash
Itouched on the solution in last month's issue, but
it's worth repeating —the current version of the soft-
ware that comes with Applied Engineering's RAM-
WORKS allows 4,283 records per file.
Interrupts and the sun
I'm working on a Basic program that uses a Thun-
derclock and an analog:to-digital conversion board
to periodically measure temperatures and pump sta-
tusin an open-loop solar collector system. Eventually
I'd like to get it into machine language so that I can
use interrupts to achieve foreground/background
operation but that's a ways down the road. I'd like the
display to be in80 columns but seem to getin trouble
whenever I read the clock or the a/d board. Is there a
way to read another slot and keep 80 columns with-
out refreshing the screen every time? I've been inter-
ested in Apple's Ile enhancement because I've read
they have finally fixed the byte $45 interrupt problem.
This aftemoon | read that ProDOS supports inter-
rupts on the regular Ile. What gives? Do I need the
enhancement or not?
Bill Stiles
Charleston, S.C.
To return to the 80-column card without clearing
the screen do this:
008 3.3
POKE 54,7 : POKE 55, 195 : CALL 1002
Prob0S
PRINT CHRS(4) :“PRURSCI07”
See the January issue (page 6) you want to know
how these tricks work.
Let's go through interrupts from the top. An inter-
mupt is an electronic signal from a peripheral that
tells the 6502 microprocessor to immediately stop
whatever it's doing and come to the ald of the
peripheral.
A typical use for interrupts would be with a high-
speed modem, As each character is received, it is
necessary for the computer to get it and store it
someplace so that it isn't ovenoritten by the next
character coming In. If interrupts aren’t used, the
modem software must continually poll the modem
to find out if a character has been recelved yet. With
interrupts active, on the other hand, the modem
stops the software and yells "come and get it” when-
ever a character is ready.
Most clock cards can also be set up to send an
interrupt every so often. Clock interrupts provide a
Vol. 1, No.5
way for your computer to check on a security sys-
tem or a solar collector every once in awhile (in the
background), while still being primarily used for
something else (in the foreground). I too have a
Thunderclock and although it has proven very reli-
able (and expensive), its slowest interrupt rate is 64
times a second—somewhat more often than I've
ever had any use for.
Many computers have an interrupt-driven key-
board. This is a good use for interrupts, although the
Apple keyboard doesn't normally support this. Prod-
ucts such as Apple Writer must take a peek at the
keyboard about a hundred times a second, even
while doing such things as scrolling the screen, to
keep a fast typist’s keystrokes from being lost. How-
ever, the Apple Mouse card (built into the Apple IIc)
provides keyboard interrupts to the Apple II family if
you really need them.
‘The main idea of interrupts is that afier the inter-
rupter's needs have been taken care of, the 6502 can
{go back to whatever it was doing before. In order to
do this successfully, however, the status of the
microprocessor and of the computer's memory con-
figuration at the time the interrupt occurred has to be
saved somewhere. The 6502 automatically saves its
status register and program counter on the stack
when an interrupt occurs, but it's up to a machine's
software to take care of everything else. After the
6502 saves the status and program counter, itjumps
to whatever address is stored at memory location
SFFFE.
Interrupt support ts buitt into all Apple Ils. In the
original II, Il-Plus, and Ile, the address stored at
SFFFE points to a routine in the Monitor that saves
the contents of the 6502's A register at memory
location $45 before passing control to the pro-
grammer’ interrupt handler. This would be great if
no other software ever used $45 for anything.
Software that does use $45, however, fails with inter-
rupts, because every time an interrupt occurs the
contents of byte $45 are destroyed.
The Apple II has a reputation of not working with
interrupts because DOS 3.3 saves stuff in $45. You
can work around this bug by disabling interrupts
before giving a DOS command and enabling them
again afterwards (this requires assembly language
tricks. By the way, both DOS 3.3.and ProDOS disable
interrupts while actually reading from or writing toa
disk, This is because the subroutines that actually
deal with the magnetic patterns on your disks are
extremely time-sensitive and don’t work if inter-
rupted. Consequently, interrupts are disabled and
can remain that way for relatively tong periods of
time during disk access —several seconds if an error
occurs that causes the disk to recalibrate itself.)
On the enhanced Ile and lic, Apple solved the
interrupt problem by saving the A register on the
6502's stack rather than at byte $45. Thus, you can
successfully interrupt DOS 3.3-based programs on
‘one of these machines, The enhanced Ile and IIcalso
automatically save the memory configuration at the
time of the interrupt, and put it back again when the
interrupt handler is finished.
ProDOS never uses $45. Consequently, it supports
interrupts on any kind of Apple. It also automatically
saves the registers, bytes $FA through $FF and 16
bytes of the stack. The interrupt handler can freely
use these resources. Neither the interrupt handler
nor any ProDOS program, however, should ever use
$45 or $7F8 (ProDOS uses $7F8 to store the number
of the slot that was active when the interrupt
occurred.)
June 1985
Dump 40
1 am looking for a method to dump just the 40- °
column screen to the printer, | tried modifying your
80-column dump (February, page 15) by poking only
the odd columns, butt did nasty things to my Apple-
soft program.
Richard Hanley
Milford, Conn,
You can tun February's DUMP 80 into DUMP 40
by simply deleting lines 330, 340, and 350. In 40-
column mode, it isn’t necessary to poke anything to
read the screen memory correctly. (if youve
updated your DUMP 80 with the modifications I
gave in March (page 22) to make it run faster, you'll
also have to remove the L$+ from line 360.)
Learning assembly language
I'minterested in learning assembly language. | am
ata beginners level programming in Basic. Could you
recommend any sources?
John J. Gwynn
Roslindale, Mass.
I think the best book around for learning assembly
language on the Apple is Roger Wagner's Assembly
Lines. Since this book was published by Softalk
Books, many people are under the impression it is
no longer available, and it wasn’t there for awhile,
However, Mark Pelczarski of Penguin Software
recently managed to wrestle down the rights to
Softalk’s books and is now distributing them.
They're still called Softatk Books and they can be
ordered from Penguin Software, P.O. Box 311, Ge-
neva, IL 60134; orders 800-325-0884, information
512-232-1984. Apple-related books currently avall-
able and prices (add $2 for shipping) are:
Applesoft Isn't Hard $14.95
bby Doug Cariston
Aseembly Lines
bby Roger Wagner
$14.95
Graphically Speaking $14.95
by Mark Pelczarski
Nacintosh Complete!
bby Doug Clapp
Apple lic hardware fix
Early Apple ics (serial numbers below D51000)
have a hardware bug that can prevent them from
working with 1200 baud modems and other high-
speed peripherals. If you have a peripheral that won't
work with your IIc, Apple dealers are supposed to
replace the motherboard in your IIc without charge.
dim Luther
Kansas City, Mo.
514.95
Super hi-res graphics
Do you know of any way of increasing the Apple II's
resolution past 560 x 192? There was mention of a
card in an old Softaik letter that had resolution capa-
bilities of 640 x 768, Itwas made by Demco Electron-
ics and called the Graphics Tool Kit. Does this still
exist? Where are these people? How come other
companies don't make “add-ons” to increase
resolution.
Hove my Appleand wouldn't trade it for all the IBMs
in the world, but when it comes to information about
graphics there is a curious lack of information. For
example, no computer store in my area has any
graphics tablet for me to ty. They all say there is no
demand for them so they can't afford to stock them.
Not only that, 50 per cent of the stores claim Apple
doesn’t make a graphic tablet anymore; what gives?
Clyde Godfrey
Ann Arbor, Mich.
Demco Electronics (10516 Grevillea Ave, Ingle-
wood, Calif. 90304, 215-677-0801) selis its Graphics
Tool Kit for $595. It includes eight disk sides of
software and sample data and a peripheral card that
works in slots 1 through 7. It provides 640 x 384
Screen resolution (the Macintosh screen is 560 x
354) and can print at 640 x 768.
While finding out about these higher-resolution
modes can be hard, there is something there to find
out about. | recently got a letter from a company
called MicroGraphic Images (21040 Victory Blvd,
‘Suite 210, Woodland Hills, CA 91367 818-368-5482),
which is justifiably proud of itself for having created
a professional-quality high-resolution graphics
workstation based onthe Apple lle. Their system has
512x512 screen resolution with 16 colors and simul-
taneously uses the Apple's 6052 and a 6 MHz 2-80
card to increase the system's speed. The whole
thing, including a Ile with drives, Videx Ultraterm and
monochrome monitor for the “command” screen,
graphics board and RGB monitor for the “design”
screen, 7-80 board, graphics tablet, software,
detailed manual, and heavy-duty power supply and
cooling fan costs $8,795, which is about $20,000
less than the systems it competes with. if you
already have the hardware, the guts of the system
(software mostly) are available separately at alower
price,
| called Diane Blake, Vice President of Creative
Development at MicroGraphic Images, and asked
her your question about obtaining information on
super high-resolution graphics on the Apple Il. She
agrees with you that it’s hard to obtain. She said it
wouldn't actually be necessary to see a card before
buying—what you need to ask about is the resolu-
tion, number of colors, and kinds of graphic primi-
tives built into the hardware. MicroGraphic Images
uses the Number Nine Graphics Card, from a com-
pany called Number Nine (stupid me, | forgot to ask
fortheiraddress; MicroGraphicImages will probably
sell you one if you're interested, though).
‘One thing to consider is that when you deal with
‘super high-resolution, you have to move a lot more
bytes around to fill a picture. Thus, super high-
resolution systems on the Apple II may be slow
unless you also add a faster 6502 or some other
chip, as MicroGraphic Images does. And unless you
are an assembly language programmer willing to
devote all your time to graphics, the software that
comes with any card you buy will be very important
to your ultimate satisfaction.
Regarding Apple's Graphic Tablet, Blake agrees
with you that it is hard to obtain but she says itis stilt
being made. (A call to Apple confirmed this, The
suggested retail price is $795.) Dealers are mixed up
because Apple pulled it off the market for about a
year sometime ago because of radio-interference
Problems that have since been solved. Blake said
MicroGraphic Images became an Apple VAR (Value-
‘Added Reseller; this means they buy direct from
Apple rather than through dealers) primarily to have
better access to the tablets. Blake also mentioned
that there are RS-252 graphics tablets available from
other manufacturers; these would work with an
Apple Il if you had a serial card.
Blake says most of MicroGraphic Images’ poten-
Open-Apple 47
tial customers are surprised to find such a high-
powered system running onan Apple iI, Most of their
competitors use IBM-PCs, “The quality, reliability,
and open architecture of the Apple II is the tie that
binds this system together. On any other machine it
would be slower, more expensive, and less reliable,”
California-area subscribers interested in just how
far the little Apple II can be pushed, as faras graphics
are concemed anyhow, can see MicroGraphic
Images’ stuff at the West Coast National Computer
Graphics Association conference in Los Angeles,
June 25-27.
HCOLOR me invisible
I recently encountered a hi-res graphics program
that worked well onan Apple II-Plus but didn’twork at
all ona lle. After some fiddling around, | discovered
the problem had to do with the default HCOLOR on
power up. When the Il-Plus powers up, HCOLOR
defaults to 7 (white); when the lle powers up, HCOLOR
defaults to 0 (black). This can be seen by examining
byte 228 (SEA),
Thus programs that fail to specify an HCOLOR will
fail to work on the Ile, even though they (accidentally)
work just fine on the II-Plus,
Nowa question. Normally an Apple peripheral card
can be identified by peeking its slot location. For
example, to verify that a disk controller card is in slot
6, all one needs to dois PEEK the locations starting at
50688 ($C600), For the Apple Disk I! interface, bytes
50688 through 90 always contain 162, 32, and 160.
However, this trick doesn’t work for an Integer
Basic ROM card or a MicroSoft Softcard. The values
peeked don't remain constant over time. The same
thing happens with empty slots, How come?
Michael Ching
Honolulu, Hawaii
Thanks for your HCOLOR tip. For the record, the
‘meaning of the values you'll find by peeking at byte
228 ($E4) are: O=black.1; 42=green; 85=violet;
127-white.1; 128=black.2; 170=orange; 213=blue;
255=white.2.
Slots 1 through 7 in all Apple lls each have an
exclusive 256-byte address range for machine lan-
guage programs. A program that appears in this
range Is really on a ROM chip that's on a peripheral
card. The program will appear within its slots
assigned address range when the card is plugged
into the stot.
‘The address range for each stot is $Cs00 to $CsFF.
where "s” isthe slot number. The address range from
$C800 through $CFFF can also be used by machine
language programs on peripheral cards, however,
only one card at a time can use this space. Whenever
a reference ls made to byte $CFFF all peripheral
cards are supposed to turn their $C800-SCFFF
memory off. Whenever a reference is made inside a
card's 256-byte program area, that card is supposed
to tum its $C800-SCFFF memory on. This feature has
been built into the Apple II since the beginning, and
was the first use of "bank switching” on the Apple.
The system is ingenious, Most computers have to
be “reconfigured” whenever a new peripheral is
added or removed. This means the operating system
must be modified by adding or removing machine
language “drivers” that interact with the peripheral.
But with the Apple II, this reconfiguration takes place
automatically when a card is inserted or removed,
since the required machine language programs are
built into the peripheral cards. Steve Wozniak credits
his friend Alan Baum with coming up with this
scheme (Byte, December 1984, page A7U).
48 Open-Apple
However, some cards don't take advantage of it.
They have no machine language drivers built into
the 256-byte program space. Since there's nothing
there, you'll get a different number everytime you
PEEK at those addresses, just as you do if the slot is
empty.
Printers to flash
Ihave developed a revolutionary new product that
your readers might be interested in—a printer that
will print flashing characters. I've been working day
and night (yesterday and maybe tonight) on this
project. First | tried octopus ink, but ASCII printed as,
octal. | diluted it 4:1 and got binary.
Finally | got a bright idea and tried ink made from
the juice of Canadian fireflies.
Murray MacKenzie
Scarborough, Ontario
Readers may address inquiries to MacKenzie in
care of the Northem Lights.
The wonderful world of windows
‘Type in and run the following Applesoft program:
10 TEXT : HOME : FOR Tel 70 23 : PRINT I : NEXT
28 POKE 32,3 = HOME : END
Why does HOME clear the lower 16 lines of the area
outside (to the left of) the new text window and not the
upper eight?
Dennis Doms
Kansas City, Mo.
Let's begin by explaining a little bit about win-
dows on the Apple II to everyone. The Apple It
operating system has always provided pro-
grammers the ability to specify a “text window” for
all further PRINTing to appear in. Usually this win-
dow is set to full-screen — 24 lines high by either 40
or 80 columns wide. But a few simple POKEs can
make the window smaller and put tt anywhere on
the screen. The following table shows which bytes to
POKE:
byte use allouable range
40-col 80-col
32 ($20) left edge 0-39 0-79
33 ($21) width 1:40 1-80
34 ($22) tow 0-23 0-23
35 ($23) _botton 24 12a
The following program demonstrates a way to set
is a trademark of Tom Weishaar. Apple Computer and
Shen Ree are two aiterent unrelated, independent companies
that wish everyone in the worldhad an Apple
up windows using an integer array (variable name
ends with a "%") to hold the dimensions of several
different windows. It will show you some of the
Possibilities windows provide:
10 REM #** MENODK OHO."
100 NORMAL : TEXT : HONE
110 Suicd0 + REM determine screen uidth (42 or 807)
120 IF PEEK(64435)=6 AND PEEK(49183}>127 THEN Su=B2
130 NisS + REM nunber of windows used
140 DIM WR(NN.4) : REN Integer array for windows
190 FOR W=1 TO NM : REM get and check dimensions
160 : READ We(W,1) : REM left edge
170 : READ WH(K,2) : REM width
180 : READ We(W,3] = REM top
190 : READ We(K,4) = REM bottom
210:
F WR(M,1)<1 OR WR(M,1)>9W THEN
PRINT “LEFT EOGE OFF SCREEN IN WINDOA “3H
220 = IF We(W.1)+4(u,2) > Sel THEN
PRINT “RIGHT EDGE OFF SCREEN IN MINDOW “3H
230 5 TF WR(H4,3)C2 OR HR(H,3)D24 THEN
PRINT “TOP EDGE OFF SCREEN IN WINOCH
240 = IF WA(4.4)<L OR WR (W4)>24 THEN
PRINT “BOTTOM EDGE OFF SCREEN IN MINDOM “2k
250 = TF wR(u,2}<1 THEN
PRINT “WIDTH NEGATIVE IN KINOOW “s W
260 : IF Wx(wy3) > Wa(H,4) THEN
PRINT “TOP BELON BOTTOM IN NINOOM “sh
270 NeXt
280 PRINT : PRINT
290 INPUT “PRESS <RETURN> TD BEGIN" 3HS
300 REM LEFT NOTH TOP aT
310 DATA «1,28, 1,12
320 0RTA 20, 20,1, 2
330 DATA «1, 20,13, 24
340 DATA 20, 20, 13, 24
350 DATA 1, 40, 18, 24
360 DATA «1, 40,18, 18
370 DATA «20, 1, 1, 24
380 DATA «28,5, 12, 12
390 DATA «8,82, 25,
500 INVERSE : HOME
510 INPUT “WINDOW B?*;Ws
520 NORMAL : TEXT : HOME
530 M=VAL (WS) : TF WKL OR WDNM THEN END
540 POKE 32,M&(H,1)-1 + POKE 33,MR(W,2) =
POKE 34,W(4,3)-L + POKE 35,uR(H, 4)
950 VTAB WR(,3) > HTAB WR(KAL) =
REM put cursor inside new window
560 GOTO S00
Lines 100 to 390 initialize the program. For things
to work right we need to know whether a 40-column:
or an 80-column screen is active. Line 110 assumes
40-columns; line 120 changes this to 80 if byte
64455 indicates the program is running on a He or
IIc AND if byte 49183 indicates 80-column mode is
active.
Line 150 sets up a loop for reading the window
dimensions from the DATA statements in lines 300 to.
390, Lines 210 to 260 check these dimensions to
make sure they are allowable and sends messages
to the screen when mistakes are found. Program
initialization ends in line 290.
The main body of the program is at lines 500 to
560, Line 510 asks which window you want to acti-
vate. When you run the program, enter a number
between 1 and 8 in response to this question. Enter-
ing 9will crash the program because the dimensions
for window 9 are bad. Anything else ENDs the
Program.
Line 540 pokes bytes 52-55 with the dimensions
for the chosen window. It also makes some adust-
Vol. 1, No.5
‘mentsto the dimensions (by means of the-1 in POKE
32 and POKE 34) so they're easier for us humans,
These adjustments allow you to specify window
dimensions using the same screen coordinates as
VIAB and HTAB, In other words, the adjustments
allow you consider the top line and the left-most
column as number 1, rather than 0.
Line 550 puts the cursor inside the specified win-
dow. Line 560 loops back to line 500, where the
program continues. If you are using a Ile or lic with
the 80-column firmware active, line 500 will cause
the window to appear as an inverse rectangle on
your screen. On a Il-Plus, or with the 80-column
firmware off, you will have to search for the edges of
the window by pressing Escape and moving the
cursor around with the IJ-K-M keys. Alternatively,
you could replace line 500 with this:
50@ INVERSE : FOR I=1 TO 24 : PRINT SPC(SH) : NEXT
Its not elegant, but it will make your window
clearly visible.
If the WINDOW DEMO gets your interest up, try
GIRAFFE. However, | wam you that it has no redeem-
ing social value whatsoever:
10 REM 29" GIRAFFE ##
100 NORMAL : TEXT : HOME
110 SH=40 : REN cetermine screen width (40 or 887)
120 IF PEEK(G4435)=6 AND PEEK(49183)>127 THEN Su=8o
130 POKE 33,1 : REM make window 1 column wide
200 INPUT “)"3Xx8
210 HOME : PRINT CHRS(7);“]I FEEL ILL.”
220 C=PEEK(32)
230 Cat42
240 IF C=>SH THEN TEXT : HOME : POKE 331 : C=
250 POKE 32,C
260 VTAB 1
270 GOTO 200
This program uses the TEXT command a couple of
times. TEXT always opens the window to the full
screen size (as well as turning off graphics, which is
meaningless here). Pressing the Reset key also
opens the screen window to full size. If you use
windows in your programs, remember that your
reset trap, if you have one (see the February issue,
Page 16), will have to fixthings up.
Window bugs result from a number of mistakes,
but the two most common are making a window
wider than the screen itself and forgetting to put the
cursor inside the window. The Apple's screen display
routines do not check the contents of bytes 32-35 to
see if they make sense. If you put in nonsense you
don't get an error message — you get erratic opera-
tion. This includes the possibility of destroying
your program.
The 80-column firmware in the original He has
some of its own window bugs. To avoid them, put the
left edge of all windows in an odd column (assuming
you call the first column 1 not 0).
Now that the preliminaries are out of the way, let's
answer the original question. POKE 32,3 moves the
left edge of the “text window” to the fourth column
on the screen. The problem here is that byte 33, the
screen width, still holds 40 (or 80), thus right edge of
the window is in column 43 (83). This is off the
screen, but the screen display routines don't check
for that. Thus, the HOME command starts messing
with bytes it's not supposed to touch.
This time the bug is in the program, not in the
Apple. To get the program to work correctly, change
line 20 to:
20 POKE 32,3 : POKE 33,40-3 = HOME : ENO