[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can anyone help me with Apple CP/M



In article <394D27FF.71C98F25@pacific.net.au>,
Matt Jenkins  <mdj@pacific.net.au> wrote:
 
> Paul Schlyter wrote:
> 
>> In article <394BC2CC.67D6764@pacific.net.au>,
>> Matt Jenkins  <mdj@pacific.net.au> wrote:
>> 
>>> Howdy,
>>>
>>> Just been playing with CP/M on a clone machine a friend picked
>>> up, it works just fine using Microsoft softcard cpm boot disks...
>>>
>>> Now while I understand the basics of cpm use, I have no idea
>>> how you go about loading a driver to access 80 column cards etc.
>>>
>>> can anyone help with that?
>> 
>> On the CP/M cards I've used (the Softcard and the Appli-Card) it was
>> automatic: I just inserted my Videx card in slot 3, and CP/M booted
>> up automatically in 80-column mode.  Quite sensible, since a lot of
>> CP/M software assumes 80 column.  Once I tried, in vain, to configure
>> WordStar for 40 columns: it didn't work, since WordStar required a
>> minimum of 64 columns....
> 
> Ah, it does work :) Ok, perhaps I should've tried that before posting
> such a silly question...
 
You're not alone -- a lot of people ask too much before trying even
the obvious.  It's as if they think they're guaranteed to break
something if they try things not explicitly mentioned in manuals/etc.
 
>>> And also, does anyone know if I can use my beautiful UniDisk 3.5"
>>> drive with Microsoft style CP/M ?
>> 
>> It's definitely possible, but will require that you dig a lot "under
>> the hood" yourself, and acquaint yourself with how the SoftCard
>> BIOS works (both the Z80 and the 6502 parts).  And if course you
>> must also know how to access your UniDisk 3.5" from 6502 assembly
>> language.  Good luck!  (no, I can't help you since I don't know
>> how the UniDisk 3.5" works)
> 
> Ok, The 6502 accessing of the UniDisk I can handle, but I'd assumed that
> this would all be done in Z80 mode. Doesn't the softcard just pull the
> 6502 into halt
 
Almost: the 6502 is allowed to refresh itself evey microsecond.  This
is necessary: since the 6502 is a dynamic processor, putting it to
halt for more than about 50 microseconds will make it "forget" the
contents of all it's CPU registers.  This is done by letting the Z80
run at 4 MHz for half a microsecond, then halting the Z80 for the
other half of the microsecond - then the 6502 refreshes itself by
doing a dummy memory fetch; the data fetched is not used but discarded.
 
> and allow the Z80 to control the system?
 
Yes, however the Z80 can at any time stop itself and give control
back to the 6502.  And it does at all disk accesses for instance.
This is because the code for the lowest-level disk access to the
Apple drives (the RWTS in DOS 3.3 -- there are equivalents in all
other OS'es for the Apple II) are very sensitive to timing/etc,
and instead of rewriting it all in Z80 code, it's simpler to just
modify the 6502 code which already is there and well tested.
 
 
> Or does any access to C000-CFFF have to be done in 6502 mode.
 
Nope!  Keyboard reads, serial port I/O, etc are all done in
Z80 mode in the SoftCard.  However the range $C000-$CFFF are
mapped to 0E000h-0EFFFh as seen from the Z80.
 
Any access to $Cx00 (where x = the slot number of the SoftCard) halts
the 6502 and startes the Z80 at the address it was when it last was
running (initially it'll start att address 0000H = $1000).
 
> I hardware reference of the softcard would be pretty handy...
 
It indeed would.  The docs with the SoftCard even included a circuit
diagram of the SoftCard.  The paragraph below is taken from the
documentation for the S-C Macro Cross Assembler for the Z80.  Note
that $nnnn refers to addresses as seen by the 6502, while nnnnh
refers to addresses as seen by the Z80.  The reason for the address
remapping is that CP/M assumes a contiguous memory area available
from address 0000h up to some upper limit.  And due to the Apple's
text screens and 6502 page zero and stack, this cannot be
accomplished without address remapping.
 
=======================================================================
The Softcard is turned on and the 6502 off when the 6502 program
writes to location $Cx00 (x is the slot number).  When the Z-80
program writes into 0Ex00H, the Z-80 is halted and the 6502 is
restarted, continuing where it previously stopped.  The processors
can continue to toggle back-and-forth in this manner.
 
A small 6502 driver routine can be written to handle such things as
input or output while the Z-80 does most of the processing.  That is
what is done in Microsoft's version of CP/M.
 
If the Apple RESET key is pressed, the Z-80 will reset, setting the
Z-80 PC-register to 0H.  If you intend to use MGO and are not sure
whether the Z-80 PC-register is properly set, be sure to press RESET.
If RESET is not pushed after Softcard use, the Z-80 will continue
wherever the PC-register points.  That is the reason for the JR START
instruction above.
 
The Softcard remaps the address space of the Apple.  This provides
contiguous memory from 0000H to 0DFFFH (with a 16K RAM Card
installed) without accessing 6502 page 0, stack, or screen memory.
This is explained in the Softcard manuals, but it is presented again
here.
 
      Z-80 Address          Apple Address
 
    00000H - 0AFFFH         $1000 - $BFFF
    0B000H - 0DFFFH         $D000 - $FFFF
    0E000H - 0EFFFH         $C000 - $CFFF
    0F000H - 0FFFFH         $0000 - $0FFF
 
=======================================================================
 
> I do know that CP/M 3.0 BIOS's for other boards (Cirtech Z80, maybe
> Applicard and AE Z80) allowed access to UniDisks, and even Hard disks
> and Ram cards, but I only have old Microsoft
> Apple CP/M 2.2 disks, and it'd be cool to get it to work under that. How
> difficult it ends up being will probably depend on whether the Microsoft
> BIOS was modular enough to accept an additional low-level disk driver,
> or if it actually has to be hand-hacked to work.
 
Some hand-hacking is necessary.  However you do need to set up disk
parameter tables in the CP/M BIOS, and this is done for the softcard
as for any other CP/M system, except that Microsoft won't give you
source to its BIOS, so you'll have to patch it.  But it can be done
-- I've done it myself to implement support for 80-track double-sided
diskettes: it was indeed very nice to have floppies of 640K instead
of a mere 140K!
 
So you must figure out how the softcard BIOS transfers control to its
own RWTS (yes, there is an RWTS equivalent, written in 6502 code and
residing at $0800-$0FFF = 0F800h-0FFFFh, which is used for all disk
accesses to the standard Apple disk drives).  Once you know that, it's
probably fairly simple to feed your BIOS disk calls to the Unidisk
instead, once you've decided which drive letters should go to the
Unidisk (C: and D: perhaps?).
 
If you really want to pursue this, I might be able to dig up some
old disassemblies I might still have, which might give you the
needed information faster than if you'd dig it up all by yourself.
 
And, yes, you have another problem: you say you know how to handle
the Unidisk from 6502 assembly.  How much code is needed for this?
A few tens of bytes?  Then you might be able to squeeze it in
somewhere in $0300-$03FF = 0F300h-0F3FFh -- just watch out so you
don't overwrite stuff that's already there!  Or is it hundreds of
bytes, or even a few kilobytes large?  Then you must find space
elsewhere, e.g. by somehow moving down CP/M a KByte or so.
 
Or do you want to throw out all support of standard Apple disks and
replace it with support for only the Unidisk.  Then you have 2 KBYtes
available free at $0800-$0FFF = 0F800h-0FFFFh, but instead you ahve
another problem: you must, somehow, create a Softcard CP/M boot diski
for the Unidisk, and that requires familiarity with the Softcard CP/M
boot process.
 
> The beauty is one well written driver using the SmartPort protocol
> could implement UniDisks, superdisks, some slinky ramcards, and SCSI
> card all in one driver. Heck, it could even replace the existing
> 5.25" driver.
 
Would the driver fit in 2 KBytes?  See above....
 
> Does anyone out there have a surplus Z80 card for a //e they'll sell
> for a very nice price ?
> Messing with this old clone is cool, but it's not mine, and I'd much
> prefer the comfort of playing with this on my "production" //e.
 
Check out Ebay -- you'll probably find it advertised there from
time to time.  No, I don't want to sell mine, sorry.
 
-- 
----------------------------------------------------------------
Paul Schlyter,  Swedish Amateur Astronomer's Society (SAAF)
Grev Turegatan 40,  S-114 38 Stockholm,  SWEDEN
e-mail:  pausch at saaf dot se   or    paul.schlyter at ausys dot se
WWW:     http://hotel04.ausys.se/pausch    http://welcome.to/pausch