[Frequently Asked Questions] [Resources] [Emulators] [Where Is...?] [File Formats] [Technical Information] [Pinouts] [Acknowledgements]


This page last updated on 20 May 1999

[Z80 Tech Info] [48K Tech Info] [128K Tech Info] [Peripheral Ports]

[Z80 CPU] [CB ops] [ED ops] [DD/FD ops] [R reg] [Undocumented flags] [Interrupts]
[Channels & Streams]
[Hardware] [Port FE] [The 48K Spectrum] [Contended Memory]
[Interface 1] [Port E7] [Port EF] [Port F7]
[The 128K/+2 Spectrums] [Memory] [Keypad] [Sound chip]
[The +2A/+3 Spectrums] [Memory] [Disk drive]


The 128K machine is similar to the 48K machine, but with the extra memory, which is accessed by paging it into the top 16K of RAM, and some timing differences:

Note that this means that there are 70908 T states per frame, and the '50 Hz' interrupt occurs at 50.01 Hz, as compared with 50.08 Hz on the 48K machine. The ULA bug which causes snow when I is set to point to contended memory still occurs, and also appears to crash the machine shortly after I is set to point to contended memory.


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 5B5Ch (23388) must be kept updated with the last value sent to port 7FFDh. It is not possible to read this port.

On the 128 and +2, memory is entirely controlled by port 7FFDh. The byte to output will be interpreted thus:

Bits 0-2RAM page (0-7) to map into memory at 0C000h
Bit 3Select 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 4ROM select. ROM 0 is the 128k editor and menu system; ROM 1 contains 48k BASIC.
Bit 5If set, memory paging will be disabled and further output to this port will be ignored until the computer is reset.

The memory map of these computers is:

FFFFh +--------+--------+--------+--------+--------+--------+--------+--------+
      | Bank 0 | Bank 1 | Bank 2 | Bank 3 | Bank 4 | Bank 5 | Bank 6 | Bank 7 |
      |        |        |(also at|        |        |(also at|        |        |
      |        |        | 8000h) |        |        | 4000h) |        |        |
      |        |        |        |        |        | screen |        | screen |
C000h +--------+--------+--------+--------+--------+--------+--------+--------+
      | Bank 2 |        Any one of these pages may be switched in.
      |        |
      |        |
      |        |
8000h +--------+
      | Bank 5 |
      |        |
      |        |
      | screen |
4000h +--------+--------+
      | ROM 0  | ROM 1  | Either ROM may be switched in.
      |        |        |
      |        |        |
      |        |        |
0000h +--------+--------+

RAM banks 1,3,4,6 and most of 7 are used for the silicon disc; the rest of 7 contains editor scratchpads.

Memory banks 4-7 are contended, i.e. the processor shares them with the ULA. This reduces the speed of memory access in these banks. Port #FE is still contended, and port #7FFD also causes contention, although the precise details of this are not known.

An example of a typical bank switch on the 128 is:

     LD      A,(5B5Ch)       ;Previous value of port
     AND     0F8h
     OR      4               ;Select bank 4
     LD      BC,7FFDh
     LD      (5B5Ch),A
     OUT     (C),A

The principle is the same for all bank switching: change only the bits you need to.

The contended memory timings for these machines are similar to that for the 48K machine, except that the 6,5,4,3,2,1,0,0 pattern starts at 14361 T-states after the interrupt, as opposed to 14335.


The 128K machine's keypad extra editing facilities are also available via the normal keyboard:

                 FUNCTION                        KEYS
                 Beginning of next word          [E] [S] J
                 Beginning of previous word      [E] I
                 Up ten lines                    [E] P
                 Down ten lines                  [S] I
                 Start of line                   [E] [S] 2
                 End of line                     [E] M
                 First line                      [E] N
                 Last line                       [E] T
                 Screen                          [E] [S] 8
                 Delete this character           [E] [S] K
                 Delete word left                [E] E
                 Delete word right               [E] W
                 Delete to start of line         [E] K
                 Delete to end of line           [E] J

                 [E] = Extended Mode
                 [S] = Symbol Shift
Sound Chip

The AY-3-8912 sound chip is a widely used one, to be found in the MSX, Vectrex, Amstrad CPC range, etc. It is controlled by two I/O ports:

OUT (0FFFDh)   - Select a register 0-14
IN  (0FFFDh)   - Read the value of the selected register
OUT (0BFFDH)   - Write to the selected register

There's a guide to how to use the registers at this site - this is for the CPC, so the I/O commands used will be different, and on the Spectrum register 14 is used for the serial ports rather than the keyboard as on the CPC. There is also an excellent load of info on the AY chip in the techinfo.doc file accompanying the Z80 emulator.

The Fuller Box also used the AY-3-8912, with port #3F used to select registers and #5F for data. The Fuller Box joysticks were connected to port #7F.

The Timex TS2068 is one of the Spectrum clones and also had an AY chip, using port #F5 to select registers and #F6 for data. For a more complete list of TS2068 ports, see the TS2068 ROMs file (to be found on NVG).

Typically, the AY chip is written to inside 128K games using:

LD BC,#FFFD      01 FD FF
OUT (C),D        ED 51
LD B,#BF         06 BF
OUT (C),E        ED 59

To convert to a TS2068 poke a few values as follows:

LD BC,#FFF5      01 F5 FF
OUT (C),D        ED 51
LD C,#F6         0E F6
OUT (C),E        ED 59

If you've got a Fuller box, you can do the same mod, replacing F5 with 3F and F6 with 5F.


The +2A/+3 share the same timing information, sound chip, etc as the 128K/+2 machines; see above for details.

Bit 6 of port #FE of the +2A/+3 does not show the same dependence on what was written to port #FE as it does on the other machines, and always returns 0 if there is no signal. Finally, reading from a non-existing port (eg #FF) will always return 255, and not give any screen/attribute bytes as it does on the 48K/128K/+2.


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 7FFDh behaves in the same way as before, except that bit 4 is now the low bit of the ROM selection. The extra features are controlled by port 1FFDh. This port is also write-only, and its last value should be saved at 5B67h (23399).

Port 1FFDh responds thus:

  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 1FFDh:

       Bit 2 =0    Bit 2 =0    Bit 2 =1    Bit 2 =1
       Bit 1 =0    Bit 1 =1    Bit 1 =0    Bit 1 =1
 FFFFh+--------+  +--------+  +--------+  +--------+
      | Bank 3 |  | Bank 7 |  | Bank 3 |  | Bank 3 |
      |        |  |        |  |        |  |        |
      |        |  |        |  |        |  |        |
      |        |  | screen |  |        |  |        |
 C000h+--------+  +--------+  +--------+  +--------+
      | Bank 2 |  | Bank 6 |  | Bank 6 |  | Bank 6 |
      |        |  |        |  |        |  |        |
      |        |  |        |  |        |  |        |
      |        |  |        |  |        |  |        |
 8000h+--------+  +--------+  +--------+  +--------+
      | Bank 1 |  | Bank 5 |  | Bank 5 |  | Bank 7 |
      |        |  |        |  |        |  |        |
      |        |  |        |  |        |  |        |
      |        |  | screen |  | screen |  | screen |
 4000h+--------+  +--------+  +--------+  +--------+
      | Bank 0 |  | Bank 4 |  | Bank 4 |  | Bank 4 |
      |        |  |        |  |        |  |        |
      |        |  |        |  |        |  |        |
      |        |  |        |  |        |  |        |
 0000h+--------+  +--------+  +--------+  +--------+

RAM banks 1,3,4 and 6 are used for the disc cache and RAMdisc, while Bank 7 contains editor scratchpads and +3DOS workspace.

The contended memory timings differ on the +2A/+3 from the earlier machines; firstly, the timing differences mean that the top-left pixel of the screen is displayed 14364 T-states after the 50 Hz interrupt occurs, as opposed to 14336. The T-states (relative to the interrupt) at which delays occur are given in the following table:

      Cycle #    Delay
      -------    -----
       14361       1
       14362   No delay
       14363       7
       14364       6
       14365       5
       14366       4
       14367       3
       14368       2
       14369       1
       14370   No delay
       14371       7
       14372       6

and so on, until cycle 14490, when the display of the first scanline on the screen has been completed, and no more delays are inserted until 14589 (=14361+228) when the cycle repeats. The other difference occurs for instructions which have multiple 'pc+1' or 'hl' entries in the breakdown for the other machines: on the +2A/+3, these entries are combined into just one. This means that, for example, JR becomes pc:4,pc+1:8.

Like the base 128K machine, RAM banks 4-7 are contended. However, port #FE is not; whether ports #7FFD and #1FFD are contended is currently unknown.

Disk Drive

The disk drive on the +3 is controlled by three ports:

For more information on the uPD765A, see the CPC Guide section at the Unofficial Amstrad WWW Resource, as the Amstrad CPCs used the same FDC; the documents most relevant to the +3 are the first two in the 'Disks' section.

Another useful bit of information is that it is possible to add an Amiga 3.5" drive to a Spectrum +3 by simply wiring the pins by name and providing it with some external power source (which can be an Amiga PSU with increased amperage, used to power the entire +3 and external drive in one go). There is a public domain formatter around to format it to 720k - this is quite useful as 3" disks are now a rarity and were never that reliable.

The added advantage is that PC users equipped with a copy of Sydex's shareware package 22Disk can read these files into a PC too.

[Z80 Tech Info] [48K Tech Info] [128K Tech Info] [Peripheral Ports]


This FAQ is maintained by Philip Kendall; distribution is permitted only under the conditions specified in the copyright notice.
Primary site for this FAQ: http://www.ast.cam.ac.uk/~pak/cssfaq/index.html.