General Insanity (Genesis + PVR)

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
Warmtoe
DC Developer
DC Developer
Posts: 453
https://www.artistsworkshop.eu/meble-kuchenne-na-wymiar-warszawa-gdzie-zamowic/
Joined: Thu May 16, 2002 8:29 am
Location: ice88's house
Has thanked: 0
Been thanked: 0
Contact:

Post by Warmtoe »

This is really starting to look good - I have it all compiling with the latest SVN version of KOS.

The main changes are in the xrender loops not re-getting the vertex structure, in the controller code, instead of mapping the CONT_ values to the pad values, I changed the pad values to match the CONT_ values and just straight copy buttons to pad[] - also changed the code not to look for new devices each time (single initialised dev[] array).

I also changed the xrender stuff to use the TR rather than the PT list - not sure why they were being separated.

Plus loads of other tweaks and fiddles (shifts instead of multiplies, only performing arithmetic operations once where possible etc).

My current dc_options are:

Code: Select all

options_t dc_options =
{
	0,		/* Frameskip */
	487,	       /* M68k clock speed */
	228            /* Z80 clock speed */
};
Sound is still not perfect - but sonic is well playable.

It struck me that I may well be using different KOS_CFLAGS to you guys... I'll show you mine (if you show me yours)...

Code: Select all

KOS_CFLAGS='-O3 -fomit-frame-pointer -ml -m4-single-only fno-optimize-sibling-calls -D_arch_dreamcast -D_arch_sub_pristine -Wall -g fno-builtin -fno-strict-aliasing'
Warmtoe
DC Developer
DC Developer
Posts: 453
Joined: Thu May 16, 2002 8:29 am
Location: ice88's house
Has thanked: 0
Been thanked: 0
Contact:

Post by Warmtoe »

In fact... here is some updated source... dig away...

http://homepage.ntlworld.com/ian_edward ... armtoe.zip

I renamed the snd_stream functions too, to avoid clashes with the snd_stream within KOS itself, anyway, if you can get anything useful from this lot, do - it expects a sonic.zip in /rd/games.

If you do try this with chankast (using the -file option with the .bin file produced) bear in mind that the gfx you get out look nothing like they do on a real DC - they look nice on a real DC!!!
Storminator16
DCEmu Veteran
DCEmu Veteran
Posts: 850
Joined: Mon Sep 01, 2003 11:12 am
Location: NC/Iraq
Has thanked: 0
Been thanked: 0
Contact:

Post by Storminator16 »

Ooh, I'll poke at this one too :)

EDIT: Wow, I didn't realize you guys had the sound working and it doesn't sound like crap. It's repeating a lot and not syncing well, but still this is damn close.
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

* Calculate the sound buffer size */
snd.buffer_size = (rate / 27); //27 change the number to match
snd.sample_rate = rate;

do this to fix the repeating sound has been working for a long time Stef d coded that. Been in my dev release working fine for over 6 months.
Dreamcast forever!!!
Storminator16
DCEmu Veteran
DCEmu Veteran
Posts: 850
Joined: Mon Sep 01, 2003 11:12 am
Location: NC/Iraq
Has thanked: 0
Been thanked: 0
Contact:

Post by Storminator16 »

I'm confused about the '27'. Is that used as an example? Z80 cycles? Plus, what code of yours can I check to see how this is implemented?
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

system.c

line 56.

Change 60 to a lower number till the sound becomes normal. It is repeating because it's not fullspeed. Change it to the aproxx speed of emulation and it fixes it.

Simple fix but not what we want to do for the future but it does work. Give it a try!
Dreamcast forever!!!
Storminator16
DCEmu Veteran
DCEmu Veteran
Posts: 850
Joined: Mon Sep 01, 2003 11:12 am
Location: NC/Iraq
Has thanked: 0
Been thanked: 0
Contact:

Post by Storminator16 »

Ok, I just realized the lines you were speaking of when I came back to check this thread. Yeah, it seems that setting it to around 58 did seem to succumb some of the stuttering and repeats but it a tad slower playback & not a remedy. Does make some of it more bearable, though. I'm going to read up on some things tomorrow to see if I can find something that will help. I have no idea what I'm doing, but I guess it's time to start learning new things. Especially since I have time to do it :D
Storminator16
DCEmu Veteran
DCEmu Veteran
Posts: 850
Joined: Mon Sep 01, 2003 11:12 am
Location: NC/Iraq
Has thanked: 0
Been thanked: 0
Contact:

Post by Storminator16 »

Would re-calculating the sound buffer size within the main loop do the trick? Using a timer which keeps the current FPS should be able to make this sync proper, right?.

EDIT: Yeah, re-calculating should solve this little problem.

Code: Select all

/* recalculate sound buffer size */
		snd.buffer_size = (rate / framerate);
Rate is currently 12000, but I'm still searching for what variable which tracks the framerate. Using 'pvrstats.framerate' keeps resetting the DC. I'm either being lazy, or too tired. I might quit for the night, I'm sure BA will have something juicy by the time I wake up.
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

Yeah that should work I linked it to frameskip and it worked but again not perfect. I know it's not a proper fix but it makes it useable.
Dreamcast forever!!!
Storminator16
DCEmu Veteran
DCEmu Veteran
Posts: 850
Joined: Mon Sep 01, 2003 11:12 am
Location: NC/Iraq
Has thanked: 0
Been thanked: 0
Contact:

Post by Storminator16 »

Ok, my simpleton idea made the sound worse:

Code: Select all

/* recalculate sound buffer size */
		if ((int)pvrstats.frame_rate > 0)
		{
		snd.buffer_size = (12000 / (int)pvrstats.frame_rate);
		printf("\nframerate is %i", (int)pvrstats.frame_rate);
		}

EDIT: Nevermind, that printf() made it sound worse than what it was. So taking it out worked out a bit better. Still not great, though but the repeating isn't happening as much. Getting much more random sounds, though :/
Last edited by Storminator16 on Tue Jun 22, 2004 10:16 pm, edited 1 time in total.
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

speud - Thanks for working on the menu, and I'll have a look at 640x480 mode.

elefas - Should work under DevC++, but you only need xvdp.c and xrender.c, not the others (they're for the software renderer)

ice88 - Thanks. I'll have a look at it. It seems like you've been doing the same kind of little tweaks I've been doing too, but more of them.

Oh, and that's how the pad handling was supposed to work anyway.

It was using the PT list because it didn't need full blending, and I wasn't sure how much difference doing the blending calculations would make to the speed. Since it only takes around 2ms for the PVR to render the frame, I don't think that's going to be a problem.

On the upside - we might be able to do fake shadow/hilight mode on sprites now.

Storminator16 - I think I have a better way to do the sound playback anyway. Generate the samples required for one frame, upload them, check how many extra samples are required to keep the buffer filled, and upload those too. It has more-or-less the same effect as fiddling with the buffer length, but it should be a little cleaner.
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

I can make it not repeat at all by initing the sound when i init the draw the frame try that.

Then the sound runs the same speed. Also this is not that good of an idea but works well i get no random sounds or problems.
Dreamcast forever!!!
speud
DCEmu Uncool Newbie
DCEmu Uncool Newbie
Posts: 1459
Joined: Sat Dec 27, 2003 10:40 pm
Has thanked: 0
Been thanked: 0
Contact:

Post by speud »

here is the menu: http://bswirl.kitsunet.org/gpdc-pvr-menu.rar or http://speud5.free.fr/gpdc-pvr-menu.rar (looks like kitsunet is down atm).
like i said before thats nothing especially beautiful, the goal was to have a simple interface to allow easy testing.

i didnt implement ice88's improvements, nor ian's framerate/sound calc (i set the z80 clock to 124 when sound is enabled) so feel free to do it.

you can freely browse your cd, everything that isnt a dir or doesnt have one of the predefined extenion (zip/ZIP, gz/GZ, bin/BIN, smd/SMD) is skipped.
press down/up to move the cursor or left/right to change the page.
press A to open a dir or launch a ROM.
press B to open the parent dir.
press X to choose the resolution between 640x480 (default) and 320x240.
press Y to disable (default) or enable sound.
while youre playing press L+R+start to return to the menu.
when youre finished pressed X+Y+A+B+start to exit the app.

i only tested it with the elf, but it should work with the bin too and allow you to make a preview release for everybody to test it.
http://blueswirl.fr.st - DC Online Tools and Downloads

thx to Wack0 for the avatar ;)
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

Cool. I'll stick the menu to the front, clean up the code a bit more, fix a couple of mis-features in the VDP emulation, and do another source release. I suspect that this is running faster on ice88's setup than it is on mine, so I think it may be worth getting him to compile a preview release.

The stuff that needs doing immediately for the VDP emulation:

Background colour (should be easy)
Use display enable/disable flag (should be easy)
Use 32/40-cell flag (should be relatively easy)
Emulate window mode (could be tricky, and I don't quite know how)
Fix the weird tile cache update problem (might be easy, might be really, really hard)
Blank the borders at the top and bottom (just stick a black rectangle over them)

That should make most games at least playable, and looking approximately correct. Quite a lot of games will still look wrong, and a few will still be unplayable (or at least more difficult).
Warmtoe
DC Developer
DC Developer
Posts: 453
Joined: Thu May 16, 2002 8:29 am
Location: ice88's house
Has thanked: 0
Been thanked: 0
Contact:

Post by Warmtoe »

Sure - I'll do a bin for a preview release - I won't base it on my source level though - BA, if you're going to put the menu on the front, I'll wait for your next source output.

Again - the only difference I can think of is the KOS_CFLAGS... What do you all have?

Mine is....

Code: Select all

KOS_CFLAGS='-O3 -fomit-frame-pointer -ml -m4-single-only fno-optimize-sibling-calls -D_arch_dreamcast -D_arch_sub_pristine -Wall -g fno-builtin -fno-strict-aliasing'
.

You could try using this to see if it makes any difference - Ian, you're a past-master at compiler flags, what am I missing?!!

Anyway - I'll let BA be the 'keeper-of-the-keys' - so I'm waiting on your source for a preview bin - When I get it of course, I can re-do any of my tweaks that you didn't get around to.
BlackAura
DC Developer
DC Developer
Posts: 9951
Joined: Sun Dec 30, 2001 9:02 am
Has thanked: 0
Been thanked: 1 time

Post by BlackAura »

The CFLAGS I compiled KOS with are basically the defaults. Aside from -D_arch_sub_pristine (which I don't have) the only difference is the -O3 (I used -O2)

I'm not quite sure what the thing with having only one vertex struct was though. Obviously my code is non-optimal, but I don't quite see how yours would be much better. It's using only one of the two store queues, so the code has to wait around for that store queue to finish before it can start filling it up again. My code was doing a lot of extra work (it's a bit better now) but it should be filling up one store queue while it's waiting for the other one to finish writing. Unless something's happening somewhere that I'm not seeing. It certainly does happen.

Either way, it seems to make no perceptible difference on my end. The twiddling code seems to be using a hell of a lot of CPU time at the moment.

I'm probably not going to keep the resolution switching from Speud's menu system, so I'm leaving it controlled by an #ifdef, which is set to 640x480 at the moment.
Warmtoe
DC Developer
DC Developer
Posts: 453
Joined: Thu May 16, 2002 8:29 am
Location: ice88's house
Has thanked: 0
Been thanked: 0
Contact:

Post by Warmtoe »

OK... what the hey - I stuck the menu on it and produced an elf.

Don't know what you need to do to selfboot / SBI it... but here is a mega-early-pre-pre-alpha version:

http://homepage.ntlworld.com/ian_edwards/ice88/gpdc.zip

Instructions for the menu are in the text above.
Warmtoe
DC Developer
DC Developer
Posts: 453
Joined: Thu May 16, 2002 8:29 am
Location: ice88's house
Has thanked: 0
Been thanked: 0
Contact:

Post by Warmtoe »

BA - I've tried fiddling-with-the-twiddling code before - I cannot think of a more efficient way to twiddle the data better... I did wonder about twiddling it to a buffer in main memory and then uploading the entire buffer to a texture in pvr-memory via DMA - some of the problem is going to be that the twiddle code as it stands is modifying, a long at a time across the main/pvr memory boundary.

It would mean allocating a second buffer in main memory which might be too much memory... but it might be a lot quicker.

The advantage of the 640x480 mode is that it looks right in chankast (!)

Anyway - I have real work to go to - I expect progress by this evening !!!!! :D
Storminator16
DCEmu Veteran
DCEmu Veteran
Posts: 850
Joined: Mon Sep 01, 2003 11:12 am
Location: NC/Iraq
Has thanked: 0
Been thanked: 0
Contact:

Post by Storminator16 »

I'm going to upload this to my site to make sure you won't get killed on the bandwith, Ian.
Ian Micheal
Soul Sold for DCEmu
Soul Sold for DCEmu
Posts: 4865
Joined: Fri Jul 11, 2003 9:56 pm
Has thanked: 2 times
Been thanked: 4 times

Post by Ian Micheal »

My compiler flags are as follows

You can try this ice.

-funroll-all-loops -frerun-loop-opt -falign-loops -fstrict-aliasing -ffunction-sections -fdata-sections -mieee

Break down
-funroll-all-loops depends what version of gcc but this will have a speed impact.
-frerun-loop-opt re runs the loop optimzer after it has completed optimzing them futher unrolling loops is very importin on dreamcast for speed.
-falign-loops after all the optmizing this is needed most times and can up the speed again and save space.

-fstrict-aliasing this has the impact to me of smoother out the flow of data i allways use it things most times go up by 1fps just using this flag.

ill explain the other's if needed. But most times this will help adds 3 to 5% speed on neogeo cd.

-funsigned-char also use this it corrects some of the grafix errors your geting give it a try.






Great work on the menu Speud really a great guy his helped me and the scene heaps.

*bows*
Dreamcast forever!!!
Post Reply