Hints for CP/M users on the Spectrum +3
---------------------------------------

(This file is in rather a random order - please forgive the weirdness.)

There's a lot of PD out there for CP/M (especially on oak.oakland.edu :) ),
but there are a few initial stumbling blocks to getting at it.

First, you need an internet connection, and some other 'big' host computer
with a serial port. I'll let you sort these two out. You'll also need a serial
lead. These are not fun to make. If you want to try, have a look at page 318
of the +3 manual. If you don't, there is at least one company that still
supply +3 serial leads at the time of writing. They are (or rather, he is) B.
G. Services, phone 081 397 0763 and ask about a Spectrum 128k serial lead. Or 
you can email briang@bgserv.demon.co.uk and ask for a price list. (BTW, no
connection with BGS other than as a satisfied customer.) Price as of May 94
was 6.50 pounds. NB: this serial lead won't do on its' own. It's intended for
connecting to a modem or printer, so you'll need an *additional* null modem
lead, such as you might use for connecting two PCs. A normal 25-25 should do
the job.

To help test the serial lead, PIP will probably come in useful. You can do 
'pip con:=aux:' to receive show input from the serial port, and 'pip 
aux:=con:' to output whatever you type to the port. You'll need ^Z's to end 
the PIP command though.

So now you have your working serial lead, you have the unenviable task of 
getting the first program across which 'bootstraps' you into the wonderful 
world of CP/M PD. :) This is a nontrivial task. The method I used was a little 
obscure and involved writing a program which could send data in speccy tape 
format (we're talking LOAD "" here) and using a disk editor to do a couple of 
LDIRs, compensating for the +3DOS header.

How you'd do it I'm not sure. If you can get hold of a program which converts
a .COM file into .HEX format, then you can use PIP to copy that first program
with something like 'pip wibble.hex=aux:' and then doing 'hexcom wibble'. This
should create the wibble.com file, and you should be ok from then on.

The first program
-----------------

This 1st program will obviously be something capable of file transfer, to make
it easier to transfer other stuff. I recommend QTERM, mainly because it's the
only comms program I've managed to get working. :) Actually it looks like the
best one available - it does kermit, xmodem and ymodem, and functions as a
pretty useful terminal. If you ever wanted to play Nethack remotely, now's
your chance.

You should be able to find a copy of QTERM called qtplus3.com (and a .HEX file
of it called qtplus3.hex) in the same place you found this.

The good stuff
--------------

Ok, now the boring bit is out of the way, we can get onto what programs there
are. Well first of all, you'll probably be wanting an editor. (Maybe you
won't, but who's writing this file anyway?)

Text editors
------------

There are two editors that look really good, for CP/M:

ZDE, which I'm using to write this file - weighs in at about 17k;

and Z80EMACS (or is it zmacs?) which weighs in at about 40-oddk, I think. I'm
not sure, as I haven't tried it.

ZDE is a Wordstar-like editor. It has a really good configuration program
which is certainly more flexible that most - e.g. you can set the number of
columns as well as the number of lines, which is a great boon on the +3 where
you only get a 51-column screen. ZDE handles a 51-column screen surprisingly
well. You could use the emulated 80-column mode allowed by CP/M, but this
doesn't seem to work too well with ZDE. It moves the cursor all over the place
which confuses the poor speccy no end as it tries to follow the cursor. You
could turn cursor following off, I suppose, but I think it's preferable to use
ZDE's handling.

At any rate, it beats using Tasword Two by a mile. :)

Zmacs is a port of MicroEMACS to CP/M. This sounds really good - multiple
files for one thing - but it uses a large-ish number of overlays in addition
to a .COM file. Apparently it runs ok though, so you might want to check this
out. This appears to only be on sipb.mit.edu, in /pub/z80/emacs I think. That
site is also known as rtfm.mit.edu, and it's *very* busy as it holds all the
Usenet FAQ postings. These are mirrored in many other places, but the Z80
files aren't. Mumble.


Z80 disassemblers
-----------------

If you're not much of a hacker, you're probably better off skipping to the
next section. :)

Although CP/M comes with SID, which is really good for patching programs and
the like, it uses the awful old 8080 opcodes for its' disassembly output.
There are a few different Z80 disassemblers avaiable for free which run on
CP/M, but the best I've encountered is called Wade. It has a command syntax
similar to SID (though not the same), and I used it to help fix up an old
ls.com program which was suboptimal in a couple of ways for the +3 (more on
that later).


Keyboard problems
-----------------

While I'm terribly happy that I can now touch-type on my +3 and it can keep up
with me, there are a few problems I've run into, especially in writing this
file. One is that the old speccy problem of the 'sticky keys' still remains -
this is to do with the way many of the keys on the keyboard are in fact
producing some shift + another key as far as the speccy is concerned. A big
gotcha in this department is the sequence '. ' (dot then space). Several times
while typing random documents I've run into this one. In fact, I just did. The
only way to deal with this is to try and allow for it a bit; just give an
extra bit of time between characters like ; " . and , or if your memory of
which real speccy keys these match to is good enough, use them instead - in my
case, at least, it seems to slow me down enough to mostly alleviate the
problem.


Using that ramdisk
------------------

You may think that the ramdisk you get under CP/M is rather lame. You're
right, of course - 12k as compared to 58k under +3 basic is pretty bad, but it
is possible to get useful utilities which fit (albeit rather snugly) into this
precious, and fast!, 12k.

One which I've really come to appreciate is called ls.com. This is an old
version of the 'SD' program as supplied in tools.lbr, patched to produce nicer
output on a 51-column display, and with the free space display fixed for CP/M
Plus, as used on the +3. This fits in 3k. Another useful utility is 'mft',
which copies files from one disk to another on a single-drive machine. Now,
although the +3 allows a logical A: and B: on a single drive much like +3
basic (and MS-DOS for that matter), PIP wasn't designed with this in mind. In
fact, IMAO, PIP wasn't designed with much at all in mind, but that's another
matter. ;)

A third utility which can often come in handy is a text file viewer called
'peep'. This comes from the 1kutils3.lbr on oak.oakland.edu, and the big plus
with using this instead of 'type' is simply that you can go backwards in the
file.

In all, I have five programs on my ramdisk:


LS      .COM   3k   MFT     .COM   3k
NT      .COM   1k   PEEP    .COM   1k
PIPE    .COM   1k

Drive C, user 0 contains 9K in 5 files
 2K free

(The dir. listing above was produced with 'ls'.)

'pipe' is a mini-version of pip. It seems to use a very small buffer size,
though, which makes it very slow. It's no good for copying across disks, but
you would be using mft for that. 'nt' is a very small program to take notes to
a file. You can think of it as equivalent to 'cat >file', or (for you DOS
people) 'copy con: file'. Unfortunately pipe doesn't work with devices,
otherwise you could do the literal equivalent of 'copy con: file', which would
be 'pipe con: file' (pipe works in the source, dest order). The normal CP/M
pip does work, however. Try 'pip file=con:' for that.

Pipe and nt are both in the 1kutils3.lbr archive.


Patching with SID
-----------------

Although the Locomotive CP/M manual explains a bit of how to configure
commercial software, these obviously don't need you to dig out your favourite
debugging tool to patch them with the right terminal escape sequences. :)

Worse though, they don't cover how to use sid at all. (sid is similar to ddt,
which you might see mention of.) Using sid to patch programs is actually
fairly straightforward.

There are only three commands you really need to know - 's', which changes one
or more bytes' hex values; 'd', which displays (dumps) a chunk of memory to
the screen as hex and ascii; and 'w', which writes your lovingly patched file
to disk.

Say you had to patch a program which was expecting a zero-terminated string
which clears the screen at the address 110h. Your sid session might go
something like this:

A>sid thingy.com
CP/M 3 SID - Version 3.0
NEXT MSZE  PC  END
4300 4300 0100 D0FF
#s110
0110 06 1b
0111 10 48
0112 80 1b
0113 02 4a
0114 30 0
0115 B0 .
#wthingy.com
0084h record(s) written.
#^C
A>

The 's110' starts entering hex bytes at 110h. The hex bytes are 1b 48 1b 4a, 
which are ESC H ESC J, which is the easiest way to clear the screen on a VT52, 
the terminal the speccy (approximately) emulates. The '.' indicates that no 
more bytes are to be changed. You can just press enter to skip a byte without 
changing it.

The 'w' command at the end saves the newly patched program to disk. It need 
not have the same name as the file you loaded up when starting sid. but 
usually you'll only want one (working) copy of the program to avoid confusion.

One command not used above was the 'd' command. You use this like 'daddr' 
where addr is the address you want the command to start hex dumping at.

When you're finished with sid, you can just press control-c to exit (which is 
of course extend mode + c on the +3).



Well, that's all I can think of for now, so I hope this helps someone, 
somewhen, maybe.

Cheers,
- Russell Marks.
(rm1ajy3@gre.ac.uk from Oct. 94, probably)
