GP32 Dma Bug Is Back


fdave

Final Dave
Joined
Apr 20, 2004
Messages
331
Website
www.finalburn.com
Have to say it's really annoying me this time!

Any more information on it? Do you put asm("nop")s in? Thing is I've put them absolutely everywhere, and yet for certain type of execution (e.g. rendering Megadrive screen when display is disable = full horizontal line of colour) the sond just breaks up.

I've tried nops in all the tight loops, and it just don't work!
Any more info??
 
ive heard that it helps to set the memory region youa re accesing to "non cached" with the mmu, i bet the S3C2400X01 sheet have informations on this
 
fDave: can you post the latest version on your site? I'd be happy to have a look at it. Could be a number of things I guess, couldn't say without more details.
 
Vimacs posted on Jul 26 2004 at 07:33 PM said:
ive heard that it helps to set the memory region youa re accesing to "non cached" with the mmu, i bet the S3C2400X01 sheet have informations on this
Yep, and afaik this is the only way. It worked for me anyway. My screen was split in half (either horizontally, or vertically), and when I set the framebuffer region of the memory to non-writeback and non-cache, it just dissappeared
 
Last edited by a moderator:
Robster posted on Jul 26 2004 at 07:39 PM said:
fDave: can you post the latest version on your site? I'd be happy to have a look at it. Could be a number of things I guess, couldn't say without more details.

Okay uploaded Cyclone, Pico, PicoDrive, GigaDrive (usual spot)
( which is http://www.finalburn.com/cyclone/source.html by the way )

This is version 0.025 by the way.

Ideas totally welcome, I am one confused monkey.

In it's current state it works... just. The source loop is at 6 segs (100ms latency). Okay, so here's the story so far what I've done to it

Move it down to 4 or lower, and it goes all funny, which people are saying it shouldn't do. I tried doing mmu thing. No joy at all.

If the Megadrive display is disabled (e.g. on Strider between game sections), the sound goes wrong! It seems if it rendering LESS, the sound goes wrong. Which is just plain weird and is messing with my head.

Problem number 3, I started to rewrite the line renderer (Draw2.cpp). Uncomment it and you'll sound hear the problem - even just rendering the background colour, the sound goes wrong.

I tracked down the functions I thought needed nops in (EmulateScan()) and lo and behold, the nops didn't help at all. As a result, that is messing with my head.

And finally, very worryingly weird thing: if I used the faster execution routine in Pico.cpp PicoFrameSimple() I get the sound problems (with Draw2.cpp). However if I use the slower PicoFrameHints() all the time, the sound problems go away.

I then thought maybe Cyclone itself was using the bus, so I split Cyclone execution into sections with nops in between... no difference, sound still buggered with Draw2.cpp

It seems whatever I do, if I try to make the emulator faster, I'm immediately punished by having the sound wrecked!

Tell me I'm not going insane?

By the way, does anyone know how to pageflip the screen without taking about 3ms to do it like the official functions?
 
Last edited by a moderator:
Cool nice to see Gigadrive has gotten updated to 0.025. Soz can't help you with the sound...
 
He only posted the source, and it doesn't contain a binary. Anyway, it sounds like he's been working mostly on the sound, which he is having problems with.

I feel useless in situations like this, as my knowledge of sound on the GP32 is extremely limited.
 
kotd posted on Jul 27 2004 at 12:01 AM said:
Cool nice to see Gigadrive has gotten updated to 0.025. Soz can't help you with the sound...

No changes in 0.025, (apart from BlockOut and Moonwalker maybe?) just tryying to get my head around the DMA bug

I might start again from scratch with the interface at some point. brains hurtz
 
Last edited by a moderator:
fdave posted on Jul 27 2004 at 09:04 AM said:
kotd posted on Jul 27 2004 at 12:01 AM said:
Cool nice to see Gigadrive has gotten updated to 0.025. Soz can't help you with the sound...

No changes in 0.025, (apart from BlockOut and Moonwalker maybe?) just tryying to get my head around the DMA bug

I might start again from scratch with the interface at some point. brains hurtz
some sound hints:

I use this memory segment for sound :
// 16kb free memory for soundmixer 0x0C7B0000 - 0x0C7B4000
#define SAMPLEBUFFER0 0x0C7B0000 // 8kb RINGBUFFER, 2 segments of 4096Bytes, 1920*2 Bytes used...
#define SAMPLEBUFFER1 0x0C7B2000 // 4kb MODPLAYER_RENDERBUFFER
#define SAMPLEBUFFER2 0x0C7B3000 // 2kb MODPLAYER_LEFT_CHANNEL
#define SAMPLEBUFFER3 0x0C7B3800 // 2kb MODPLAYER_RIGHT_CHANNEL

#define FRAMEBUFFER 0x0C7B4000 // 153600
#define FRAMEBUFFER1 0x0C7B4000
#define FRAMEBUFFER2 0x0C7DA000 // 153600


DONT use malloc for your ringbuffer. !!!!!!!

disable cache on Ringbuffer.
gp_setMMU( SAMPLEBUFFER0, (SAMPLEBUFFER0+16384)-1, 0xFFA ); //no cache for samplebuffer

Now the best strick: Only use ONE Ringbuffer, and let it repeat automatic by the irq/dma. Do NOT set a new sampleplayback at the end at one playback.

split the ringbuffer to TWO segments. And determinate by yourself, at what segement you are.
void gp_addRingsegment( u16 *add_buffer ) {
int i;
u16 *SEGMENT0 = (u16*)SAMPLEBUFFER0;
u16 *SEGMENT1 = ((u16*)SAMPLEBUFFER0) + SEGMENTSIZE/2; // ((short*)0xf000)+4 is exactly the same as ((short*)0xf000)[4]
// detect playing segment
if ( gp_getSamplepos() > SEGMENT1 ) { // we are in upper segment
for (i=0;i<SEGMENTSIZE/2;i++) SEGMENT0 = add_buffer; // fill lower segment
while (1) { if (gp_getSamplepos() < SEGMENT1) break; } // wait reaches lower segment
}
else {
for (i=0;i<SEGMENTSIZE/2;i++) SEGMENT1 = add_buffer; // we are in lower segment, fill upper segment
while (1) { if (gp_getSamplepos() > SEGMENT1) break; } // wait reaches upper segment
}
}

thats it, the main problem was that you better dont set the irq/dma new, at the end at one playback. Let it refill automatic... I dont use any loops or nops in my code. And it works out of the box in any clockspeed. In < 66Mhz clockspeed, you must set the Framebuffer to no cache. and it works until 25 Mhz :)


greets, Mirko
 
Last edited by a moderator:
mr.mirko posted on Jul 27 2004 at 10:25 AM said:
I use this memory segment for sound :
// 16kb free memory for soundmixer 0x0C7B0000 - 0x0C7B4000

DONT use malloc for your ringbuffer. !!!!!!!

disable cache on Ringbuffer.
gp_setMMU( SAMPLEBUFFER0, (SAMPLEBUFFER0+16384)-1, 0xFFA ); //no cache for samplebuffer

Now the best strick: Only use ONE Ringbuffer, and let it repeat automatic by the irq/dma. Do NOT set a new sampleplayback at the end at one playback.

split the ringbuffer to TWO segments. And determinate by yourself, at what segement you are.

thats it, the main problem was that you better dont set the irq/dma new, at the end at one playback. Let it refill automatic... I dont use any loops or nops in my code. And it works out of the box in any clockspeed. In < 66Mhz clockspeed, you must set the Framebuffer to no cache. and it works until 25 Mhz :)


greets, Mirko
Is that the video ram? I tried that as well, didn't seem to make any difference.

What is the reason though for not using malloc()?

I tried the setmmu thing didn't appear tomake any difference.

I use one ring buffer repeating. (Not only is it split into 2, it's split into 6!)
And yes, I determine myself what segment it is in.

What did you mean by that last bit though "the main problem was that you better dont set the irq/dma new, at the end at one playback"?


So I *think* I've tried all that. Thanks for the advice though. Like I said I'll probably just have to try again from scratch, maybe using the alternate SDK that is talked about... Any links?
 
Last edited by a moderator:
fdave posted on Jul 27 2004 at 11:57 AM said:
mr.mirko posted on Jul 27 2004 at 10:25 AM said:
I use this memory segment for sound :
// 16kb free memory for soundmixer 0x0C7B0000 - 0x0C7B4000

DONT use malloc for your ringbuffer. !!!!!!!

disable cache on Ringbuffer.
gp_setMMU( SAMPLEBUFFER0, (SAMPLEBUFFER0+16384)-1, 0xFFA ); //no cache for samplebuffer

Now the best strick: Only use ONE Ringbuffer, and let it repeat automatic by the irq/dma. Do NOT set a new sampleplayback at the end at one playback.

split the ringbuffer to TWO segments. And determinate by yourself, at what segement you are.

thats it, the main problem was that you better dont set the irq/dma new, at the end at one playback. Let it refill automatic... I dont use any loops or nops in my code. And it works out of the box in any clockspeed. In < 66Mhz clockspeed, you must set the Framebuffer to no cache. and it works until 25 Mhz :)


greets, Mirko
Is that the video ram? I tried that as well, didn't seem to make any difference.

What is the reason though for not using malloc()?

I tried the setmmu thing didn't appear tomake any difference.

I use one ring buffer repeating. (Not only is it split into 2, it's split into 6!)
And yes, I determine myself what segment it is in.

What did you mean by that last bit though "the main problem was that you better dont set the irq/dma new, at the end at one playback"?


So I *think* I've tried all that. Thanks for the advice though. Like I said I'll probably just have to try again from scratch, maybe using the alternate SDK that is talked about... Any links?
get my sdk here:

http://gp32.mirkoroller.de

Have a look at the sound part.
 
Last edited by a moderator:
I'm just in the process of building gigadrive (it's a bit different on Linux). Really though, the gpsdk sound functions are evil and must be avoided at all costs :)

Hardware DMA is not only just as easy as using a ring buffer in GpSdk, but gives far better results. I'll look at implementing that in gigadrive (will take a couple of days) and get back to you.
 
fdave posted on Jul 27 2004 at 09:04 AM said:
kotd posted on Jul 27 2004 at 12:01 AM said:
Cool nice to see Gigadrive has gotten updated to 0.025. Soz can't help you with the sound...

No changes in 0.025, (apart from BlockOut and Moonwalker maybe?) just tryying to get my head around the DMA bug

I might start again from scratch with the interface at some point. brains hurtz
Thats cool! Moonwalker was one of the only launch? games that still didn't work. Good luck I hope you figure it out:)

If you want me to test it than you can send the binary to my email or whatever :)
Thanks
Rob
 
Last edited by a moderator:
Back
Top