ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Show us what you're working on, (preferably with screenshots).
Post Reply
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by dfzx »

This is my latest hardware project, a recreation of the ZX Spectrum Expansion System from 1984.

Image

The original expansion system bought you a Microdrive and the Interface 1 required to connect it to the Spectrum. My system is a single box which provides 8 virtual Microdrives with no Interface 1 required. The virtual Microdrives use MDR-format cartridge images delivered from a micro SD card.

The system is, to my knowledge, completely compatible with all Microdrive-supporting software from the 1980s. There are no workarounds, ROM hacks or limitations. All my operational design cues were taken from the way the original Microdrive works, so cartridges are inserted and ejected, write protect behaves the same way as the original and so on. Read and write operations (e.g. LOAD* and SAVE*) all work as expected. Use of the MDR format makes the virtual cartridges compatible and interoperational with emulators which support Microdrives.

I made a short demonstration video:



As ever with my work, it's open source and open design, licenced under the GPL. There's lots more information on my website, and the sources are on Github.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
PeterJ
Site Admin
Posts: 6879
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by PeterJ »

Brilliant @dfzx,

Congratulations in removing the need for a real interface one.

Peter
User avatar
flatduckrecords
Manic Miner
Posts: 787
Joined: Thu May 07, 2020 11:47 am
Location: Oban, Scotland
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by flatduckrecords »

Congratulations and thanks for sharing/open sourcing @dfzx. I read through the technical description with great interest (it is a truth universally acknowledged, that a man in possession of a spare Pico, must be in want of a good project).

My favourite part is the aluminium face-plate. ๐Ÿ‘จโ€๐Ÿณ๐Ÿ‘Œ perfection.
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by dfzx »

flatduckrecords wrote: โ†‘Fri Jul 21, 2023 11:18 am My favourite part is the aluminium face-plate. ๐Ÿ‘จโ€๐Ÿณ๐Ÿ‘Œ perfection.
You have no idea how many times I checked my workings when I created the design for that! It would have been seriously annoying if it had come back from the fabricators and the LEDs didn't line up with the holes... :lol:
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
TomD
Manic Miner
Posts: 379
Joined: Tue Nov 13, 2018 9:47 am
Location: Leeds UK
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by TomD »

Looks great, nice work.

Was interested in your experiments with Pico to Pico comms. Shame SPI didn't work as it seems perfect for this. Was wondering if you tried I2C?
Retro enthusiast and author of Flynn's Adventure in Bombland, The Order of Mazes & Maze Death Rally-X. Check them out at http://tomdalby.com
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by dfzx »

TomD wrote: โ†‘Fri Jul 21, 2023 2:14 pm Was interested in your experiments with Pico to Pico comms. Was wondering if you tried I2C?
I'd expect I2C to work well, given it's framed and clocked, but I really needed a faster link. I need to get the MDR file image (135KB) from the SD card to the Pico that delivers the data to the Spectrum as quickly as possible. On the original system you didn't have to wait for a cartridge to insert, it was ready the moment you pushed it into the drive. That's the usage pattern I was aiming for.

In the course of this work I created a new project which isolates that PIO-based Pico to Pico link so I could experiment with it. It's here, it's not particularly well written up but you might find it interesting.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
jpnz
Manic Miner
Posts: 324
Joined: Tue Nov 14, 2017 4:07 pm
Location: Hamilt[r]on - City Of The Future - NZ

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by jpnz »

Nice project!

Would it be suitable for use with Ian Collier's modified Interface 1 ROM ?

There was also a physical experiment a while back, having 10 micro drives in operation by patching the ROM to support 16 - in theory this could be more

May need some more LEDs :)
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by dfzx »

jpnz wrote: โ†‘Tue Jul 25, 2023 11:35 am Would it be suitable for use with Ian Collier's modified Interface 1 ROM ?
I was unaware of that modified ROM project. A brief look at the notes that come with it suggest it would work fine. My code does assume the cartridge is formatted in the headerblock/gap/datablock pattern the IF1 ROM code uses. Anything else might confuse it. That modified ROM doesn't change anything so fundamental (and nor does anything else I'm aware of) so I'd expect it to work.
jpnz wrote: โ†‘Tue Jul 25, 2023 11:35 am There was also a physical experiment a while back, having 10 micro drives in operation by patching the ROM to support 16 - in theory this could be more

May need some more LEDs :)
Yes, the maximum number of microdrives is only limited by a setting in the IF1 ROM software and, I'm guessing, the voltage drop of the signals along the line. I'd need to change my NUM_MICRODRIVES macro and recompile my code, but then I'd expect it to just work. But yes, only the first 8 microdrives would get activity LEDs. :)
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
zx-heinz
Drutt
Posts: 28
Joined: Fri Dec 02, 2022 6:16 pm

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by zx-heinz »

Look here https://forum.tlienhard.com/phpBB3/view ... 106#p60106! Your IF got another brother! :D
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by dfzx »

zx-heinz wrote: โ†‘Mon Aug 28, 2023 10:01 pm Look here https://forum.tlienhard.com/phpBB3/view ... 106#p60106! Your IF got another brother! :D
Oh, man.... That gave me almost as much of a buzz as when I got own working. Obligatory dancing banana: :dance
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
zx-heinz
Drutt
Posts: 28
Joined: Fri Dec 02, 2022 6:16 pm

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by zx-heinz »

Thanx for assistance!
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by dfzx »

There's a debate going on about my device, in German, over here.

I'm not going to try get into a Google Translate based argument on that website, but there is plenty on nonsense being stated there about how my interface works, like this (via Google Translate):

"Unfortunately, Derek took a shortcut. It does not simulate the original interface but returns the contents of the SD card straight away, which is significantly faster. The if1bis can do that more compactly, with rs232 and much more."

The statement quoted above is wrong in a couple of ways. I'll add some clarifications here in case anyone is ever interested.

I do not return the contents of the SD card straight away. I initially read the contents of the MDR cartridge image into a memory cache (at the "cartridge insertion" point of the GUI) and use that cache to simulate the "tape". My interface works at the Z80 instruction level. It spots the IN and OUT instructions as the Z80 issues them and makes the appropriate read and write accesses from that memory cache. When connected to the Z80, my interface passes data via the CPU's data bus in exactly the same way as the original hardware does. I do not use a hacked ROM, I use an exact binary image of the machine code in the Interface One's ROM. That's how I get 100% compatibility: I'm using the exact same software, and hardware which is identical to the Z80 at address-, data- and control-bus level.

The reason my interface runs significantly faster than the original Microdrive is simply because it doesn't need to wait for the tape to run past. When the code in the IF1 ROM wants the next sector on the tape, the original hardware needs to wait for the tape to move along. On my device the software in the Pico can make the first byte of the next sector available as soon as the IF1 code wants it. I still simulate the format of the cartridge, so I present the various "gaps" from the surface of the tape in the same way the Microdrive does, but other than that my interface runs at the maximum speed the Z80 code in the IF1 ROM can run at. My interface loads Manic Miner in about 2 seconds, which is as fast as the IF1 code can load it (and no faster).

I did not take a shortcut. There are a couple of ways to implement an IF1/Microdrive emulation. One is to essentially emulate the IF1 ULA and the signals it receives from the Microdrive hardware. That would indeed have the advantage of hardware compatibility. The second method is to simulate (rather than emulate) the Microdrive's function at the MDR file level. That's what the FUSE emulator does, and in fact my code started off based on a port of the FUSE emulator code to the Pico SDK. Either approach should work, both have their merits and drawbacks. I chose the second approach. I did not see the lack of hardware compatibility as a drawback, I didn't want that. Some might disagree.

The comparison made to the if1bis is therefore somewhat moot, but just for the record I'll explain. The if1bis uses a modified ROM and works at the IF1 "hook code" level which it reimplements for SD card access. Hook codes are standardised and documented entry points to the IF1 ROM (read sector, write sector, erase, start motor, etc). There are 26 of them. Any program which uses hook codes should be compatible with standard Microdrive operations, including the extended BASIC interpreter, and that is the level the if1bis works at. This is fine for most programs, but will fail for anything written in machine code which bypasses the hook codes, uses non standard entry points in the ROM, or uses its own code for, for example, higher capacity formatting. Paul Farrow's ZXC3 ZX Microdrive-mimicking cartridge works at this level too, reimplementing the hook codes for his flash storage. Those devices do not claim 100% compatibility which is fair enough. I do claim it. My code doesn't reimplement anything. It works at the individual Z80 instruction level using the original IF1 ROM code and as far as I know I'm compatible with everything ever written for the Microdrive.

One more point: I did not implement the network and RS232 features of the IF1, simply because I didn't want them. There's no reason they can't be added. In fact, the FUSE code I based on has them, and I actually took those features out in order to simplify the code so I could understand it. So it's not so much about adding those features as putting them back in. :) Right now I have no plans to do it, but if someone asks, or I need another project, I might well do it.

Right. I've set the record straight, just in case anyone cares. :)
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
Jbizzel
Dynamite Dan
Posts: 1537
Joined: Mon May 04, 2020 4:34 pm
Location: Hull
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by Jbizzel »

flatduckrecords wrote: โ†‘Fri Jul 21, 2023 11:18 am My favourite part is the aluminium face-plate. ๐Ÿ‘จโ€๐Ÿณ๐Ÿ‘Œ perfection.
Only a man with an intimate knowledge and history of the z88 could have designed a peripheral with such a face plate ;)

I love it. Awesome project Derek.
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by dfzx »

Jbizzel wrote: โ†‘Fri Nov 03, 2023 8:31 pm Only a man with an intimate knowledge and history of the z88 could have designed a peripheral with such a face plate ;)
LCD display, enclosed in black plastic, with a silver face plate... I hadn't actually thought about it, but, now you mention it, yes, there's definitely a theme there. :)
Jbizzel wrote: โ†‘Fri Nov 03, 2023 8:31 pm I love it. Awesome project Derek.
Thank you! At least 3 other people have made them, which gratifies me. It's nice to spread the ZX love. :dance
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
PeterJ
Site Admin
Posts: 6879
Joined: Thu Nov 09, 2017 7:19 pm
Location: Surrey, UK

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by PeterJ »

Do you have any plans to produce these and sell them @dfzx?
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by dfzx »

PeterJ wrote: โ†‘Sat Nov 04, 2023 11:18 am Do you have any plans to produce these and sell them @dfzx?
I did think about it, but I figured there probably wasn't enough interest to justify the effort. They would be quite expensive. With 3 PCBs, 3 Picos and quite a few other bits and pieces, there's about ยฃ35 of components in there before you even think about the 2 days it would probably take me to make one from scratch. It's a complicated device.

It took me about 6 months of full time effort to get the design correct and all 3 pieces of software working. There was quite a learning curve at the start of that process because I didn't know how to do most of what I ended up doing. So by the time I finished it I was quite glad to put it down for a while. Several months on, I'm now thinking about picking it up again. I need to rework it to use the much smaller "stamp" style Picos, which will make it single board, and the board will be much smaller and simpler. That version might be a more practical proposition to sell.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
+3code
Manic Miner
Posts: 433
Joined: Sat Mar 19, 2022 7:40 am

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by +3code »

When I heard of a "ZX Expansion Expansion System", I remember something like https://worldradiohistory.com/hd2/IDX-U ... e-0024.pdf
dfzx
Manic Miner
Posts: 683
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by dfzx »

+3code wrote: โ†‘Sat Nov 04, 2023 7:50 pm When I heard of a "ZX Expansion Expansion System", I remember something like https://worldradiohistory.com/hd2/IDX-U ... e-0024.pdf
Blimey, that's a thing to have hanging out the back of a Spectrum!

The rest of us were thinking of this one. :)
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
User avatar
+3code
Manic Miner
Posts: 433
Joined: Sat Mar 19, 2022 7:40 am

Re: ZX Spectrum Expansion System Recreated (IF1 and Microdrive hardware emulator)

Post by +3code »

dfzx wrote: โ†‘Sat Nov 04, 2023 8:23 pm Blimey, that's a thing to have hanging out the back of a Spectrum!

The rest of us were thinking of this one. :)
I found it in some Spanish retro-computing forum, I can't remember now where, the complete first part is here: https://www.worldradiohistory.com/UK/El ... ocessor%22

PS: Fun quote: "The ridiculously popular ZX Spectrum has been mostly left out of all this co-processing fun. This is mainly because it was never designed for serious expandability and so the designer of a suitable co-processor is forced to start from nothing. However, there are a great many Spectrums out there - some feeling very lonely and dejected, wanting nothing more than a little companionship. So, here comes the ETI Spectrum Co-processor to the rescue!"
Post Reply