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!
Replace GD-ROM with Flash Card?
Sega Dreamcast Development and ResearchPure sex sir!:clap:
:clap:
Very impressive. Good continuation.
Very impressive. Good continuation.
goood good good
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:
Amazing progress!
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.
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.

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!
Anyway just a thought but basically I think I am just making stuff up!
Keep up the good work!
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
@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.
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.
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.

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.
Which development board are you using? I have a good friend who does micro-coding for a living that I can ask for advice.
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
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.
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.

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.
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
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
Great stuff ! I'm in love :love2:
Thank you OzOnE, this is awesome.
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.
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.

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.
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:
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:
Original thread: https://assemblergames.com/threads/replace-gd-rom-with-flash-card.27608/