sorgelig / ZX_Spectrum-128K_MIST

ZX Spectrum 128K for MIST Board
GNU General Public License v2.0
31 stars 18 forks source link

Spectrum +3 with disk support work in progress #10

Closed gyurco closed 7 years ago

gyurco commented 7 years ago

This is the +3 with the upd765 disk controller. This is not complete, since the disk image handling is completely missing. I couldn't figure out how to handle disk files, the wd1793 code is very cryptic for me. If you have a little time for some instructions, where should I start, I would be very thankful.

gyurco commented 7 years ago

I looked the code again, and if I understand correctly, the existing disk codes are reading-writing the SD card bypassing the FAT file system? And if the disk image is fragmented, it is possible that a write will corrupt other files?

sorgelig commented 7 years ago

MiST has 2 access modes. If no image is selected, then core has access to full SD card in raw mode. If any image has been selected, then core access only to that image. You don't need to worry about offsets except the size of image. LBA access to image goes through file access, so file can be fragmented or not - it doesn't matter - it always will have correct sector mapping.

You just need to add "S" option to OSD to let the user choose the file to mount.

So, does +3 DOS work for you already?

gyurco commented 7 years ago

Yes, the ram disc works perfectliy (drive M:), drive A: and B: returns an error on a read/write operation (since no image handling). So one less thing to worry about, just isn't there a simple example how to read/write an image? And another issue, I cannot add a new "Load +3 disk image" menu option, since it seems the OSD is full. A new option will make the last one disappear, so now I'm rewiring the sd_xxx connections depending on the plus3 switch, however it makes the beta interface useless in +3 mode, which sucks. But if I undestand correctly, one cannot mount two images at the same time? Then some kind of image auto-detection would be the best, .trd, .img, .mgt would work with the WD chip, .dsk with the NEC upd765 one. Sounds complicated...

sorgelig commented 7 years ago

MiST can display only 7 options - this is a big problem i suffered on MiST. In MiSTer i've expanded it to 15 options. Currently, i see the only way to fit into 7 options is doing autodetect as you described. In bits [7:6] of index, you can get a sub-index of image type which equals to position of extension in list.

I think, beta interface doesn't expect +3 hardware. So it's OK to split DOS'es between different HW. You even can change supported file extensions. You can see how i change some part of version depending on loaded disk. Thus only supported disk images will be displayed depending on chosen HW config.

I don't know what kind of example you want. Work with image is quite straight forward. Core sets LBA and RD/WR signals and then gets 512 bytes block through sdbuff* signals - they are directly connected to altsyncram - you can see it in wd1793. The main logic you need to implement - is preparing LBA offset. If FDD sector size is not 512 bytes, then you need to add additional logic to read/write part of block or multiple blocks at once. This mechanism is implemented in wd1793 - that's why it's a bit complicated.

MiST supports only one mounted image (MiSTer supports up to 4 images), so you cannot implement more than one disk with write capability, although you can load second disk like ROM into SDRAM and use it as read-only. This mode is supported in wd1793 - and this is another reason why it's complicated.

About pull request: this repository is considered as a master, ready for end-user. So, it's better if you will finish floppy part and +3 DOS support on your repository first, and only then create a pull request. This will make sure the master contains a working code.

gyurco commented 7 years ago

Ahh, ok, I'll try to use index [7:6]. Yepp, the original Beta didn't support +2A/3 (mostly because of the extra ROMs, and the two ROMCS lines), however in usr0 mode it works well with the MIST core, and I found it useful to load .trd files.

Meanwhile I managed to get some disk file read from the SD card, and get its contents via IN basic commands :) So I think I can handle it. However I don't think I'll implement two simultaneously mounted disks.

You're right, this is just work in progress, don't merge it, just wanted to show some work, and get a little help from you.