Hi, all,
Firstly, I think it's important to mention hurricane Sandy - let's hope that everyone is safe and all is well. :nightmare:
OK, I've pretty much given up with the Dreamcast GD Emu stuff for the time being in the hope that SWAT or somebody can get it working.
@cybdyn has been in touch about us both using the same FPGA board, but unfortunately I've lost all enthusiasm for the project after spending many months on it without success. :sorrow:
I'm still happy to help with it, but it's not something I want to spend more money on atm.
So, I got back to the 64DD again to see if I could interface it directly to the PC via USB.
It was a pain to find a code example for the FT245 USB chip at first, and I had to install Visual Studio 2010 Ultimate to get it to compile (VS 2010 Express will NOT work without a lot of hassle)...
The first step was to get a basic USB protocol working on the FPGA to "talk" to the 64DD. The USB protocol is very simple...
CC RR RR RR RR DW DW DW DA DA DA DA
The CC Byte is the USB "command"... 0x00 == (READ from 64DD reg). 0x01 == (WRITE to 64DD reg). 0x02 == (Get 64DD Interrupt pin status via FPGA).
The RR Bytes are the 64DD address for the Read or Write, MSB first (this is the full "cart slot" address, eg. the main 64DD registers start at 0x05000500).
The DW Bytes are the DWORD Count, so denotes the number of 32-bit WORDS (4 BYTES) to Read / Write.
The DA Bytes make up the data DWORD for a WRITE command (number of Words transferred depending on the DWORD Count).
The number of command Bytes must always be a minimum of 8, so for a Read command it just needs the first 8 Bytes, then it sends your DWORD Bytes back.
The "Interrupt status" command is required to poll the interrupt pin from the 64DD. (it was easier to implement polling rather than trying to separate real data from status updates).
After much messing around, I finally got the USB-64DD interface working reliably. The challenge was then the C programming side (which I'm not too great at)...
The example code for the FT245 USB chip uses MFC - I don't think I've ever used this library, but it's not too bad.
Basically, yesterday I managed to get the Windoze app to read some data blocks from the M@rio Artist disk!
I'm pretty sure I have direct access to the System Area too (first 24 Blocks / 12 Tracks).
(try decoding those first four bytes into ASCII :friendly_wink: )
The trick, as jrra said, was to get the timing correct as well as all the commands / parameters.
I had to get the commands in the exact order as the real N64 libleo library sends them...
What happens after reset / power on is that you can do a "Read Seek" command right away. This just reads the raw data from the chosen Track into a temp buffer (including C1/C2 error correction etc.).
The 64DD has a small Hitachi MPU for parsing this raw data to find the start / end of each block etc.
(there are two Blocks per Track, each Block is made from around 90 Sectors. The number of Bytes per Sector varies depending on the "Zone").
So, after the Read Seek, you need to send some data (64 bytes) to the MSEQ (Micro Sequencer?) RAM. This sets up some parameters for the MPU to grab the User data. You then Reset the BM (Bit Micro??), Start the BM, wait for an interrupt, then grab your data bytes!
(You can see how this maps to the row of buttons on the Win app.)
I couldn't get this to work before because I had a few commands in the wrong place. I was also using separate buttons, and leaving too long between presses (Interrupt polling isn't quite working yet, so I don't know exactly when to grab the data).
It seems that after a while, the 64DD will actually clear the data buffer if you don't grab the data within a certain time. Strangely, if you do grab the data in time, you can repeat the read from the buffer and the data is still sat there?
What I've done now is to add the "Run Cycle" button, which just cycles through the "Send MSEQ" to "Read 0xE7" buttons. If I keep clicking the "Read ASIC Status" button, I can see when it sets the Mecha Int flag, so I know when the data has been read and I can grab it from the sector buffer.
I'm just after some help now to code the Win app so it can read a chosen LBA / Track, then hopefully "read" the whole disk to a file.
I don't know how much of this info I can post here though? I can remove a lot of offending info from the code if need be, but it will still contain a lot of register info of course.
The good thing is, it looks like most of the parameters are figured out now. The problem is if the MSEQ data needs to be changed depending on the Track / Bytes per Sector? This can be figured out, but I'd need some help with the MIPS code too.
btw, Thanks to everyone on the forum (and IRC) for help with the 64DD stuff; Especially to @kameddo, @marshallh, @pinchy, @Twili (for Jap ASCII translation), and mostly to @jrra for help decoding the registers. :very_drunk:
I believe jrra == Jason, who is one of the developers on mupen64?
If I've missed anyone out, it's because it's been about a year since I messed with this. lol
OzOnE.
P.S. If there are any talented coders out there, it should be possible to add support for this to an N64 emulator so that real DD's can be played on a PC / Xbox!