XGM Driver help please

SGDK only sub forum

Moderator: Stef

Post Reply
NightShadow
Interested
Posts: 19
Joined: Sun Oct 14, 2012 10:20 pm

XGM Driver help please

Post by NightShadow » Sun Mar 06, 2016 4:38 pm

Hi !


I spent one hour and half trying to play a XGM in my game and unfortunatly I am not able.

I would really like if somebody could give me some help initialising everything in order to play a music. I haven't found good example, only one for playing a sound.

I already converted to .xgm with xgmtool.

I know I need to add something like this in my ressource.res:
XGM groovy_xgm "c:/Tools/Coding/SGDK/res/ressource/groovy.xgm"

if that good ?

now, the part I really don't know what to do.

extern const u8 groovy_xgm[226304]; <- that's what I found in an example,but was for a for a sound file... What am I supposed to put there ? tried different stuff but I get different compilation error..


In my code I try:
SND_startPlay_XGM(groovy_xgm);


I get an undefined reference to groovy_xgm and SND_startPlay_XGM ...

I really talented to code graphics stuff, physics, AI and Gameplay when base stuff is set and working but unfortunately my lack of knowledge in C give me a lot of trouble figuring how to set and use new function I have never done before ... The same thing happenned last time I tryied to use the function to only draw a line on a plane, I never been able to understand/create variables/arguments needed by the function.. I know it's really simple but without clean example of everything needed in order to use it I am not able.


I would be really happy if someone can clear thing for me. I could continue working on new stuff for my game.

dub
Very interested
Posts: 101
Joined: Thu Mar 19, 2015 1:26 pm

Re: XGM Driver help please

Post by dub » Mon Mar 07, 2016 8:11 am

I just make a little source code with the essentials :

And it's like your code. Maybe it's your xgm files. Do you test an another xgm like sor2 ?

ressource.res:

Code: Select all

# Generated with rescomp

XGM sor2_xgm "sor2.xgm"
That give you in resource.h, the value Inside [] is automaticaly add :

Code: Select all

#ifndef _RESOURCES_H_
#define _RESOURCES_H_

extern const u8 sor2_xgm[78688];

#endif // _RESOURCES_H_
And the main code :

Code: Select all

#include "genesis.h"

#include "resources.h"

int main()
{
    VDP_setScreenWidth320();
    VDP_setHInterrupt(0);
    VDP_setHilightShadow(0);


    VDP_drawText("Current Z80 driver", 10, 1);

SND_startPlay_XGM(sor2_xgm);

    while(1)
    {
        VDP_waitVSync();
		
		
    }
}
I can upload my code if you want to test it.

NightShadow
Interested
Posts: 19
Joined: Sun Oct 14, 2012 10:20 pm

Re: XGM Driver help please

Post by NightShadow » Mon Mar 07, 2016 10:34 am

Hi dub !


Thanks alot, I think everything you gave me should help me a lot... I have to go working but I'm hurry to make some tests..

In fact I think I have a problem somewhere with my SGDK installation... even if I downloaded the latest version.

I see that I never had a resources.res and resources.H ... all my gfx stuff is in a file res/resource.rc ... I don't have a .H and I included all Export in my own init code.

Now that I added a resources.res with the XGM declaration inside, when I compile I get an error saying files that are supported and XGM isn't ,... Will try to re-install later today.

will give some news..
Thanks

NightShadow
Interested
Posts: 19
Joined: Sun Oct 14, 2012 10:20 pm

Re: XGM Driver help please

Post by NightShadow » Mon Mar 14, 2016 11:15 pm

Hi again ! Sorry for being slow giving update on this.

Finally it seems last time I tried to install the new version failed and it wasn't upgraded, unsupporting xgm.

I installed the new version, fixed my ressource files and now everything works great. I've been able to play sor2 and 2 of my tunes I composed. the xgm driver looks to be performing very well and stable.

The only disapointment is that I see a fps slowdown in my game... I really push everything on the border to get a stable 30 fps... When I run it with xgm support, it's going between 24-28 fps ... too slow.. I know I use a lot of VDP Loading and VDP Setting functions.. that's why.

But I'm happy to get that test done so I can now know how it's running on the real machine when I also play music and sounds. Couldn't know where I was going without testing driver's performance for real.

Before continuing, I'll try to optimize some already done stuff and I'll plan better how I'll do the rest with these performance.

Still, I think the driver's performances are very good, It's only my game been too ambitious for the Genesis ;-P maybe if it was coded in assembler, but SGDK is a very good compromise and functions are very fast from what I did experience. Creativity is now limitless !


Hope to show something someday but I have a lot of more work before ;-)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: XGM Driver help please

Post by Stef » Tue Mar 15, 2016 6:31 pm

Glad you finally sorted everything and thanks for the nice feedback about the XGM driver, i'm happy to heard it's working nicely with your game condition :) It's true that given how Z80 is intensively accessing the 68000 bus (about 1000 times per frame) you can observe a performance hit on 68k side but still i'm surprised the impact is that important, i would have estimated it between 3-5% max. On another side, some SGDK methods are slow if you use them intensively and just replacing some of them by a bit of asm here and there can probably sort you FPS issue ;)

NightShadow
Interested
Posts: 19
Joined: Sun Oct 14, 2012 10:20 pm

Re: XGM Driver help please

Post by NightShadow » Thu Mar 24, 2016 10:13 pm

Hi Stef


I see no performance differences while playing a complicated Song or a very simple one.

About the tests I done with loading maximum tiles I can between each frames while playing a song, I haven't tested playing sound samples in addition. Will there be a conflict with the "load from rom" max bandwith affecting my tiles loading ? ..as I'm really on the border line to get my fps stable and I couldn't load less tiles as I need them updated without compromise.

Maybe I should test as it's probably hard to say, probably depends on my code as it's too border limit ;-)
If you already have an idea please let me know.

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: XGM Driver help please

Post by Stef » Fri Mar 25, 2016 9:12 am

In fact almost of the bandwidth is eat by the PCM mixing and even if you're not playing PCM the XGM driver is always fetching "silent" sample from ROM. I did that for design reason but also to not have any difference in 68000 performance depending the PCM load. It would be problematic: imagine your FPS dropping each time your PCM load is important (3 or 4 PCM channels played at same time for instance), so i preferred to always use maximum BUS bandwidth with maximum impact on 68000, the XGM music data itself has only a minor impact on 68000 so even if music is complicated it won't make a big difference.
About the tiles data you are trying to upload, it should not make almost *any* difference. If you transfer your tile data by DMA (and i guess you do that) then DMA has BUS priority so the XGM driver won't be able to request BUS in the meantime.
At this point i even added advanced feature in the XGM driver to avoid at best the contention with the DMA.
Can you give some details about how many tile data you are transferring by frame ? Also you have to know if you are extending the VDP VBlank period, you have to take care of that with the XGM driver.

Post Reply