How did you fix the sound!?!


Nutzo

Member
Joined
Apr 23, 2003
Messages
155
GREAT WORK!

Please tell me how you fixed the farts. :)

I have a tiny programming/technical background, and I'm extremely curious to know what was required to get the sound from point A (o.5) to point B (0.6). If you don't feel like elaborating that's fine, but I'll read as much as you feel like typing. :p
 
OKay, lets say this..

Spiv was correct in that its a hardware/design issue in the GP. Doing too much memory bandwidth (or perhaps memory cache hits?) causes popping noises. I'd turned off memory caching in the MMU for the sound buffer.. but not the screen. Turns out the problem was rendering to the screen causing the noise. I eliminated the code in question before turning off caching... so that alone might have done it.

Anyway.. The problem only manifested when gcc had -O3 optimization on. The code got too tight, and the popping started. Not optimization == no problem and reall slow emulation.

So I reasoned I could go through, and take away the -O3 flag on a per-file basis to find the culprit(s). Turns out that it was only one source file that resulte din farting noises. Too bad it was the main one :)

So I split out another empty file with all the right headers, etc, and moved the sound generator over to it and compield everythign but it with -O3, and it with no optimizations. a trial by brute force to find the problem. All was still opping.

Moved the soun code back, then moved over the video.... still a propping. Got annoyed.

Moved over the API calls.. GpKeyGet(), etc.. still popping.

Started to get really annoyed. Started loking for the non-obvious.. if the obvious didnt' match, must be non obvious.

Then narrowed it down to a little tiny shitty routine I'd never really looked at.. one swiped from my Palm OS code. I have a C and ASM version in Palm OS, and broguht over the unoptimized C version (ther debug version) for GP32. IT just clears the area under a word.. clears it line by line. With a for loop. A 3 line for loop.

That caused it.

When -O3 applied to the for-loop that goes across 30 pixels on the screen, it made a popping noise.

So I removed it. Instead of clearing the box under a word, I draw the word in blasck over top of itself, now to clear it. No more popping noise. A little sloppier looking (due to ghosting), but works fine, and faster too.

So the moral is.. you can't controlwhat gcc optimizes to death, but its reallly good at little shitty loops. And the GP32 can't handle that.

So the trick was to find the shitty loop causing it. The loops that do it look like memcpy/memset/bcopy/strcpy type routines.. things that move a lot of data. Find it, remove it, or slow it down.

The option here woudl be to keep these sorts of ops in their own file and compiel them without optimization.. buit in my case, it was easy to just remove the problem entirely.

Voila.

*whew*

jeff
 
That is so freakin' cool! Thanks for that narration, really interesting.

So not only did the sound get cleared, but you even gained another drop of speed. Sweet!
 
Back
Top