ZX Spectrum +3 Disk Drive
The disk drive on the +3 is controlled by three ports:
$1ffd: Setting bit 3 high will turn the drive motor (or motors, if you have
more than one drive attached) on. Setting bit 3 low will turn them off
again. ($1ffd is also used for memory control).
$2ffd: Reading from this port will return the main status register of the
uPD765A (the FDC used in the +3).
$3ffd: Bytes written to this port are sent to the FDC, whilst reading from
this port will read bytes from the FDC.


Memory
The additional memory features of the 128K/+2 are controlled to by writes
to port 0x7ffd. As normal on Sinclair hardware, the port address is in fact
only partially decoded and the hardware will respond to any port address
with bits 1 and 15 reset. However, 0x7ffd should be used if at all possible
to avoid conflicts with other hardware.
When memory is being paged, interrupts should be disabled and the stack
should be in an area which is not going to change. If normal interrupt code
is to run, then the system variable at 0x5b5c (23388) must be kept updated
with the last value sent to port 0x7ffd. Reading from 0x7ffd produces no
special results: floating bus values will be returned as would be returned
from any other port not attached to any hardware.
The byte output will be interpreted as follows:
Bits 0-2: RAM page (0-7) to map into memory at 0xc000.
Bit 3: Select normal (0) or shadow (1) screen to be displayed. The normal
screen is in bank 5, whilst the shadow screen is in bank 7. Note that this
does not affect the memory between 0x4000 and 0x7fff, which is always bank
5.
Bit 4: ROM select. ROM 0 is the 128k editor and menu system; ROM 1 contains
48K BASIC.
Bit 5: If set, memory paging is disabled and further output to this port
will be ignored until the computer is reset.
The memory map of these computers is:
0xffff +--------+--------+--------+--------+--------+--------+--------+--------+
       | Bank 0 | Bank 1 | Bank 2 | Bank 3 | Bank 4 | Bank 5 | Bank 6 | Bank 7 |
       |        |        |also at |        |        |also at |        |        |
       |        |        |0x8000  |        |        |0x4000  |        |        |
       |        |        |        |        |        | screen |        | screen |
0xc000 +--------+--------+--------+--------+--------+--------+--------+--------+
       | Bank 2 |        Any one of these pages may be switched in.
       |        |
       |        |
       |        |
0x8000 +--------+
       | Bank 5 |
       |        |
       |        |
       | screen |
0x4000 +--------+--------+
       | ROM 0  | ROM 1  | Either ROM may be switched in.
       |        |        |
       |        |        |
       |        |        |
0x0000 +--------+--------+
RAM banks 1,3,4,6 and most of 7 are used for the silicon disc; the rest of
7 contains editor scratchpads.

An example of a typical bank switch on the 128 is:
     LD      A,(0x5b5c)      ;Previous value of port
     AND     0xf8
     OR      4               ;Select bank 4
     LD      BC,0x7ffd
     DI
     LD      (0x5b5c),A
     OUT     (C),A
     EI
The principle is the same for all bank switching: change only the bits you
need to change.

The basic principle of paging on the +2A and +3 is the same as for the
128K/+2. However, the +2A and +3 have four ROMs rather than two, and
certain extra memory configurations.

Port $7ffd behaves in the almost exactly the same way as on the 128K/+2,
with two exceptions:

Bit 4 is now the low bit of the ROM selection.
The partial decoding used is now slightly different: the hardware will
respond only to those port addresses with bit 1 reset, bit 14 set and bit
15 reset (as opposed to just bits 1 and 15 reset on the 128K/+2).
The extra paging features of the +2A/+3 are controlled by port $1ffd (again
partial decoding applies here: the hardware will respond to all port
addresses with bit 1 reset, bit 12 set and bits 13, 14 and 15 reset). This
port is also write-only, and its last value should be saved at $5b67
(23399).

Port $1ffd responds as follows:

  Bit 0: Paging mode. 0=normal, 1=special
  Bit 1: In normal mode, ignored.
  Bit 2: In normal mode, high bit of ROM selection. The four ROMs are:
          ROM 0: 128k editor, menu system and self-test program
          ROM 1: 128k syntax checker
          ROM 2: +3DOS
          ROM 3: 48 BASIC
  Bit 3: Disk motor; 1=on, 0=off
  Bit 4: Printer port strobe.
When special mode is selected, the memory map changes to one of four
configurations specified in bits 1 and 2 of port $1ffd:
         Bit 2 =0    Bit 2 =0    Bit 2 =1    Bit 2 =1
         Bit 1 =0    Bit 1 =1    Bit 1 =0    Bit 1 =1
  $ffff +--------+  +--------+  +--------+  +--------+
        | Bank 3 |  | Bank 7 |  | Bank 3 |  | Bank 3 |
        |        |  |        |  |        |  |        |
        |        |  |        |  |        |  |        |
        |        |  | screen |  |        |  |        |
  $c000 +--------+  +--------+  +--------+  +--------+
        | Bank 2 |  | Bank 6 |  | Bank 6 |  | Bank 6 |
        |        |  |        |  |        |  |        |
        |        |  |        |  |        |  |        |
        |        |  |        |  |        |  |        |
  $8000 +--------+  +--------+  +--------+  +--------+
        | Bank 1 |  | Bank 5 |  | Bank 5 |  | Bank 7 |
        |        |  |        |  |        |  |        |
        |        |  |        |  |        |  |        |
        |        |  | screen |  | screen |  | screen |
  $4000 +--------+  +--------+  +--------+  +--------+
        | Bank 0 |  | Bank 4 |  | Bank 4 |  | Bank 4 |
        |        |  |        |  |        |  |        |
        |        |  |        |  |        |  |        |
        |        |  |        |  |        |  |        |
  $0000 +--------+  +--------+  +--------+  +--------+
RAM banks 1,3,4 and 6 are used for the disc cache and RAMdisc, while Bank 7
contains editor scratchpads and +3DOS workspace.

