Emulating floppy drives on the Spectravideo SV-318

So in the previous article I upgraded my SV-318 from 16KB of CPU RAM to 64KB of CPU RAM. But I really wanted to emulate the floppy disk controller on the Spectravideo. If you are familiar with the early Spectravideo’s you may assume that this is a silly goal. More on that later.

So if you read some of my earlier posts including Emulating ROMs and floppy drives in MSX , you’ll see that I had already done most of the hard work towards emulating a floppy drive for the Spectravideo. The SV-318/328 machines use the same floppy controller that was commonly used in the MSX standard machines. This is the WD179X or WD279X floppy disk controller chips. Most MSX machines mapped the FDC to a memory mapped address, whereas the Spectravideo has it at 0x30 in the IO address space.

Unlike MSX there is no disk ROM. The built in ROMs in the SV-318 and SV-328 have enough code to talk to the FDC and load something in.

The IO Map for the FDC looks like this

0x30 - 0x33    WD1793 FDC
0x34           Write = drive select and motor control
               Read = DRQ and INTRQ
0x38           Write = Density and Side selection

So it’s a similar polling type setup that MSX does. Other interesting stuff is that the original SV-902 floppy drive was 40 track single sided. Later on there were double sided 40 track drives. The key thing for the FDC emulation is how the data is organised on each track.

For single sided disks:

track 0           18 sectors of 128 bytes FM
track 1 - 39      17 sectors of 256 bytes MFM

For double sided disks:

track 0 side 0    18 sectors of 128 bytes FM
track 0 side 1    17 sectors of 256 bytes MFM
track 1 - 39      17 sectors of 256 bytes MFM (both sides)

Per all my earlier attempts, I’m using a cheap  STM32F407 board wired directly into the expansion port of the SV-318. This is a lot easier to do for someone without much experience (compared to hooking it up to an MSX computer). You just need an edge connector with some header pins soldered to it. Then run some jumper wires to the STM32F407 board.









Again, I’m using lot’s of floating point registers as integer globals to increase the speed of the assembly code. It is almost a direct copy /paste of the MSX code with lots of bits deleted since I’m not doing any memory emulation.

The basic setup is to format a micro SD card with FAT32. Create a ‘spectravideo’ directory in the root of the micro SD. Put some disk images in this directory. So far I’ve tested with .dsk images for single sided and double sided disks. The images I’ve found are either 172032 bytes long for single sided, or 346112 bytes long for double sided.

It will load the first disk image on boot. A good one to test with is the ‘Disk BASIC’ disk. You should see a message about ‘Disk BASIC’ on the screen if it’s working OK. You can then press F1 to get a file listing. If you wire a push button to PA2 of the STM32F407 board you can cycle through the disk images (just wire a pushbutton between PA2 and GND). Similarly there is a PREVious button that you can connect to PA3.

I’m currently using one of these DevEbox boards with an LED wired to PA1 … so PA1 will flash if there are issues loading from the Micro SD.






So now that I had floppy disk emulation working (with save working as well) I started to try to find disk images I could use to further test it. Herein lies the problem. There are very very few disk images for the SV-318 and SV-328 on the internet. So far I have less than 10 total and most of those are CPM disks.

















Source is available at https://github.com/kernelcrash/spectravideo-floppy-emulator