WinCE + CDDA

Place for discussing homebrew games, development, new releases and emulation.

Moderator: VasiliyRS

User avatar
Captain Dreamcast
Developer
Posts: 324
Contact:

WinCE + CDDA

Post#1 » Wed Aug 11, 2010 5:14 pm

Yeah, my super secret project "Sigma" is trying to get WinCE + CDDA to work.

I just can't believe that after almost 11 years, a huge amount of games STILL doesn't work right. :shock:

So, in a mix of arrogance and egocentrism, I've taken a look at Tux' postponed list to find something to work on. The final decision was Midway's Greatest Arcade Hits Vol. 2, which is small AND has a ridiculous number of CDDA tracks (24 tracks? REALLY?).

The first idea was to imitate the original file order perfectly. LBA 'n stuff, you know? As idealistic as that idea was, not even Track 04 was inside the CD-R's 360000 blocks, so that doesn't work :|
Despite that fact, I still wanted wanted to imitate the original file order.
The novelty of that idea is the fact that session 2 contains two data tracks AND all the audio tracks between them.

Test #1
...was using ONE data track. At first, I forgot to check "SEGA OS" in the IP.BIN :roll: , which is about the dumbest mistake one can do. Things went a lot easier than expected and CDRecord burned the two dummy tracks (pushing session 2 border to 45000) and session 2 (track03~data;track04-29~CDDA) without much complaining, even though track 11 (or 12?) seems to be somewhat corrupted, as about 50% of the time, it failed to burn. :?
Well, it was a long-time ally who outlived his purpose: DiscJuggler.
DiscJuggler cannot recognize the switch from data (2048 bytes/block) to audio (2352 bytes/block) and thus wonders where the 304 bytes come from. So, should my new file order prove to be IT, that would mean DJ was OUT. Believe me, that hurts me a lot, I share a great deal of respect for Padus and *sniff* my favorite disc burning program :cry:
Alcohol 120% didn't have any problems with the data/audio transition, but bailed out on me during track 11 (corrupted, remember?)
My final choice was to rip the game DIRECTLY to the CD-R to play it in the DC, which worked.
No seriously, it WORKED. The right CDDA plays during the right time :D
That's quite something, but there are still two apparent flaws:
Paperboy's music is garbled. You can recognize the sound, but the CRRRRRRRRSHSSSHSHSSHSSHKRRRRRKRRRRRRRR sound makes it unbearable. Track 11, no doubt :|
And more problematically: 720 Degree's music doesn't play. At all. For those of you who don't know, the music changes volume depending on how far away you are from the speaker inside the game. Could THAT be the cause?

Problem 1 shouldn't pose much of a threat to the project. A corrupted file can be replaced. Problem 2 on the other hand will be a bit more tricky, so I'm gonna gather some knowledge on the corresponding CDDA references within the 0WINCEOS.BIN and test my luck.
What is REALLY gonna snap my neck is how I'm supposed to distribute this release, (should I really fix the issues :D).
What a mess. But I won't stop now, just imagine how many games I can release if I get WinCE + CDDA to work... Arrgh, I've gotta stop drooling and start trying!!

If you have any idea how one or more issues can be resolved, please let me know... FOR GREAT JUSTICE!

P.S.: This is now the OFFICIAL WinCE + CDDA thread. :mrgreen:

TeamXlink
Rank 9
Posts: 952

Re: WinCE + CDDA

Post#2 » Wed Aug 11, 2010 6:05 pm

Awesome work, your second problem seems very interesting.

User avatar
Captain Dreamcast
Developer
Posts: 324
Contact:

Post#3 » Fri Aug 13, 2010 3:40 pm

Here's a small update (EDIT AFTER FINISHING:" :lol: ") on the whole WinCE stuff:

A certain someone with a lot of experience hinted that there are multiple types of WinCEDA versions:

TuxTheWise wrote:Well, the behavior is not exact the same in all the games, I could separate them in three classes:
1) CDDA doesn`t play at all (virtua cop 2, sega rally 2).
2) CDDA presents wrong behaviour, starting any track from the first CDDA track and playing the others in order (kiss, armada).
3) CDDA works fine depending of the order you use for them (every wince + cdda released by kalisto or echelon).


Midway's Greatest Arcade Hits Vol.2 was 1), since it doesn't play CDDA using normal methods.
What I really wanted to fix was issue 2) though. All the games I want to play have issue 2), Rainbow Six, Kiss... Rainbow Six 2: Rogue Spear.
What makes things so much more interesting is 3). SOME games work. Tux once said that this does not necessarily mean a fix is possible, but we shouldn't rule out the possibility. What can be ruled out however, is the idea that modifying the Dreamcast executable 0WINCEOS.BIN will make CDDA work.
In order to get 2) games to work, tests were switched to The next Tetris Online edition (2 game) and Worms Armageddon (3 game). This is where...

Test #2

..took place. So, since TNT plays CDDA in a row (note: to have it play right --> convert raw files to wav), and Worms Armageddon CDDA works, my thought was that there may be some sort of difference in the WINCE folder where the .dll files are stored. It wasn't too farfetched, since all files have a different size. Using the blunt "paste-over-and-hope-it-works" method I employed in Bloody Blade 2, I used Worms' WINCE folder files with TNT. Interesting enough, the game actually started and played fine, but CDDA still plays in a row :|

FAIL

So, I looked around the data for clues and I came across a file which seemed mighty suspicious to me: SOUNDLIBCE.LIB
This file contains a lot of references to different .wav files, but I'm not quite sure wether
a) Those are the wav files I'm looking for (even though they don't appear to be SFX/voices)
b) What the references stand for.

If you think you can help me with either of these points, please PM me and I'll give you the file. :mrgreen:

Well, to check my SOUNDLIBCE.LIB theory, I needed to take a look at another WINCEDA type 2 game. I chose Kiss, just because. :D
Major Bummer: No SOUNDLIBCE.LIB
EXTREME UBER-Bummer: No WINCE folder :shock:
What the heck? This doesn't make sense at all! There is absolutely no similarity between Kiss and TNT, this could mean that the workaround is different as well... DAMN IT :evil:
In a state of rage, I browsed Kiss for hints on how to enable CDDA. The result was rather... unexpected. The files are structured pretty well, so it wasn't hard to find the music reference for mission 0. And here is where things turn awkward: The music that plays during that mission... is a wav file stored deep within the MAPDATA subdirectory. To top it off, this wav file doesn't exist. And believe me, I've checked all and every file that is said folder and no one of them functions as an archive or anything similar. So, where does this leave me? The problem is that I struggle to understand the mysteries behind the GD-ripping process.
Here's my theoretical theory:

EDIT: THERE WAS NOTHING HERE BEFORE I EDITED THE POST. Everyone who says something else is a LIAR! A false theory? By ME? Never.

-Capt. DC

P.S.: You may be wondering why I'm documenting this stuff in such detail. The reason for that is that I may not be able to finish this project. Despite the fact that it's a 1% chance that I fail, I want to make sure that in the Space year 2068, someone will read this stuff to help them discover the trick behind WINCEDA.
For Great Justice!

Comrade Snarky
Vagabond
Posts: 714

Re: WinCE + CDDA

Post#4 » Tue Aug 21, 2012 4:44 am

I'll add my findings to this as well. I'm going to start my own little research project. I wanted to get a version of Virtua Cop 2 working with the CDDA intact, so note that this may or may not apply to other WinCE games with CDDA.

My initial thought was that maybe there was something odd about the CDDA itself. I opened up the file and poked around with a hex editor. I found that at offset 2136 (I believe) of EVERY CDDA track for the game there was FFFF among a sea of 0s. This intrigued me. My thought was that maybe the game was checking for this value in order to play the CDDA. Some sort of weird copy protection or something, even though this game would be before piracy was an issue. I ran raw2wav and noticed that the WAV header moved the position of the FFFF values out of place by 50 or so bytes from the header.

So, I repositioned the FFFF to its original 2136 offset and burned. This did nothing to make the audio in the game play. I also found that CDRecord removes the WAV header when it burns the audio tracks. A bit more on RAW2WAV, the only thing it changes is adding the header. I wanted to be sure so I did a comparison in a hex editor. The 50 or so bytes at the start identifying it as a wave form is it.

This kills my theory that there's maybe something bizarre about the CDDA itself. This was partially inspired by Captain's mention that KISS was referencing non-existant WAV files in the game data.

Next I turned my attention to bincon. I was curious as to exactly what it does.

Bincon adds 2kb of data to the start of the binary and removes 2kb elsewhere. I went through the added and removed data, and there seemed to be nothing relevant in the data. My thought there was that maybe bincon was inadvertently changing something that some games needed. I suppose it still could be, but this seems highly unlikely.

I'm pretty stumped on this one. At least for Virtua Cop 2, nothing jumps out as obviously having a relation to the CDDA and how it works. There's several .dlls that have names pertaining to sound, but I can't find anything useful in them. There's also files which reference sound in folders for each stage of the game, but they tell me roughly nothing as well.

EDIT: One other thing I forgot to mention. One of the files I went over with a hex editor made reference to the low density sector of all things.

I looked in the low density sector and there's just your standard abstract, bibliography and copyright. The abstract does have some cheats for the game in Japanese, though.
Last edited by Comrade Snarky on Tue Aug 21, 2012 6:51 am, edited 1 time in total.

Comrade Snarky
Vagabond
Posts: 714

Re: WinCE + CDDA

Post#5 » Tue Aug 21, 2012 5:12 am

And there it is. Virtua Cop 2's EXE makes references to WAV files as well. There's definitely no WAV files in the game. They're apparently all in the directory
"CD-ROM\WAVE\filename.wav"

Of course there's not any directory remotely similar to that.

So... there's something interesting going on with how the WinCE games are laid out on the GD-ROM I'm guessing.

Edit: I looked through the area of the BIN file from the GDI that has information on file sizes, where you'd edit to fake a file size to beat protection. The WAV files aren't listed there. So, maybe these WAV references are nothing.... Maybe it just has something to do with how the code has to be written before the game is compiled? I don't know.

User avatar
Captain Dreamcast
Developer
Posts: 324
Contact:

Re: WinCE + CDDA

Post#6 » Tue Aug 21, 2012 8:14 am

Too bad the idea with the special CDDA didn't work out, just imagine how awesome it would have been if that had really been it. :(

Anyway, the "CDDA as WAV files" myth seems to be officially busted now, you're right, if they are not listed in the TOC, the DC would have no way to access them.

Maybe if we take a look at it from the hardware level we can figure out why it's not working: No matter what library you use (Katana, WinCE, Homebrew), CDDA always uses one of the same two system calls, which are about as complex as a CD player: The first system call calls the CDDA by its track number, the other one by its start and end LBA. And we already know that we have WinCEDA games that either work, or not. The most likely conclusion is that the "broken" game call their tracks by their LBA for whichever reason. Finding the system calls is relatively easy, as they are well-documented at, for example Marcus' site.

For clarification, the command searched for is stored in the BOOT ROM at 0x8C0000BC, in pseudo C code it would look like this:

Code: Select all

0x8C0000BC(r4, r5, r6, r7);


Yeah, it's kinda simplified. Anyway, the rs mean the following:

r4 = Command code. 20 for tracks, 21 for LBA.
r5 = Parameters. A pointer to a struct consisting of a 32-bit signed integer holding the Start track/LBA, followed by the same type of an integer holding the End track/LBA, followed by another 32-bit signed integer containing a value from 0-15 indicating how often the track loops. (15 = forever?)
r6 = Always zero.
r7 = Always zero.

So the faulty code we are looking for looks like this:

Code: Select all

0x8C0000BC(21, (Some pointer to RAM), 0, 0);


My assembly knowledge sucks, so please don't expect me to translate it to that, someone else has to do that... <_< >_>

You have probably guessed why it is so hard to fix: Within the compiled binary, you cannot differentiate between the code that's executed and the other stuff stored inside the binary. Otherwise, you could just add a GOTO leading to the end of the binary, add a bit of code there that (in the best-case scenario) translates the sectors to tracks. Very hard, but possible. It would probably rule out a universal fix though, the sectors would still be adjusted to the GD-ROM, the tracks are at completely different positions, etc..., etc...

This theory is pretty likely due to the fact that the DC is no more complicated than your standard 1999 CD-Player in the CDDA department. Things in the game code would have little to no effect on the way the commands are processed. Doesn't make fixing it easier though, haha. :lol:

Hope this info helps you (and that you didn't know all of this already so that I just wasted your time :shock: ).

...Credit for the explanation why it is hardly fixable goes to Tuxonio. *Sniff*, and I thought that WINCEDA could finally work easily... :cry:
For Great Justice!

Comrade Snarky
Vagabond
Posts: 714

Re: WinCE + CDDA

Post#7 » Tue Aug 21, 2012 8:17 pm

I think there's still something missing here. Why are there games that do work that just play the tracks in order instead of referring to them properly? The assumption would be that those games operate by going to play the track number... but if it's still not playing them right... why?

Comrade Snarky
Vagabond
Posts: 714

Re: WinCE + CDDA

Post#8 » Mon Aug 10, 2015 9:39 pm

I'm screwing around with Windows CE CDDA again, so I'll keep posting here just in case someone else is trying to figure this BS out in 5 more years.

I had another theory about why it didn't work. The standard Dreamcast CDDA tutorials have you burn the audio in such a way that it leaves a two second pregap between each track. I burned the CDDA without the pregap, thinking this may be interfering somehow. No dice. This may have a different effect with different games. I tried it with Virtua Cop 2, which is a known "doesn't play CDDA at all" game.

I've got another theory, I'm trying to get DEMUL setup to try it but good lord that thing is a PITA.

  • Similar Topics
    Replies
    Views
    Last post

Return to “New Releases/Homebrew/Emulation”

Who is online

Users browsing this forum: No registered users