Sunday 7 July 2024

Using the ZX-IO with the Minstrel Expansion Bus

This is a ZX-IO module from David Stephenson (www.zx81keyboardadventure.com), a 24 bit input / output device for a ZX81 or Minstrel 3. 

Thank you to David for sending the PCBs and 8255 chip so I could try it out.

This uses the same ZX81 edge connector pinout as the Minstrel Expansion Bus, so can be plugged directly into that - http://blog.tynemouthsoftware.co.uk/2024/05/minstrel-expansion-bus.html

(ignore the shrouded connector, that was the only right angled one I had that was long enough).

This is an interesting take on an IO device as it is not actually an IO device. On Z80 systems, you normally have very distinct IO devices. These are accessed using the IO and OUT assembly instructions, and controlled by the /IORQ line (I/O request). RAM and ROM are accessed differently, using pretty much every other instruction and are controlled by the /MREQ line (memory request).

You would need a good reason to diverge from that, and well, there is one. The ZX81 does not have a way of accessing I/O devices directly from BASIC. You need to write short machine code segments. 

This is not that difficult, but can be a block for some users who would prefer to remain in BASIC land. 

See the Minstrel Joystick for an example of reading an input port from BASIC using 6 bytes of assembler - http://blog.tynemouthsoftware.co.uk/2024/05/minstrel-joystick.html

The ZX-IO uses an alternate technique. One which is quite normal on 6502 based systems, but less so on Z80 based systems. It uses memory mapped I/O. 

On something like the Commodore PET, there is an area of the memory map reserved for IO devices, in that case, E800-EFFF. In this range, there is no ROM or RAM, and those addresses are used by the VIA and PIA chips and on later machines, the CRTC.

Address Range
Use
0000-7FFF
(up to) 32K RAM
8000-8FFF
1K or 2K Video RAM
9000-AFFF
2 x 4K Option ROMs
B000-DFFF
BASIC ROMs
E000-E7FF
Editor ROM
E800-EFFF
I/O Range
F000-FFFF
Kernal ROM

The ZX81 memory map is full. Due to simplified address decoding, everything is used by ROM or RAM, or mirrors of those.

Address Range
Use
0000-1FFF
8K ROM
2000-3FFF
8K Non-BASIC RAM or ROM mirror
4000-5FFF
16K BASIC RAM
8000-9FFF
8K Non-BASIC RAM or ROM mirror
A000-BFFF
8K ROM Mirror
C000-DFFF
16K BASIC RAM mirror

The ZX81 has two useful pins on the edge connector, /RAM_CS and /ROM_CS*. These are connected to the chip select pins of the onboard ROM and RAM. They are fed via resistors so that if the pin on the edge connector is pulled to 5V, the ROM will be disabled.

* The ZX81, Minstrel 2 and Minstrel 3 all have /ROM_CS, but this pin is not connected on a real ZX80. You aren't using a real ZX80, are you?

This can be done permanently, say if you are making a 16K RAM pack and you want to disable the onboard 1K RAM which is located in the address range you want to use.

Or, it can be done selectively, as is used on devices such as the divMMC to replace certain areas of ROM code to add new BASIC commands.

This method is used to punch out an area of 4 bytes in the mirror copy of the system ROM. These 4 bytes are then replaced with the four registers in the 8255 IO chip on the ZX-IO.

Address
Use
Access
49148
Port A
Read / Write
49149
Port B
Read / Write
49150
Port C
Read / Write
49151
Control
Write Only

You can read more about this in a series of posts from David himself - https://www.zx81keyboardadventure.com/2023/02/zxio-interface-for-zx81-part-1.html

The point of doing it this way, is you can now easily access this from BASIC using PEEK and POKE.

For example, POKE 49151, 128 will setup the chip with all three 8 bit ports as output. The default is all 24 bits as inputs.

There are various modes of operation, refer to the 8255 datasheet for a full description - https://www.renesas.com/us/en/document/dst/82c55a-datasheet

POKE 49148, 255 will then set all the output bits of port A on.

If you happen to have some LEDs wired up, you can see the the results of those two commands.

Here are a few more examples of driving the LED board. The left hand 8 LEDs are on port A and the right hand is port B. Makes a nice VU meter, but I don't think it will be quite fast enough. Maybe a good candidate for one of those two player games? And you have 8 bits of port C left for controllers if you want.

This was a simple count up, but I complicated it by counting backwards on port B.

Port B didn't look right, so I reversed the video just to check.

We are in BASIC land here, and a floating point BASIC at that. So the mathematical of the operations take a while.

Here I used the ** operator to do two to the power of N, so I could have a moving dot.

As usual, I complicated it on port B. I wanted the dot and all the ones before that, which is 2^n-1, but, it's the next n, so it's actually ( 2^(n+1) ) -1.

And finally, it had to be done.

Blinkenlights.

As with the other examples, there are no delays here, this is running at full pelt in slow mode on a ZX81.


I have spoken to David (who is in Australia) and has problems shipping to the UK (yeah, sorry to the rest of the world. I didn't vote for it). 

The current situation means on SellMyRetro it is difficult for David to sell TO the UK and for me to sell FROM the UK. I can ship worldwide, but you need to contact me and tell me where and what you want and I can send you an appropriate invoice.

In order to make this available to people in the UK, I will be producing a Minstrel flavoured version. (so this post will probably be delayed whilst I design and order the boards). (Ed - still waiting to order the boards, I have posted this anyway as it may be a while before funds recover sufficiently to be in a position to invest in new products I'm afraid)

When I make kits like this, it is important to me that all the parts are still in production (looking at you Zilog......). The 8255 is surprisingly still in production (well I was surprised anyway as I thought it went out of production 30 years ago).

Almost $20 a shot, and they look like cheap knock offs. Rather disappointing. I might look at alternate suppliers or NOS, but that means I have to test each chip before shipping, rather than just batch testing as I normally can do when I am working with all new parts from reputable suppliers.

This is the one I was using for the test, or, this is how it looked when it arrived.

I accidentally brushed it with IPA when I was cleaning the board, and of course it had been black topped, so the paint rubbed off. Not sure what was underneath, it has been partly sanded, but it looks the same.

Dear China, please stop doing this. Thank you, everyone.


By the way, what do you think of the change to the connectors on the expansion bus?

I had been looking for suitable polarising pins, but this seems a more obvious way to show where the gap is.



Advertisements

The ZXIO V2 Experimenters Kit is available from David's site:

Various other bits for the Minstrel Expansion Bus are described here:

My store also contains the full range of Minstrel and Mini PET kits and accessories, contact me if outside the UK or US. Sorry I have to keep saying that. I am working on an alternative.

All the links can be found here:

Patreon

You can support me via Patreon, and get access to advance previews of posts like this and behind the scenes updates. These are often in more detail than I can fit in here, and some of these posts contain bits from several Patreon posts (they also got an extra post covering the development of this board). This also includes access to my Patreon only Discord server for even more regular updates.