Replace GD-ROM with Flash Card?

Discussion in 'Sega Dreamcast Development and Research' started by _SD_, Jun 8, 2010.

  1. Anthony817

    Anthony817 Familiar Face

    Joined:
    May 12, 2010
    Messages:
    1,123
    Likes Received:
    596
    Now that's what I call progress! Gonna be keeping an eye on this more than I have been. Seems the exciting part is just around the corner!
     
  2. Evotistical

    Evotistical Robust Member

    Joined:
    May 25, 2011
    Messages:
    261
    Likes Received:
    4
    Pure sex sir!:clap:
     
  3. lolof

    lolof Rising Member

    Joined:
    Apr 14, 2008
    Messages:
    61
    Likes Received:
    0
    :clap:

    Very impressive. Good continuation.
     
  4. mar.vetto

    mar.vetto Rising Member

    Joined:
    Oct 7, 2011
    Messages:
    53
    Likes Received:
    1
    goood good good
     
  5. APE

    APE Site Supporter 2015

    Joined:
    Dec 5, 2005
    Messages:
    6,417
    Likes Received:
    141
    It very much is. I have a stack of Sony CD-Rs that are garbage on almost everything I've tried using them on that isn't a computer. My Taiyo Yudens? Peachy.

    Some Dreamcasts are a bit more temperamental than others, be curious if it is correlative/causative or maybe the difference between the two GD-ROM manufacturers. :shrug:
     
  6. PrOfUnD Darkness

    PrOfUnD Darkness Familiar Face

    Joined:
    Mar 13, 2004
    Messages:
    1,122
    Likes Received:
    48
    Amazing progress!
     
  7. OzOnE

    OzOnE Site Supporter 2013

    Joined:
    Nov 10, 2011
    Messages:
    538
    Likes Received:
    173
    Just a quick update...

    I've found the main silly mistake in the code. In the rush to get something running, I did this...

    cf_sec_count <= gd_sector_count * 4; // GD-ROM sectors are normally 2048 bytes instead of 512, so need to multiply by 4.

    Which would be fine, if "cf_sec_count" wasn't an 8-bit register! (you can only transfer 256 sectors at a time from the CF card)...

    So, for smaller transfers it works fine, but if "gd_sector_count" is 64 or greater, guess what happens! :redface:

    When it tries to read 1ST_READ.BIN, it asks for 210 GD sectors (840 CF sectors). This is why it shows the SEGA logo, but then freezes or goes back to the setup menu.

    I'm still working on the code.

    OzOnE.
    P.S. Just for reference, here are the first few GD reads for Crazy Taxi, many games could be similar to this...

    FAD 45150 (LBA 45000), 7 sector(s) = IP.BIN: META INFO / GD TOC / SEGA LOGO / AREA CODES
    FAD 45157 (LBA 45007), 9 sector(s) = IP.BIN: BOOTSTRAP 1 + 2
    FAD 45166 (LBA 45016), 1 sector(s) = IP.BIN: ".CD001" start.
    FAD 45170 (LBA 45020), 1 sector(s) = IP.BIN: GD FILESYSTEM start?
    FAD 548428 (LBA 548278) 210 sector(s) = 1ST_READ.BIN

    The FAD / LBA of 1ST_READ.BIN could change depending on the game (and the number of sectors), but you can see where the bug in the code screws things up. :rolleyes:
     
    Last edited: Dec 8, 2011
  8. runkthepunk

    runkthepunk <B>Site Supporter 2013</B><BR><B>Site Supporter 20

    Joined:
    Aug 13, 2010
    Messages:
    209
    Likes Received:
    0
    Interesting stuff! I am glad you are still making headway. Just out of interest would a HDD operate with the same limits on 'GD sector counts' as a compact flash? if not maybe a micro drive would be better? I know micro drives might not be as fast as solid state stuff but hey.

    Anyway just a thought but basically I think I am just making stuff up!

    Keep up the good work!
     
    Last edited: Dec 8, 2011
  9. -=FamilyGuy=-

    -=FamilyGuy=- Site Supporter 2049

    Joined:
    Mar 3, 2007
    Messages:
    3,097
    Likes Received:
    1,045
    AFAIK they're logically the same thing, so the same would happen. Don't quote me on that though.
     
  10. TmEE

    TmEE Peppy Member

    Joined:
    Aug 13, 2008
    Messages:
    362
    Likes Received:
    1
    I think you can transfer more sectors in UDMA modes but those are not going to be directly compatible with DC DMA interface due to both edge clocking scheme plus not all CF cards support UDMA modes anyway
     
  11. n64coder

    n64coder Robust Member

    Joined:
    Mar 25, 2009
    Messages:
    249
    Likes Received:
    2
    How are you finding the bug? By doing code inspection? There isn't a way to step through this using a debugger right?
     
  12. OzOnE

    OzOnE Site Supporter 2013

    Joined:
    Nov 10, 2011
    Messages:
    538
    Likes Received:
    173
    @runkthepunk - AFAIK, most HDD's only use 512-byte sectors (at least with this DMA mode). I think they are trying to change this to 2048 bytes on new drives though?

    It would make it much easier if CF / HDD did use 2KB sectors, but it's mainly my lack of programming experience which is causing the problem. :banghead:

    For debugging, I'm using the SignalTap II function in Altera's Quartus software which works via the JTAG connection to the FPGA.

    http://imageshack.us/photo/my-images/713/gdemusignaltapozone.jpg/

    It's quite clever stuff and can monitor a lot of signals and registers. You can also give things nice labels as you can see.

    The capture time is limited by the amount of on-chip RAM though, which is only around 64KB on this chip. So it's a challenge deciding on which trigger points and qualifiers you choose for the capture so it doesn't run out of memory.

    I'm not sure if you can use external memory for SignalTap? It would be nice to use the 64MB of SDRAM I have on the board!

    Really, I should be reading the CF data into a buffer first, then let the DC read the buffer. The limited on-chip memory is a problem though. Also, using SDRAM can complicate the timings. The best option would be a small SRAM chip - I wish I'd put one on this board.

    I'm still not having much luck with the code. It's loading the IP.BIN stuff OK, but I'm still screwing up the 1ST_READ.BIN loading.

    It's not quite the same as coding in C because you have to worry about how some statements only evaluate on the NEXT clock cycle. You can apparently change this by using "blocking" assignments, but that would be even harder to get my head around.

    I'm still very much learning this stuff myself, so it takes me a while to work out the correct code to do what I want.

    At least it looks like this is the main hurdle atm, and it's not an inherent problem with the security code (hopefully), or the way I'm handling the status.

    The issue only happens when the DC tries to read 64 or more GD sectors at once. This means reading more than 256 sectors at a time from the CF card, so it has to do multiple read commands to transfer the whole block.

    Ironically, most of the read requests from a real GD game are only 32 sectors or less. It expects to read 1ST_READ.BIN in big chunks though. :rolleyes:

    I'll have to draw a flowchart just to understand a bit better. I know what I want it to do, it's just getting everything in the correct order.

    btw, if I get completely stuck, I might post the full source code here. I'd rather release a working product that everyone can use though (proper PCB with GD connector etc.).

    What does everyone think? (I wouldn't want someone to release an inferior board using my crappy code in it's current state.)

    Having said that, the current source code isn't a million miles away from the one I attached in an earlier post - does anyone fancy finishing it off for me? lol

    OzOnE.
    God-damn, I type a lot. It's so easily done.
     
  13. n64coder

    n64coder Robust Member

    Joined:
    Mar 25, 2009
    Messages:
    249
    Likes Received:
    2
    If you want to attach the section of code that you're having trouble with, I'll be glad to take a look to see if there are any logic issues.

    Which development board are you using? I have a good friend who does micro-coding for a living that I can ask for advice.
     
  14. OzOnE

    OzOnE Site Supporter 2013

    Joined:
    Nov 10, 2011
    Messages:
    538
    Likes Received:
    173
    I'm not using a dev board as such. I built my own board with a Cyclone III FPGA (EP3C16Q240C8), Cypress FX2 USB chip and 64MByte SDRAM. I suppose it's similar to the Terasic DE0 dev board, but then FPGAs are mostly generic.

    Below is the DMA part of the code so far. There will be many obvious problems with the code because it's kind of half-way through working out some stuff

    • Not asserting "ide_rd_n" BEFORE the IF statement in state 9,
    • Not waiting for DRQ at state 24 (shouldn't need it with DMA?),
    • Incrementing instead of decrementing "cf_wordcount", then checking if == 255, because I'm lazy. :p

    http://pastebin.com/0iGu492z

    Firstly, the "start" sector is using FAD addressing, which is just the LBA address + 150. So, to make things easier, I copied track03.iso of Crazy Taxi at LBA 45150 on the CF card.

    You have to do something like....

    cf_lba <= ((gd_start_sector - 32'd45150) * 4) + 32'd45150;

    ...to zero-out "gd_start_sector" relative to the start of the ISO track before multiplying by 4 to skip the CF sectors, then add the track offset back on to get the real CF start offset! :banghead:

    Another problem is trying to keep the counting within one state because it can miss the rising or falling edges of "gd_rd". I was originally using only "gd_rd_rising" to drive state 25, then checking "if (cf_sec_count == 8'h00)" on every clock.

    You can probably see what I'm attempting to do though - with standard IDE CF cards / HDDs, it will transfer 256 sectors when the 8-bit register "sector count" == 0x00 because it decrements the count before checking if 0 (it wraps).

    I'm multiplying "gd_sector_count" by 4 to account for the 2048-byte GD sectors compared to the CF's 512-byte sectors. I'm storing this in the separate 32-bit wide "cf_sec_count_32", then I want it to transfer the maximum 256 sectors from CF if the 32-bit count is 256 or above.

    eg., say "gd_sector_count" is 210 (like it is for 1ST_READ.BIN in Crazy Taxi), "cf_sec_count_32" would be 840...

    This is above the maximum 256 sector block, so we need to transfer in 256-sectors chunks from the CF like this...

    "cf_sec_count_32" starts at 840...

    Read 256 sectors (cf_sec_count <= 0),
    "cf_sec_count_32" is now 584

    Read 256 sectors (cf_sec_count <= 0),
    "cf_sec_count_32" is now 328

    Read 256 sectors (cf_sec_count <= 0),
    "cf_sec_count_32" is now 72

    Read 72 sectors (cf_sec_count <= 72),
    done!


    Transferring less than 256 sectors is working fine - the SEGA LOGO works, then it goes haywire.

    This is probably fairly simple for experienced coders, but it's giving me a headache! :shrug:

    There may be issues with exactly when the code can pause the transfer to read the next block of sectors - it might need to be done at 16 WORD boundaries because the DC seems to read in 16 WORD bursts.

    Genuine thanks for any help with this. I think it's close to loading the rest of the game.

    btw, I did try it with F335 Challenge instead, but no change. I can see the > 256 sector reads are still screwed up.

    OzOnE.
     
    Last edited: Dec 9, 2011
    l_oliveira likes this.
  15. runkthepunk

    runkthepunk <B>Site Supporter 2013</B><BR><B>Site Supporter 20

    Joined:
    Aug 13, 2010
    Messages:
    209
    Likes Received:
    0
    Well you still seem to be progressing to me. Its very good of you to offer out the source for others to look at and develop/offer advice.

    I hope that this project can go all the way. I also think you could probably do a little bit of business if this works out for you and any others who help (but you don't seem like that kind of guy)

    Good luck man
     
  16. l_oliveira

    l_oliveira Officer at Arms

    Joined:
    Nov 24, 2007
    Messages:
    3,894
    Likes Received:
    252
    Great stuff ! I'm in love :love2:
     
  17. SGGG2

    SGGG2 Active Member

    Joined:
    Dec 30, 2010
    Messages:
    40
    Likes Received:
    0
    Thank you OzOnE, this is awesome.
     
  18. Anthony817

    Anthony817 Familiar Face

    Joined:
    May 12, 2010
    Messages:
    1,123
    Likes Received:
    596
    I agree! You are a super dude. If this all works out I think you could make some cash from doing this.

    I know about 10 guys personally that would pay to have something like this in their systems. I know I would.

    With a modified version of Dreamshell we could finally have that all in one front-end for launching games on our Dreamcast's.

    If the price of parts and labor could be negotiable to close to, or just under $100 then you might have a boom in business. :)
     
  19. APE

    APE Site Supporter 2015

    Joined:
    Dec 5, 2005
    Messages:
    6,417
    Likes Received:
    141
    If someone were to create a product using poor code it likely wouldn't sell many units if at all. I would be hesitant to release code that is far more complete if you wish to create a working product that you can profit off of (as is your right). I'm sure you're aware of how expensive PCB fabrication can be in order to drive the cost per board down to reasonable levels putting aside the cost of components.

    The only thing that keeps the EverDrive from being poorly cloned is the loyalty people currently show to Igor (which will disappear as soon as a clone reaches critical mass) and the updates that will likely not be 100% compatible with clones.

    Same thing happened with PS2 modchips but the DMS4 people charged large sums for what are arguably great chips but not $65 great for a console that was quickly being delegated to dust gathering duty. Now we have clones out that run the Matrix Infinity firmware and ToxicOS. Poorly. Good enough to run backups but not good enough for people like me.

    TL;DR version: your work will get poorly cloned by some opportunistic Chinese dick at some point. Might as well polish your work, profit off of it while you can (if you want) and be proud of what you're doing. My hope is that you won't hit a wall that you can't get over and progress doesn't stall permanently.
     
  20. NOISIA

    NOISIA Member

    Joined:
    Nov 6, 2011
    Messages:
    21
    Likes Received:
    0
    To be honest, i don't see retro console based flashcarts getting mainstream exposure. I do believe that black market will profit from that "niche" but not enough to take Krizz out of the game, as long his products get decently priced.
    It's more likely that people will try to pirate a Dreamcast flashcart/harddrive interface when released to the public. The system holds freshness and potential for re-purpose.

    I'm very happy for your contribute Ozone! No matter the outcome you've already earned my respect! :thumbsup:
     

Share This Page