Sega Genesis Dev Kit (SGDK)

SGDK only sub forum

Moderator: Stef

Mixail
Very interested
Posts: 133
Joined: Thu Nov 18, 2010 4:47 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by Mixail » Fri Feb 14, 2020 2:53 pm

How to turn off looping animation in "sprite_eng"?
How to change animation speed?

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

Re: Sega Genesis Dev Kit (SGDK)

Post by Stef » Mon Feb 17, 2020 11:04 am

There is no real way of doing that automatically yet unfortunately.
To disable looping you need to set sprite->timer to 0 when you're reaching last animation frame (setting timer to 0 actually disable auto animation).
Also to change animation speed, again you need to set manually the sprite->timer variable manually after changing animation frame, to be honest in this case it's just more convenient to handle animation manually (letting timer to 0 and using setFrame / setAnimation methods manually).

Mixail
Very interested
Posts: 133
Joined: Thu Nov 18, 2010 4:47 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by Mixail » Mon Feb 17, 2020 4:29 pm

Stef, Thanks!

danibus
Very interested
Posts: 135
Joined: Sat Feb 03, 2018 12:41 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by danibus » Fri Apr 10, 2020 6:12 pm

I'm in trouble.

Just have 2 un-used s16 vars. I used them but not now.
But if I delete one of them ( or both ), main player animation fails!

This is what I get in GensKmod message window:

"SPR_setAnim: error - trying to use non existing animation #1 - num animation = 0"

All msgs similar to this one, just change which animation fails.
The question is, these s16 vars are not used ever, they are not in any file ( I looked for them ).

Very strange, sure my code will have a mistake somewhere but I don't know where :oops:



Update: Just forget. Unused "s16 vars" were not guilty ones. I was so stupid... I was using

Sprite* spr_m[0];
spr_m[0] = SPR_addSprite(......)

Not sure why but it was working until today, when deleting s16 vars all was wrong.
Then I change:

Sprite* spr_m[1]; //1 element, idiot!!

and all working again. It's C folks, this is not Java, you have the responsability to check everything. My fault :oops: :mrgreen:

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

Re: Sega Genesis Dev Kit (SGDK)

Post by Stef » Sat Apr 11, 2020 12:12 pm

When you have that kind of weird behavior you can be certain this is just an edge effect and that the bug is somewhere else.
That's the problem with C code, you don't have any protection against illegal pointer / index access so it could work until you change something completely not related but which internally may alter memory mapping and those exhibit the issue.

danibus
Very interested
Posts: 135
Joined: Sat Feb 03, 2018 12:41 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by danibus » Sat Apr 11, 2020 1:34 pm

Yes.

You can delete these posts if u want, as they are not SGDK related

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

Re: Sega Genesis Dev Kit (SGDK)

Post by Stef » Sat Apr 11, 2020 4:45 pm

Maybe you can edit the title but honestly *many* people fall in that kind of trouble / caveat so it can still be somehow useful ;)

cloudstrifer
Very interested
Posts: 118
Joined: Mon Feb 19, 2018 7:31 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by cloudstrifer » Tue Apr 21, 2020 2:05 am

Thank you for update!

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

Re: Sega Genesis Dev Kit (SGDK)

Post by Stef » Tue Apr 21, 2020 8:34 am

You're welcome ! I forgot to mention it indeed, i just updated to SGDK 1.50, i think i will soon publish a 1.51 version to fix minors issues (as usual) :p

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by Chilly Willy » Tue Apr 21, 2020 4:54 pm

Just updated my local copy and noticed something... in joy.h, the header has this for doc generation

Code: Select all

/**
 *  \file joy.h
 *  \brief General controller support.
 *  \author Chilly Willy & Stephane Dallongeville
 *  \date 05/2012
 *
 * This unit provides methods to read controller state.<br>
 *<br>
 * Here is the list of supported controller device:<br>
 * - 3 buttons joypad<br>
 * - 6 buttons joypad<br>
 * - Sega Mouse<br>
 * - team player adapter<br>
 */
It's missing a few supported devices. Also automatically detected and supported are the EA 4-Way Play, the Menacer, and the Justifier. Also supported, but not automatically, are the Sega Master System pad, trackball, and Phaser. Another caveat is that although the Menacer and Justifier are automatically recognized and supported, the support is not enabled until the programmer tells it to because of the extra overhead that lightguns add. This way, SGDK defaults to a lower overhead state for controllers. Games that can use lightguns can check and enable the lightgun as part of the init process, while normal games can ignore that and simply count on the default init state for controllers.

Note that mice are enabled by default by JOY_init() and will return emulated pad values for reading the port as if it were a controller. This allows using a mouse as a pad for SGDK games. However, mice use a little more overhead than pads, so a game that doesn't use mice as mice and wants every last scrap of speed should check if mice are connected and turn them off to get just that extra little bit of speed. If you have an existing SGDK based game that needs every last bit of speed and doesn't check for mice, unplug any mice for extra speed. Mice are only enabled if detected.

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

Re: Sega Genesis Dev Kit (SGDK)

Post by Stef » Tue Apr 21, 2020 7:47 pm

Thanks a lot Chilly Willy, looks like this unit needed a documentation update :p
I will add all those precious informations in the header as this is very informative :)

danibus
Very interested
Posts: 135
Joined: Sat Feb 03, 2018 12:41 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by danibus » Sun May 10, 2020 2:15 pm

Hi there!

First cheers to Stef for new update. But my question is about old version :mrgreen:
Not really about old version, as I think I'm doing somethig wrong but I don't know where.

If I use SPR_getNumActiveSprite () I get a low number, i.e. 28
But if I check VDP-Sprites in GensKmod, is almost full...
Captura.PNG
Captura.PNG (47.48 KiB) Viewed 32468 times
but also there are lot of empty spaces between:
Captura2.PNG
Captura2.PNG (14.44 KiB) Viewed 32468 times
I don't remember this in 1.3 SGDK... maybe is 1.4 SGDK sprite optimization, not sure, better ask!

What is happening there? Is ok? :shock:

---------------

Edit: I think these "non-used" sprites are really being used, I saw when some sprites changed they are used, when these sprites are not animated (only 1 sprite for idle animation i.e.) they are a black block, maybe SGKD save this sprite-slots for animation moments or something like that.

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

Re: Sega Genesis Dev Kit (SGDK)

Post by Stef » Mon May 11, 2020 12:03 pm

danibus wrote:
Sun May 10, 2020 2:15 pm
Hi there!

First cheers to Stef for new update. But my question is about old version :mrgreen:
Not really about old version, as I think I'm doing somethig wrong but I don't know where.
...
Edit: I think these "non-used" sprites are really being used, I saw when some sprites changed they are used, when these sprites are not animated (only 1 sprite for idle animation i.e.) they are a black block, maybe SGKD save this sprite-slots for animation moments or something like that.
Hey :)

SPR_getNumActiveSprite() returns you the number of active SGDK sprites (meta sprite) which can internally use several hardware sprite so it's normal that you don't have the same number here.
About the un-used sprite, indeed the sprite engine will always allocate the maximum required sprites, some animation frames may use less sprites than others depending how sprite cutting optimization was done (and indeed that is new to SGDK 1.4).
You may find that sprite cutting optimization is using too many hardware sprites per default, so you can that by specifying the "opt" parameter in the SPRITE resource definition (you can read the rescomp.txt file to get more information about that) :)

danibus
Very interested
Posts: 135
Joined: Sat Feb 03, 2018 12:41 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by danibus » Mon May 11, 2020 9:37 pm

Stef wrote:
Mon May 11, 2020 12:03 pm
danibus wrote:
Sun May 10, 2020 2:15 pm
Hi there!

First cheers to Stef for new update. But my question is about old version :mrgreen:
Not really about old version, as I think I'm doing somethig wrong but I don't know where.
...
Edit: I think these "non-used" sprites are really being used, I saw when some sprites changed they are used, when these sprites are not animated (only 1 sprite for idle animation i.e.) they are a black block, maybe SGKD save this sprite-slots for animation moments or something like that.
Hey :)

SPR_getNumActiveSprite() returns you the number of active SGDK sprites (meta sprite) which can internally use several hardware sprite so it's normal that you don't have the same number here.
About the un-used sprite, indeed the sprite engine will always allocate the maximum required sprites, some animation frames may use less sprites than others depending how sprite cutting optimization was done (and indeed that is new to SGDK 1.4).
You may find that sprite cutting optimization is using too many hardware sprites per default, so you can that by specifying the "opt" parameter in the SPRITE resource definition (you can read the rescomp.txt file to get more information about that) :)
Yesssss, I forget about hw sprite vs SGDK sprites, that's a good point.

Regarding the rest, I don't use to check VPD sprite table as there are enough entries for almost everything... sure cutting optimization makes some funny "sprites" in VDP hehehe thanks for replying

cloudstrifer
Very interested
Posts: 118
Joined: Mon Feb 19, 2018 7:31 pm

Re: Sega Genesis Dev Kit (SGDK)

Post by cloudstrifer » Fri Jun 05, 2020 4:44 pm

@stef

Hi.
I have a sound corruption in my first sfx, fruit.pcm, fruit2.pcm and fruit3.pcm are same sfx.

VIDEO
https://youtu.be/fp6pkZ9joKE

At 11 seconds you can heard the issue.

fruit.pcm = OK
fruit2.pcm = OK
fruit3.pcm = Sound Corruption

sound.res file

Code: Select all

BIN fruit3_sfx "sfx/fruit3.pcm"
XGM stage1 "music/to_the_south.vgm"
BIN fruit2_sfx "sfx/fruit2.pcm"
BIN fruit_sfx "sfx/fruit.pcm"
C file

Code: Select all

...
#define SFX_FRUIT 64
#define SFX_FRUIT2 91
#define SFX_FRUIT3 92
...
XGM_setPCM(SFX_FRUIT, fruit_sfx, sizeof(fruit_sfx));
XGM_setPCM(SFX_FRUIT2, fruit2_sfx, sizeof(fruit2_sfx));
XGM_setPCM(SFX_FRUIT3, fruit3_sfx, sizeof(fruit3_sfx));
...
XGM_startPlayPCM(SFX_FRUIT, 1, SOUND_PCM_CH3);
XGM_startPlayPCM(SFX_FRUIT2, 1, SOUND_PCM_CH3);
XGM_startPlayPCM(SFX_FRUIT3, 1, SOUND_PCM_CH3);
...

Using SGDK 1.51 (april 2020).

I love SGDK, it's marvelous.

Thank you!
Last edited by cloudstrifer on Fri Jun 05, 2020 7:33 pm, edited 1 time in total.

Post Reply