USIfAC II:Convert a PC or USB stick to Amstrad HDD,access dsk's,and many more!

Started by ikonsgr, 08:17, 01 December 20

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

ikonsgr

Quote from: VintageAdvantage on 17:35, 02 December 20
This is brilliant and a great example of what can be done if the MCU is fast enough - everything that requires extra glue logic chips for address decoding with slower MCUs can just be done in software with all these extra MHz's. Did you program the firmware in ASM or C? Good choice of the MCU.

Well, actually the extra logic needed for the required address bus and signal decoding, wasn't done in software at all (even at that speed, analyzing the required address bits and Cpu signals in software loops, would affect seriously responce and speed).
Instead i use an extra  feature of these Microcontrollers called "Configurable Logic Cells" or CLC's.
These are small programmable logic modules where you can assign type of logic (AND OR gates, Flip-Flops etc,and even combination of them), and set for, up to 4 inputs and an output. When module is activated (which can be done "on the fly" in microcontroller program) it will act like a real logic chip, e.g. have INSTANT responce on input signal changes!  :)
So,i design separate logic cell modules to accommodate various functions, like when Amstrad is addressed to Serial Port or Floppy disk controller,or when it reads upper rom or when gate array selects rom number (e.g. an out &DF00,x is sent from Gate Array chip). All in all, i needed to design 5 different logic modules, 4 for the above functions, and one "master" module ,that take the outputs of the other modules and gives a single ouput that pauses Amstrad (ready signal forced to '0') and enables Microcontroller program.
By doing that, the only thing that needs to run constantly on the PIC microcontroller, is a small loop for checking the output of master module, which can be done VERY fast, every ~0.15 usec! ;-)
I use cow basic as main tool for PIC program developing, which produce REALLY good and optimized asm code!  ;)
And finally, for anyone interested, you can find the assembly code for the main USIfAC II ROM, which holds the code for the dozens of  RSX commands ,in the attached file (this can also be very helpful for anyone wants to use the CH376 USB host module, as the documentation was not very good, it took me A LOT of testing and effort to finally make it work as it should...  :) ).
The binary of this code is placed inside a table into PIC's program.
I also used a "trick": When Amstrad reads from USIfAC II Rom and code reaches specific addresses,it jumps to start reading from first byte @&C000,while at the same time, Microcontroller program changes table to other tables (that hold large utlitites or the 3 games included). By doing that,i've managed to fit ~80kb of data into a 16kb address space of a single upper rom!

VintageAdvantage

Quote from: ikonsgr on 19:20, 02 December 20
These are small programmable logic modules where you can assign type of logic (AND OR gates, Flip-Flops etc,and even combination of them), and set for, up to 4 inputs and an output. When module is activated (which can be done "on the fly" in microcontroller program) it will act like a real logic chip, e.g. have INSTANT responce on input signal changes! 

That is interesting. How do you program these? Is that done from the MPLAB Microchip IDE?
And the main firmware is in BASIC? Wow! I should switch over to PICs...

So this is combinational logic only it seems. No Flipflops or Latches in the logic cells possible? It seems you still need to pause the Z80 via pulling READY to not "miss" the databus... correct?

ikonsgr

Quote from: GUNHED on 18:36, 02 December 20

Thanks a lot for your answer. Sorry, I don't know the usifac 2 as well as you. So don't bother if I ask something twice.
No bother at all my friend! I didn't remember the details too, but i remembered we had discussed the matter a few months ago, so i've made a quick search and gave you the link directly!  ;)

Quote from: GUNHED on 18:36, 02 December 20
About the X-DDOS ROM... the best one is attached to this post. See below.[/font]
Can we burn the chip on the card by myself to alter the ROM content? Maybe this would make things more easy for you

My friend, changing parados to X-DDOS rom, is half a minute work: Just convert the binary to a large pile of numbers with commas (i've already developed such a utility and used it all the time) ,and copy it into PIC's program in place of PARADOS table!  ;) 
If you have a PICKIT3 i can give you the custom HEX file with X-DDOS and burn it yourself easily, this time i add an ICSP connector to the board, so you can flash PIC directly on board!  ;)

GUNHED

Oh, the PIC is too new for my Vspeed Stager (2015). Maybe I can get a software update for it.


Do you have the ParaDOS at position 7 like the Amsdos? In this case I wouldn't need XDDOS. Need to read the USIfAC manual again...


Cant't wait to use it to emulate an real FDC.  :) :) :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

ikonsgr

Quote from: VintageAdvantage on 19:41, 02 December 20
That is interesting. How do you program these? Is that done from the MPLAB Microchip IDE?
Yes, these need to be configured through MPLAB's MCC (MPLAB Code Configurator),then i export the configuration file for each CLC and place it into Cow basic's source code, once you learn to do it it's rather easy task.

Quote from: VintageAdvantage on 19:41, 02 December 20
And the main firmware is in BASIC? Wow! I should switch over to PICs...
Yes,the source code for PIC microcontroller was made using COW Basic as i already told you. But the compiler produces a very good and optimized assembly code!
It's really a very good tool, which makes programming 8bit PIC's (especially for large complex projects as this one) a much easier and enjoyable task!  :)

Quote from: VintageAdvantage on 19:41, 02 December 20
So this is combinational logic only it seems. No Flipflops or Latches in the logic cells possible?
Well, not exactly. This is taken from PIC 18F47Q10 data sheet:
Possible configurations include:
• Combinatorial Logic:
– AND
– NAND
– AND-OR
– AND-OR-INVERT
– OR-XOR
– OR-XNOR
• Latches:
– S-R
– Clocked D with Set and Reset
– Transparent D with Set and Reset
– Clocked J-K with Reset


And there are 8 CLC's in total, enough to develop quite complex logic, don't you think?  :)
Practically it's like having a small CLPD or PAL inside Pic!  ;)

Quote from: VintageAdvantage on 19:41, 02 December 20It seems you still need to pause the Z80 via pulling READY to not "miss" the databus... correct?
Well since most of the tasks,when interface is enabled, usually need some microseconds, Amstrad must be paused.But the good thing is that the procedure of unpausing amstrad and unlatching data bus (after finishing the job),is made in "real time" without any added delays (like with previous usifac). And this is where the extra speed becasue of running at 64Mhz, really helped!  ;)

ikonsgr

Quote from: GUNHED on 19:59, 02 December 20
Oh, the PIC is too new for my Vspeed Stager (2015). Maybe I can get a software update for it.
Do you have the ParaDOS at position 7 like the Amsdos? In this case I wouldn't need XDDOS. Need to read the USIfAC manual again...
Cant't wait to use it to emulate an real FDC.  :) :) :)
Well, yes i suppose it does. If you give "|DOS,2" to select Parados for emulation, and then "|464" command, Amstrad will reset (in this state ,you can't use any RSX commands as upper rom 7 is exclusively points to either AMsods or Parados emulation tables) ,and any rom read from Upper ROM 7 will be done from Parados table inside PIC's code!
I could even run the parados utility program by giving |DRIVE, but of course, disk drive doesn't work. In this special mode, you can only access the dsk image you have previously selected.
I named this function |464 because its main purpose is to give a cpc464 the ability to access dsk images. And in order to do that, you need to "replace"-emulate both missing 765FDC and AMsods/parados rom chips. However, on Amstrad cpc664/6128 ,because Amsdos rom already exists, you only need to emulate 765FDC ("|FDC" command), in order to gain access on a dsk image . This offers speed (responce is a bit faster than using a real gotek/disk drive)  and you can also use all RSX commands too! What i found out though,is that you can also use this special mode for 464, with a cpc6128 too, in order to have access to parados dsk images (i demonstrate this in the presentation video too)! It's like having a rom switcher that provides both amsdos and parados!  ;)

ikonsgr

I took a look at the snapshot sna file structure, that some noted before, and i think it might be not too difficult to develop a routine for using them with Usifac II too.
But, as i never got involved with snapshots, and before i start, i would like to ask some things first:

- Is the ability to use sna files on real CPC, something useful for the average user or it's more of a tool, addressed to the advanced user/developer/programmer?

- I've noticed in sna archive that almost all snapshots are for CPC464. Does this mean, that their main usefulness concerns CPC464? And is this because quite a few games found in dsk images can't be loaded on a CPC464? (i've noticed this while testing usifac ii on CPC 464 too, some games ,for example Cauldron II or ikari warriors, couldn't load on CPC 464 , giving error messages or hang up/crash, while others, i had to "tamper" the basic loader listing to remove any "CPC6128" only commands they have)

-On the technical side, i suppose there must be a specific way to properly restore all the registers, counters and interrupts apart from memory dump. Can someone give me a rough "walkthrough" of how exactly i will do that? (i have a rough idea of how to restore registers from various chips using proper OUT commands but what about restoring interrupts or special counters of CRTC? And what about the order of restoring?)

- Finally, is there a way to create a snapshot on a real amstrad apart from using multiface II (although i'm not quite sure that snapshot files taken with multiface ii are the same as sna files...)? And how exactly could someone do that? Maybe activating NMI (non maskable interrupt) on Z80, and placing @&0066 RAM address, an RST3 call to a routine?

Gryzor

As a simple user I'd find snapshot support useful for those programs that refuse to load, for whatever reasons, from the device...

ikonsgr

Quote from: Gryzor on 21:00, 04 December 20
As a simple user I'd find snapshot support useful for those programs that refuse to load, for whatever reasons, from the device...

From the 100's of games/programs i've tested so far, the only ones i couldn't run was:
- Batman for ever demo single disk (gave me a "wrong disk configuration", but it works from normal 180kb image file)
- R-Type 128, at some point stops loading, (this was impossible for me to fix, what ever i tried... :( )
- Dragon Ninja, original, crashed after loading (but the cracked version works fine  ;D )

This means that,statistically, you can probably load, either directly from files or dsk images, more than 99% of existed games/programs.
So, if the only practical use of snapshot is a way of loading games that refuse to load, i don't think it would be very useful for USIfAC II...  ::)

XeNoMoRPH

@ikonsgr , with http://cngsoft.no-ip.org/cpcec.htm , takes custom snapshots of used memory: automatically detects if the first 64k is enough.
your amstrad news source in spanish language : https://auamstrad.es

ikonsgr

Quote from: XeNoMoRPH on 08:39, 05 December 20
@ikonsgr , with http://cngsoft.no-ip.org/cpcec.htm , takes custom snapshots of used memory: automatically detects if the first 64k is enough.

Ok,but i was talking of taking snapshots from a real CPC not  from an emulator.

Gryzor

If compatibility is so high then I guess it's a small luxury😊

Of course hunting for a version that will work is a waste of time, but now we're talking first world problems😁

Takis Kalatzis


First of all, congratulations for your excellent work regarding this board! It looks like the most straightforward way to have your entire collection at one USB stick and run everything from there!

As a happy owner of the excellent Duke's M4 board, I have some questions regarding USifAC II.


1. Since M4 has already the ability to load games (either from files or from .DSK), what are the benefits of running games/programs through USifAC? I guess the loading time will be faster, but will I be able to run programs that are not cracked? For example, I have not been able to run "The Pawn" through M4 in whatever version I tried.


2. Shall I need a Mother X4 board (or similar) in order to have both M4 and USifAC connected at the same time? My understanding is that they both use CPC's expansion port (and for those who have Mother X4: can I connect an M4 with an Edge Adapter directly on Mother X4 or will I need another cable/adapter?)


Keep up the good work!


Takis

ikonsgr

Quote from: Takis Kalatzis on 15:18, 06 December 20
1. Since M4 has already the ability to load games (either from files or from .DSK), what are the benefits of running games/programs through USifAC? I guess the loading time will be faster, but will I be able to run programs that are not cracked? For example, I have not been able to run "The Pawn" through M4 in whatever version I tried.

Well,i would say that, the most obvious difference is COST! USIfAC II is a LOT cheaper than a M4 board (~less than half the price);D
Also,i think that M4 doesn't offer the "direct mode" to load files directly from a usb flash drive instead from image containers, at least not at such great speeds of ~20kb/sec. (false assumption... :) )
Of course, M4 is a much more  powerful and modern/proffesional board (it uses very powerful ARM 32bit MCU and smd chips), and also, it's been developed for years ,offering many extra tools and functionality. USIfAC II it's more of a hobbyist "low budget" board. But if you see it from the "average Amstrad user" perspective, where the main thing they want, is an easy, fast and cheap way to load games, USIfAC II might be the best "Value for money" choice for that!  ;)
Especially for CPC 464 users, i think it's BY FAR the most affordable way to load easy and fast games compared to everything else on the market.

Quote from: Takis Kalatzis on 15:18, 06 December 20
2. Shall I need a Mother X4 board (or similar) in order to have both M4 and USifAC connected at the same time? My understanding is that they both use CPC's expansion port (and for those who have Mother X4: can I connect an M4 with an Edge Adapter directly on Mother X4 or will I need another cable/adapter?)
Keep up the good work!
Takis

Well,i suppose you could do that, but if you already have a M4 board, i don't find any reason for having a USIfAC II,unless you are an Amstrad collector and you want to have all existed hardware ...

ikonsgr

Quote from: Takis Kalatzis on 15:18, 06 December 20
I have not been able to run "The Pawn" through M4 in whatever version I tried.

You mean this game?
I found it in my collection, this is a 2 dsk image game, so you need a way to "change disks" in order to load it.
I don't know if you can change "on the fly" mounted images with M4, but currently you can't do that with USIfAC II. BUT, i happen to be in a process of developing such an ability for a future version (where you will be able to mount up to 3 dsk images, and "round" select them "on the fly" by pressing a small button like the one i have for RESET  :)) and i gave it a try. Game loaded just fine  ;D  (i've also test it with XYPHOBES (a 3 dsk image game!), Savage, OUT RUN europa and turbo out run, all 2 dsk image games, and also they seem to load fine!). Of course, only a very small portion of  games is more than a dsk image in size, and most of them ,(especially recent games)you can find them in  "big" single dsk images too (like the very good adventure "orion prime", which i've played it using a single 800kb image, instead of having 4 "normal" images), which USIfAC II also supports.
All in all, compatibility seems to be very good, out of 100's of games/demos i've tried only a few didn't seem to load. But even for these games you can usually find them in cracked versions which most probable will work!  :)

Duke

Quote from: ikonsgr on 20:51, 06 December 20
Also,i think that M4 doesn't offer the "direct mode" to load files directly from a usb flash drive instead from image containers, at least not at such great speeds of ~20kb/sec.

Quote
Well,i suppose you could do that, but if you already have a M4 board, i don't find any reason for having a USIfAC II, unless,perhaps, you want to load games even faster! 

Well you are wrong.
Just for the kicks I quickly wrote a simple basic test to measure the speed of accessing the microSD card via firmware on M4 board.
The speed after a 4 minute run is around 100 KB/s.

Unless my program is completely wrong, you could try it on your device aswell:

10 MEMORY &1FFF     
20 MODE 2
30 u = TIME
40 t = 0
50 a = TIME
60 FOR i=1 TO 10
70 LOAD"32KB_BLK.BIN",&2000
80 t=t+32
90 NEXT
100 b = TIME
110 PRINT 320/((b-a)/300);" KB/s - total : ",t;" KB/", (TIME-u)/300;" Sec"
120 GOTO 50

First save a 32KB block, ie. like this save"32KB_BLK.BIN",b,&2000,&8000
And you may want to start a timer next to it in case you have any interrupt disabling (I used my phone and ran the test for 4 minutes).

Also it could be much faster written in assembler and doing direct access. The microSD on M4 board is connected via SDIO 4 bit, its very fast if the card allows it ;)

Other than that. Congrats on your device, it looks promising - good job :)

ikonsgr

Quote from: Duke on 22:34, 06 December 20
Well you are wrong.
Just for the kicks I quickly wrote a simple basic test to measure the speed of accessing the microSD card via firmware on M4 board.
The speed after a 4 minute run is around 100 KB/s.
Unless my program is completely wrong, you could try it on your device aswell:
10 MEMORY &1FFF     
20 MODE 2
30 u = TIME
40 t = 0
50 a = TIME
60 FOR i=1 TO 10
70 LOAD"32KB_BLK.BIN",&2000
80 t=t+32
90 NEXT
100 b = TIME
110 PRINT 320/((b-a)/300);" KB/s - total : ",t;" KB/", (TIME-u)/300;" Sec"
120 GOTO 50

First save a 32KB block, ie. like this save"32KB_BLK.BIN",b,&2000,&8000
And you may want to start a timer next to it in case you have any interrupt disabling (I used my phone and ran the test for 4 minutes).

Also it could be much faster written in assembler and doing direct access. The microSD on M4 board is connected via SDIO 4 bit, its very fast if the card allows it ;)

Other than that. Congrats on your device, it looks promising - good job :)

100kb/sec? Wow!  :o  Although it  seems a bit... "too much",i mean, even copying a memory block in Amstrad's RAM  can't be faster than ~60-65kb/sec.... Unless you are using MCU's internal RAM and not Amstrad's ram.... ::)
Anyway, i would be surprised if your 32bit ARM "monster" with ~200MIPS "horse power", couldn't do less than that and be..."defeated" by my "puny" 8bit PIC, giving "only" 16MIPS.... :)

Bur since you got bother answering my ...."challenge"  :), perhaps you could clear up some things about M4:

- Apart from the above speed test, can M4 also run games/programs directly from files at such speeds? Because the ~20kb/sec USIfAC II can achieve,  is not just a speed test, but the ACTUAL average loading speed of REAL games!

- Does M4 is able to also take snapshots or only load ones? And could you give some details on how exactly you do that? (i never got involved with snapshots, so i would appreciate any help on that)

- Can M4 mount more than one dsk images and somehow select them "on the fly", for supporting "in game" disk (image) swapping? (i'm experimenting on that too with USIfAC II)

- Does M4 support dsk image access of large non AMSDOS formats, like the various  dual head and/or 80tracks PARADOS formats of up to 800kb?

Thanks again for looking at my "humble" project "master" Duke!   ;)

Duke

Quote from: ikonsgr on 01:11, 07 December 20
100kb/sec? Wow!  :o  Although it  seems a bit... "too much",i mean, even copying a memory block in Amstrad's RAM  can't be faster than ~60-65kb/sec.... Unless you are using MCU's internal RAM and not Amstrad's ram.... ::)
Actually as far as I remember we can move around 4KB of data per frame using ldi/ldir/stack on CPC, so that would amount to roughly 200 KB/s.

Quote
- Apart from the above speed test, can M4 also run games/programs directly from files at such speeds? Because the ~20kb/sec USIfAC II can achieve,  is not just a speed test, but the ACTUAL average loading speed of REAL games!
Yes, of course, there really isnt any difference.
Quote
- Does M4 is able to also take snapshots or only load ones? And could you give some details on how exactly you do that? (i never got involved with snapshots, so i would appreciate any help on that)
Yes, it can take snapshots via the HACK menu... The HACK menu source code is available here, if it can be of any help:
https://github.com/M4Duke/m4hackmenu

Quote
- Can M4 mount more than one dsk images and somehow select them "on the fly", for supporting "in game" disk (image) swapping? (i'm experimenting on that too with USIfAC II)
You can change .dsk´s using the web-interface. An option to do it via hack menu was planned...

Quote
- Does M4 support dsk image access of large non AMSDOS formats, like the various  dual head and/or 80tracks PARADOS formats of up to 800kb?
Yes it does. Ie. ROMDOS (D1/D2/D10/D20/D40) and PARADOS 80.

And lets not derail your thread even further, it should not be about M4 but your project, I only had to correct the incorrect assumptions :)

ikonsgr

Quote from: Duke on 02:40, 07 December 20
Actually as far as I remember we can move around 4KB of data per frame using ldi/ldir/stack on CPC, so that would amount to roughly 200 KB/s.
Do you have any video of loading a game directly from files? I would LOVE to see running a game in... half a second!  :)

Quote from: Duke on 02:40, 07 December 20
Yes, it can take snapshots via the HACK menu... The HACK menu source code is available here, if it can be of any help:
https://github.com/M4Duke/m4hackmenu
That's really could be great help! Thanks a lot for letting me know! One last question: to enable my "save snapshot" routine installed in interface's rom, i should place at boot (probable in the initialization routine of usifac's rom) an RST3 command @&66 ram address, so when NMI is activated, execution will  jump to &66 ,and from there, call my routine. Is this the correct approach?

Duke

Quote from: ikonsgr on 02:55, 07 December 20
Do you have any video of loading a game directly from files? I would LOVE to see running a game in... half a second!  :)
Sure, why not..
First example it loads a 38KB binary (zorro).
2nd example, I run Commando, save a 64 KB snapshot and reload it.
Both take less than 1 second.
Here you go:


Quote
That's really could be great help! Thanks a lot for letting me know! One last question: to enable my "save snapshot" routine installed in interface's rom, i should place at boot (probable in the initialization routine of usifac's rom) an RST3 command @&66 ram address, so when NMI is activated, execution will  jump to &66 ,and from there, call my routine. Is this the correct approach?
Yes you will need to have your NMI jump at &66, best is to map the area with your own lower-rom replacement.
Prior to that you will need to store the hardware regs so they can be retrieved once you enter your nmi rom/code.

Audronic

Procrastinators Unite,
If it Ain't Broke PLEASE Don't Fix it.
I keep telling you I am Not Pedantic.
As I Live " Down Under " I Take my Gravity Tablets and Wear my Magnetic Boots to Keep me from Falling off.

Duke


Audronic

Procrastinators Unite,
If it Ain't Broke PLEASE Don't Fix it.
I keep telling you I am Not Pedantic.
As I Live " Down Under " I Take my Gravity Tablets and Wear my Magnetic Boots to Keep me from Falling off.

GUNHED

Quote from: ikonsgr on 20:51, 06 December 20
Well,i suppose you could do that, but if you already have a M4 board, i don't find any reason for having a USIfAC II,unless you are an Amstrad collector and you want to have all existed hardware ...
Well, ...
- Real fast serial interface
- FDC emulation (of Vortex FDC too!!!)
- And if you want, to learn how to work with an external CPU
- Also much more I still don't know

Even if most CPC users have an FDC, the possibility of FDC hardware emulation is IMHO super awesome. Imagine for example how easy it will be to copy an 0,7 MB format DSK to a real 3.5" disc and vice versa.
Also backup copies of real 0.7 MB format discs to DSK will be super easy now.
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

GUNHED

Quote from: Duke on 02:40, 07 December 20
Yes it does. Ie. ROMDOS (D1/D2/D10/D20/D40) and PARADOS 80.
Please - everybody - consider to also support the 0,7 MB Vortex format. In Gemany (at least) it still is/was the 80 track standard format for floppy discs. The big companies like Dobbertin, Vortex ... all did support it.  :) :) :)
http://futureos.de --> Get the revolutionary FutureOS (Update: 2023.11.30)
http://futureos.cpc-live.com/files/LambdaSpeak_RSX_by_TFM.zip --> Get the RSX-ROM for LambdaSpeak :-) (Updated: 2021.12.26)

Powered by SMFPacks Menu Editor Mod