On real hardware program hangs

SGDK only sub forum

Moderator: Stef

Post Reply
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

On real hardware program hangs

Post by alko » Sun Jan 17, 2016 11:04 am

During playback wav-sample on real hardware (and on android-emulator "Gensoid" ) program crashes.
but in the emulator Kega Fusion all right.

Code: Select all

 SND_startPlay_PCM(sample, sizeof(sample), SOUND_RATE_16000,SOUND_PAN_CENTER,FALSE);
 
I tried different samples.
Also tried turn off interrupts. It did not help.
Image

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: On real hardware program hangs

Post by alko » Sun Jan 17, 2016 3:44 pm

Cartridge - everdrive v3
Image

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: On real hardware program hangs

Post by alko » Sun Jan 17, 2016 6:42 pm

hmmm... standard example of sound-driver works properly...

It may necessary use any specific program to convert the wav?

I use jetAudio (PCM 16 kHz 8bit MONO).
Image
Image

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

Re: On real hardware program hangs

Post by Stef » Sun Jan 17, 2016 8:38 pm

SGDK should convert it for you, why are you converting it yourself ?
At least you can resample it to 16000 Khz as the resampler in rescomp is rubbish, but you can keep your file as WAV file at least to avoid any problem :)

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: On real hardware program hangs

Post by alko » Mon Jan 18, 2016 5:24 am

I already converts from original file Wav 44 kHz 16bit to Wav 16 kHz 8bit
Image

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

Re: On real hardware program hangs

Post by Stef » Mon Jan 18, 2016 8:56 am

Ok that sounds correct :-) as long you keep them in WAV format it should be ok. Maybe the problem come from the wav converter in SGDK :-/

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: On real hardware program hangs

Post by alko » Mon Jan 18, 2016 10:35 am

One gets the impression Z80 conflicts with 68000.
They have the common bus.

Or maybe amplitude too large for this audio-driver :|
Image

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

Re: On real hardware program hangs

Post by Stef » Mon Jan 18, 2016 10:46 am

Except if you are hanging the main BUS for very long period (with DMA or just accessing VDP too much during active area) it should not have any effect on Z80. Rescomp automatically takes care of converting 16 bits WAV to 8 bits if need, that could not be an amplitude problem...
Do you hear anything on real hardware ? did you try to comment all your code except the WAV play command ?

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: On real hardware program hangs

Post by alko » Mon Jan 18, 2016 4:59 pm

Do you hear anything on real hardware ?
VGM|XGM-music played correctly.
did you try to comment all your code except the WAV play command ?

Code: Select all

#include <genesis.h>

#include "gfx.h"
#include "music.h"
#include "fonanimate.h"
#include "lyapanimate.h"
#include "globalvar.h"
#include "menu.h"
#include "worm.h"
#include "tride.h"

.....
static void joyEvent(u16 joy, u16 changed, u16 state);
....

int main()
{
level=lvl_worm_boss;


    SYS_disableInts();
    VDP_setScreenWidth320();
    VDP_setScreenHeight240();
    JOY_setEventHandler(joyEvent);
    zastavka();
    SYS_enableInts();
   
   .....
}

.....

static void zastavka()
{
    ind = TILE_USERINDEX;

    VDP_drawImageEx(BPLAN, &alko, TILE_ATTR_FULL(PAL0, FALSE, FALSE, FALSE, ind),4, 0, FALSE, TRUE);
    memcpy(&palette[0], alko.palette->data, 16 * 2);
    VDP_fadeIn(0, (3 * 16) - 1, palette, 150, FALSE);

    SND_startPlay_PCM(hristu, sizeof(hristu), 
    SOUND_RATE_16000,
    SOUND_PAN_CENTER,
    FALSE); //THERE PROGRAM CRUSHED
    
    waitTick(900);

    VDP_fadeOut(0, (1 * 16) - 1, 150, FALSE);
}

.............
static void joyEvent(u16 joy, u16 changed, u16 state)
{
    // START button state changed

    /*
       if (changed & BUTTON_START)
       {

       }

       if (changed & state & (BUTTON_A | BUTTON_B | BUTTON_C))
       {

       }*/
}

Image

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

Re: On real hardware program hangs

Post by Stef » Mon Jan 18, 2016 9:46 pm

I don't see any problem with the code... not sure about what happen :-/
Did you try to comment every thing except the WAV command then re-enable one by one to see where the problem arrive.

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: On real hardware program hangs

Post by alko » Sun Feb 14, 2016 6:15 pm

SND_startPlayPCM_XGM (which is intended for mixing samples and music) does not hangs on hardware, unlike of SND_startPlay_PCM.
But the sample is played back slowly, as if a sampling frequency (16 kHz) does not support.
Image

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

Re: On real hardware program hangs

Post by Stef » Mon Feb 15, 2016 11:34 am

When you want to play sample and at same time play music, you need to stick on XGM driver methods (SND_startPlayPCM_XGM(..) here) else you will change the current loaded driver and music will stop ! The XGM driver requires sample at 14Khz, normally if you define them correctly in the resources files they should be automatically converted but i recommend you to do it manually as the conversion quality may be better than my automatic one.

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: On real hardware program hangs

Post by alko » Mon Feb 15, 2016 2:06 pm

Stef wrote:When you want to play sample and at same time play music
I just wanted to play a sample without music, but in this case it hangs [SND_startPlayPCM]
completely hangs
Image

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

Re: On real hardware program hangs

Post by Stef » Mon Feb 15, 2016 3:42 pm

You probably have some edge effects with others pieces of your code, as the sound driver test sample provided in SGDK does work on real hardware (and use the same SND_startPlayPCM(..) method).
Try to isolate code to understand when it start/stop to work.

Post Reply