*********************************************************************
This article is being presented through the *StarBoard* Journal of
the FlagShip/StarShip, SIGS (Special Interest Groups) on the
Delphi and GEnie telecommunications networks.  Permission is
hereby granted to non-profit organizations only to reprint this
article or pass it along electronically as long as proper credit
is given to both the author and the *StarBoard* Journal.
*********************************************************************

                                  -
                            CP/M Primer #3
                                  -
             By: Mike Mantino   (GEnie MAIL address: MIKEM)
                                  -

Welcome back!  If you're still with us after reading the first two CP/M
Primer articles, you've probably concluded that although the CP/M
environment is a lot different from the Commodore operating system (and
a bit slower on our 128's than in most CP/M machines), it is
nonetheless an interesting and powerful world.  This month we will add
to that power and discuss ways to speed up the system and generally
make life easier for you thru the use of key configurations and batch
processing of commands in a variety of ways.

                                  -

Let's get organized, first.  Because the C-128 does not automatically
boot-up in CP/M mode, we have to do it manually by loading-in the CP/M
system files.  Once that is done, there really isn't any need to have
those files on our disk, so it makes sense to create just one CP/M BOOT
disk (plus a backup).  That disk should also include some important
files and programs that will aid in setting up your initial parameters
and getting things set correctly for the rest of your CP/M session.
The files I use quite often upon boot-up are: CONF.COM, NFORMAT.COM,
SUBMIT.COM, DIR.COM, DATE.COM, SHOW.COM, C1571.COM, NSWEEP.COM,
NULU15.COM, INITDIR.COM, TYPE.COM, and KEYFIG.COM.

CONF.COM is very important to us C-128 folks, because we need to adjust
a few parameters every time we boot-up CP/M.  For instance, by turning
off the 40-column display, we can gain a speed increase of about 10%.
This is accomplished, simply enough, by typing: conf 40col=off

We can change a wide variety of things using CONF.COM which will
enhance the way we do things.  All of the parameters that follow
require that you precede them with: conf.    You can, however, string a
number of them together in one command line which starts with: conf.

40col=off  - As stated, this turns off the 40-column display.  To turn
it back on, you would use: 40col=on

feel=0     - This parameter adjusts the way the keyboard 'feels'.  The
keyboard is scanned with the same interrupts used in handling the
serial port, so as the BAUD rate is increased, the number of keyscans
per second is increased.  Because of this, we use FEEL to set the
number of interrupts that are *not* used between each one that *is*.
The default values for the different baud rates are set to keep about
300 keyscans per second.  For instance, at 300 baud, the FEEL is
defaulted to 2.

baud=75    - The modem port baud rate adjustment can be changed to any
of these values:  50,75,110,134,150,300,600,1200.  I have found that
75 seems to be both a fast and reliable speed.  Remember that changing
this also changes the FEEL.

back=6     - Change the background color by supplying the appropriate
color number.

bord=6     - Same as above, but for the border color.

char=9     - Same as above, but for the character color.

cursor=fast 7   - For the 80-col display cursor.  This example sets up
the cursor to be a flashing (fast or slow) underline.  You may set it
up as 'solid' instead of fast or slow, and also include the optional
start and end scan line parameters.  Examples:  cursor=solid 0 4
or  cursor=slow 4.

date=      - This parameter was reviewed in CP/M Primer #2.

dump xxxx  - Allows you to dump 16 bytes of memory starting from the
HEX address supplied (xxxx).  This is RAM BANK 0, *not* the TPA memory.

map        - This will show both of the character sets.

parity=<number><parity><stops>   - The options in which the serial data
can be sent or received, normally defaulted to 8 bits/no parity/1 stop
bit (8N1).

poke xxxx - This powerful command allows you to change bytes within the
operating system (again, BANK 0, *not* the TPA).  The range you can
change is 1000 to FEFF. (Below 1000h is ROM)
Example: poke 4000=21 22 23 24 25  (will write 21 to 4000, 22 to 4001,
etc).

prt1=cbm  - Specifies either CBM or ASCII sent to the printer on the
serial port. A secondary address may be added to allow different
printer and interface configurations.  Note: If your printer/interface
allows a transparent mode and you find you are unable to print a dbl
quote mark ("), use: prt1=ascii x  (where x is the secondary address,
usually 4, 5, or 7)

repeat=0  - If a 0 is specified here, then your keys will not repeat.
Otherwise the lower the number, the the faster the repeat.

vol=0     - You can set the volume of the keyclicks with this
parameter.  If a 0, you will turn them off.  15 will set the highest
volume, and the default is a 6.


Okay, so that's the run-down on our CONF.COM options.  Now we will make
it easy to use.  As previously stated, we can string a number of these
parameters together on the same command line.  Every time I boot-up
CP/M I send the following CONF commands:

conf 40col=off,cursor=solid 6,back=6,char=9,vol=0,repeat=1,feel=1

Easy enough, but still not the best way to do things, since you need to
type this in at each system reset.  We will see in a few minutes that
we can make that command line be executed automatically upon booting
the CP/M system.  Before going into how that is done, let's discuss one
more of the modular utilities we have at our disposal so that we can
include both of them into the automatic process (batch processing).

                                   -

The little utility called c1571.com is used specifically to turn off
disk verify's on any or all of your drives, thus gaining additional
speed.  The format for the utility is: c1571 [drive letter, drive
letter, drive letter, etc].  So, if you had two 1571's (drives A and
B) and a 17xx RAM expansion module, plus the virtual drive E, your
format might look like:  c1571 [a,b,e,m].

                                   -

Now that we know how to set up our system to allow it to run more
efficiently, and we have an idea of what parameters we want to
customize, let's store those things in such a way that they are brought
up automatically and directly after the CP/M system is loaded in.

The reason we can do this is because every time we load CP/M into
the 128, it looks for a special file called PROFILE.SUB.
If it is present, CP/M+ will then look for and run a file called
SUBMIT.COM which in turn will go to the PROFILE.SUB file and execute
all the commands you have put into it.

Given that we now have SUBMIT.COM on our disk, and know what commands
we need to put into the PROFILE.SUB file, let's do it.

All it takes to create any .SUB file (in this case, PROFILE.SUB) is an
editor or word processor of some sort.  Both ED.COM and WordStar work
well, and PIP can also be used (but not if you want to do any editing).
Here is an example of what a PROFILE.SUB file should look like:

^z
c1571 [a,b,e,m]
conf 40col=off,cursor=solid 6,back=6,char=9,vol=15,repeat=1,feel=1
a1: mex

Note that each command is given a separate line in the .SUB file.  The
above PROFILE.SUB file will turn off the disk verify on drives a, b, e,
and m.  It will then run CONF.COM and set up our parameters and colors,
and after that, will load MEX.COM from drive A, user area 1 (A1:).

After we create this file using an editor and save it to disk giving it
the filename PROFILE.SUB, it will be executed immediately after CP/M is
booted up.  SUBMIT.COM can also be used to run any other file that has
the .SUB extension, but you will need to manually do this using the
format:  submit <filename>.  For instance, if we had named that
PROFILE.SUB file FAST.SUB, it would not be executed initially with
the CP/M system.  But we could still execute all of our commands
contained in the file by manually typing:  submit fast.

SUBMIT.COM is a very powerful tool with a numerous amount of varied
uses.  Just about anything we manually type in at the keyboard can be
included in a .SUB file and executed using SUBMIT.COM.  We can even
include other SUBMIT commands inside other .SUB files, linking these
together to do a number of tasks for us, like copying files from drive
to drive using PIP inside the .SUB file.  The number of options and
ideas available for SUBMIT.COM is endless, but this article is geared
toward familiarizing one with the CP/M environment in general.  If you
plan on doing much with CP/M, learning how SUBMIT.COM works will
greatly enhance your systems efficiency and save you bunches of time.

                                 -

The first thing I had done when I acquired my C-128 was to learn how to
use the KEYFIG.COM utility.  I wasn't very impressed with the purple
character color that came up with the system; changing it manually was
getting old, quickly; and I had no idea what a PROFILE.SUB was.  I was
also used to having programmable function keys, true Commodorian that I
am.   KEYFIG.COM allowed me to do both, easily.  It also implants these
things directly on the disk(s), and you never have to use the resident
keyboard editor and function editor again.

Since I happen to like blue characters on a black background, I'll
explain the method of doing just that.  Afterwards, we'll redefine the
British Pound key so that we can make better use of it.

First, boot-up KEYFIG.COM and find yourself another CP/M disk that
you'd like to put a few changes into.  Initially, you will be asked if
you want any HELP, and since it's hard to turn down the first time you
use a program, go ahead and answer 'Sure!'.  (Actually, you must answer
with a Y for YES.  Boring, isnt it?)

After scrolling up and down the HELP options with the cursor keys (the
ones at the top of the keyboard, *not* the two keys next to SHIFT), hit
<RETURN> and you will be given the appropriate HELP file.  When you've
had enough, choose '--> done help <--' and we will start messing things
up.

Now, you will be given three options to choose from as far as sources
of the key definitions.  We can take them from the DEFAULT definitions,
the definitions on our CP/M disk, or the CURRENT definitions.  Since we
are going to be saving the set-up to the disk, we may as well take them
from the disk in the first place.  After choosing the CP/M disk option,
you will be shown three more options: EDIT KEYS, ASSIGN COLORS, and
EXIT/SAVE WORK.  We'll do the colors first, so choose that.

The next options are for 40-Column or 80-Column screens.  Choose the
apropriate one, and you will be shown two nifty pallettes of colors.
Looks nice, huh?  But what the heck does LOGICAL and PHYSICAL have to
do with colors?  Well, the LOGICAL colors are the key-defined colors. In
other words, that little purple box in the LOGICAL color map (letter e)
is the one we want to change to blue.  So, since the program is now
asking you for a letter found in the LOGICAL map, tell it you want 'e'.
Then it's going to ask for a letter corresponding to a color in the
PHYSICAL color map.  The blue box is the one we want, and it's labeled
with the letter 'o', so respond with that.

Now we can go ahead and make the color change semi-permanent and save
it to disk.  Choose the option:  done logical<-->physical colors.
Now choose to: Exit and save your work file on CP/M disk.
The colors are now imbedded, and the program will ask if there is
anything else you want to fool around with.  Tell it 'Y' again, and we
can set up that British Pound key that we hardly ever use.

We are now back at the initial three options, but this time we want to
EDIT KEYS.  Choosing that will give us a list of values for some key on
our keyboard.  The NORMAL value is the unshifted value of the key that
is labeled.  The others are SHIFTED, CONTROL, and CAPS LOCK.  Now,
since we want to change the British Pound key, go ahead and press it.
You should see all the values change.  Starting to make sense?  You can
scroll up or down these values in order to set it up for a change in
that apropriate value.  Since we want to be able to just press the
British pound key (one keystroke) and get something other than that
symbol, cursor around until the lightbar is resting on the NORMAL
value.  Now hit the <RETURN> key.  The next options are fairly clear,
so select the option to ASSIGN A STRING.  You can now type in anything
you want the British Pound key to display instead of the symbol.  I
have it changed so that it displays:  dir [user=all,drive=all]   That
way, whenever I'm at a CP/M command prompt, I can hit just the British
Pound key and get a directory of all files on all drives in all user
areas of each disk.  You can redefine the SHIFTED value of the same key
so that it displays something entirely different.  The same for the
CONTROL value and CAPS LOCK value.  Then whenever you hit SHIFT and the
British Pound key, the string that you changed is displayed, and so on.

Once you have finished defining keys, select the 'exit string edit'
option and save the string to disk.  Every time you boot up that
particular disk, all of your redefined colors and keys will be
instituted without any more input from you.

KEYFIG.COM helps in other ways that I won't cover here, so do read
through the HELP files for information on the other options available.
One interesting aspect of KEYFIG is its ability to actually describe
what it can't display.  To refer to the left arrow key which is there
in the upper left corner of the keyboard, KEYFIG describes it as the
LEFT ARROW NEXT TO 1.  To describe the DELETE key, which has no
displayable ASCII code, KEYFIG refers to it as RUBOUT.

Lastly, remember that the CAPS LOCK key is not operative under CP/M,
so you must substitute the combination of C= and SHIFT keys for it.

If there is anything contained in this article or previous CP/M Primer
articles that you still do not understand or that I haven't made clear
enough, or if you have a question about some other area of CP/M-land,
stop by GEnie's Commodore *FlagShip* Roundtable at page 625, or the
CP/M Roundtable at page 685 and let us know.  There are a good number
of people in both places that are more than willing to help!

- Mike Mantino
  (GEnie Address: MIKEM)

For our DELPHI CP/M users, be sure to check with GARYWAYNE, the
CP/M SYSOP for the DELPHI *FlagShip*.
