Over the years, a lot of hardware has been released to improve various aspects of the Spectrums. Here I'm going to attempt to give some information on each as well as eventually technical details and maybe example code for using the hardware. This is a section only just started, not much info at all but send it in if you know it and be patient if you can.
Other external links that will be useful are:
In the following table, L=Left, R=Right, U=Up, D=Down, and F=fire. ?=unused - depends on the interface or port used, but it will probably be a 1 (Kempston should leave unused bits as 0). All port values are in decimal.
Joystick Type | Port | Bit meaning | |||||||
---|---|---|---|---|---|---|---|---|---|
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | ||
Kempston | 31 | ? | ? | ? | F | U | D | L | R |
Sinclair Interface 1(=128 port2) | 63486 | ? | ? | ? | F | U | D | R | L |
Sinclair Interface 2(=128 port1) | 61438 | ? | ? | ? | L | R | D | U | F |
Cursor | Cursors! | ? | ? | ? | ? | ? | ? | ? | ? |
Protek (works as Kempston?) | ?? | ? | ? | ? | ? | ? | ? | ? | ? |
There have been a few attempts over the years to bring mice to the Spectrum, they all worked but some gained more support than others. If you are thinking of coding a routine for one, I've already got a cool generalised input detect/ select for mouse, I just need the routine for the AMX (don't own one ya see!)
The 'Kempston Mouse' can mean one of two things. It's either the special mouse interface (I think usually comes with Kempston joystick port too) that might have a thru-port, or a mouse plugged into a normal Kempston joystick port and controlled with more software. Either way, it's an Amiga 2-button mouse. The assembler driver to control the joystick-port way of doing it is available and details for reading the other type are below.
Reading the mouse button port usually gives 255 decimal, but bits 6 and 7 are inverted (reset) when the button is pressed like the Spectrum keyboard ports - see below. There are two different ports you can read to find the info (both in decimal below).
Ports | Meaning | port 64479/4929 | Mouse X coordinate (0-255) |
---|---|
port 65503/1951 | Mouse Y coordinate (0-255) |
port 64223/1751 | Mouse button (252-255) Usually 255, bit 0 is zero when the right button is pressed; bit 1 is zero when the left button is pressed. |
The AMX mouse is the only one emulated under Z80, and uses interrupts to read and interpret the clicks from the direction or mouse buttons. It has a PI/O in the interface which you need to control yourself. Info here is from Z80's "techinfo.doc".
Port | Meaning |
---|---|
#1F(31) | Data A |
#3F(63) | Data B |
#DF | mouse button |
The AMX interface uses a Z80-PIO (programmable In/Out Interface). This chip is fairly complicated, and can operate in several modes. The AMX interface only uses mode 1 (no connection with IM 1 by the way), so this is the only mode that is emulated. The following discussion applies to mode 1 only, and refers to the I/O addresses as used by the AMX mouse interface. The PIO contains two 8-bit interrupt vector registers (VECA and VECB), two 2-bit mode registers (MODEA and MODEB), two 8-bit data registers (DATAA and DATAB), and two 1-bit interrupt-enable latches (IEA and IEB). The data registers can be read at any time through IN ports #1F and #3F respectively. (Note that #1F is also used by the Kempston joystick interface, and also by the Disciple interface, and that #3F is also used by the Multiface.) The other registers cannot be read, only set, through the write-only control register CTRLA and CTRLB, accessed via OUT port #5F and #7F respectively: Bit 7 6 5 4 3 2 1 0 ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿ WRITE³ interrupt vector ³ 0 ³ Set interrupt vector ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ Bit 7 6 5 4 3 2 1 0 ÚÄÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿ WRITE³ IE ³ x ³ x ³ x ³ 0 ³ x ³ x ³ 1 ³ Set IE latch ÀÄÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ Bit 7 6 5 4 3 2 1 0 ÚÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄÂÄÄÄ¿ WRITE³ MODE ³ x ³ x ³ 1 ³ 1 ³ 1 ³ 1 ³ Set PIO mode ÀÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÁÄÄÄÙ If IEA or IEB are set (1), the corresponding interrupt sequences will generate interrupts when prompted by the hardware, and put the corresponding interrupt vector on the data bus at interrupt time. In Z80 Interrupt mode 2, this will then be used as a vector. Note that bit 0 of the vector byte is always 0. Z80 only emulates PIO mode 1 behaviour (bit 7=0, bit 6=1 when setting PIO mode), and won't do anything if the mode is set differently. The AMX interface generates an A interrupt for each 'mickey' the mouse produces in the X direction, and a B interrupt for each mickey in the Y direction. The sign of the direction is stored as a 0 (positive) or 1 (negative) in the respective data registers. One additional port, IN port #DF, reads out the mouse button status. It returns #FF or #00. The AMX is emulated as follows. At every 50 Hz frame, the mouse status is checked, and a PIO interrupt is emulated if necessary. The IRET instruction is trapped, and if caught, more PIO interrupts are emulated if necessary, after actually executing the IRET, with a maximum of 32 interrupts per frame per coordinate. Care is taken to execute the 50 Hz frame interrupt as well. This latter interrupt can be distinguished from PIO interrupts by the fact that it puts a #FF on the bus. It was also necessary to take care of cases where the first instruction executed after a RETI was a HALT, which is then skipped. It seems that the PIO leaves the Z80 in peace for a few clock cycles after seeing a RETI, before generating another interrupt. A reset signal causes the IE latches of the PIO to reset.
An absolutely wonderful piece of kit for using 3.5-inch Double Density Double Sided drives with your Speccy. It's got quite a nice Dos and it's very well used especially in England so there's lots of support for it. I've devoted a whole page to it!
I think #1F port is used for something? Just a very faint vague guess.
This is a fairly new disk interface that takes the Speccy beyond where it should go. DMA, clock (optional), up to 512kb memory, works with old games by trapping tape loading calls... It speaks for itself. The datasheets for the DMA chip and RTC are available but programming information/system interfaces are still mainly in Czech. I now have the technical manual!
Multifaces are an indispensable item for every gamesplayer ever to own a Speccy. I'm sure you know about them - interrupt a Speccy game at any point and change memory, or use it's RAM to store small programs (for hacking ) or for other data.
I've got the programmer's help sheet ready to type the info from, should be arriving here soon. I had the MF3 so am not so sure about ports for other Multifaces. Ports could be #5F and #7F.
To enable your own routines to run in a Multiface, you need to set the following values in the MF memory:
Hex | Decimal | Data | Ascii equivalent | ||
---|---|---|---|---|---|
&2000 | 8192 | Low byte of code start | |||
&2001 | 8193 | High byte of code start | |||
&2002 | 8194 | 0 | (zero) | ||
&2003 | 8195 | &52 | "R" | ||
&2004 | 8196 | &55 | "U" | ||
&2005 | 8197 | &4E | "N" |
Remember that once the red button has been pressed, the MF RAM occupies the space the Spectrum ROM used to and so you cannot directly call ROM routines from there. You need to call them via the RAM above 16384.
To page the MF RAM in or out, read from the specified ports below, for example using
IN A,(xx)
in machine code (use IN to page both in and out...). To re-enable
the stop button for normal operation, OUT to the port (eg OUT (xx),A
). The
Multiface 3 has less space than the others for usable RAM, as you can see.
Ports/Addresses | Meaning | ||
---|---|---|---|
MF1 | MF128 | MF3 | |
&3F | Page In MF | ||
#7F? | &BF | Page Out MF | |
#7F? | &BF or &3F | Re-enable Stop button | |
&260B(9739) | First RAM address usable | ||
&3FD7(16343) | Last RAM address usable | ||
Programming the Speccy
Speccy Techy Index
Speccy Intro
File last updated: 19 February 2000
Author: John Garner /
john@breezer.demon.co.uk