Page 1 of 2
Error on the tutorial code... SGDK
Posted: Fri May 03, 2013 7:01 am
by POLYGAMe
Here's the code, as copied and pasted from the SGDK tutorial:
Code: Select all
#include <genesis.h>
#include "moon.h"
int main( )
{
// get the image width (in pixel) ==> should be 8pix aligned
u16 w = moon[0];
// get the image height (in pixel) ==> should be 8px aligned
u16 h = moon[1];
// get the palette at moon[2 to 17]
VDP_setPalette(PAL1, &moon[2]);
// load bitmap data at moon[18....] in VRAM
// w/8 = width in tiles we want to load
// h/8 = height in tile we want to load
// w/8 = width in tiles of the bitamp
// the 3rd arg is needed because you could load only a part of the bitmap if you want but SGDK needs the width as reference
VDP_loadBMPTileData((u32*) &moon[18], 1, w / 8, h / 8, w/8 );
while(1)
{
VDP_waitVSync();
}
return 0;
}
And I get the following errors:
main.c||In function `main':|
main.c|7|error: subscripted value is neither array nor pointer|
main.c|9|error: subscripted value is neither array nor pointer|
main.c|12|error: subscripted value is neither array nor pointer|
main.c|20|error: subscripted value is neither array nor pointer|
||=== Build finished: 4 errors, 0 warnings (0 minutes, 1 seconds) ===|
To be honest, I'm not even sure what the array moon[] is even pointing to... data in the moon.o file?!?!
Any help appreciated

Posted: Fri May 03, 2013 8:13 am
by Stef
Unfortunately the tutorial are outdated and some methods were replaced as some structures too.
moon has now be replaced by a Bitmap structure for easier manipulation so code become :
Code: Select all
// get the image width (in pixel) ==> should be 8pix aligned
u16 w = moon.w;
// get the image height (in pixel) ==> should be 8px aligned
u16 h = moon.h;
// get the palette
VDP_setPalette(PAL1, moon.palette);
// load bitmap data in VRAM
// w/8 = width in tiles we want to load
// h/8 = height in tile we want to load
// w/8 = width in tiles of the bitamp
// the 3rd arg is needed because you could load only a part of the bitmap if you want but SGDK needs the width as reference
VDP_loadBMPTileData((u32*) moon.image, 1, w / 8, h / 8, w/8 );
I really need to update that tutorials :p
Posted: Fri May 03, 2013 8:42 am
by POLYGAMe
Stef wrote:Unfortunately the tutorial are outdated and some methods were replaced as some structures too.
moon has now be replaced by a Bitmap structure for easier manipulation so code become :
Code: Select all
// get the image width (in pixel) ==> should be 8pix aligned
u16 w = moon.w;
// get the image height (in pixel) ==> should be 8px aligned
u16 h = moon.h;
// get the palette
VDP_setPalette(PAL1, moon.palette);
// load bitmap data in VRAM
// w/8 = width in tiles we want to load
// h/8 = height in tile we want to load
// w/8 = width in tiles of the bitamp
// the 3rd arg is needed because you could load only a part of the bitmap if you want but SGDK needs the width as reference
VDP_loadBMPTileData((u32*) moon.image, 1, w / 8, h / 8, w/8 );
I really need to update that tutorials :p
Great, thanks! I'll give it a go

Posted: Fri May 03, 2013 9:12 am
by POLYGAMe
Hmmm... I'm not getting any errors now, but it's displaying a blank screen when run

Posted: Fri May 03, 2013 9:42 am
by POLYGAMe
Okay, by commenting out the set palette line, I get my image in red. How do I get the palette from the actual image file? It seems to be ignoring the colour data in it...
Posted: Fri May 03, 2013 12:17 pm
by POLYGAMe
Nevermind, got it working
It was my image export settings in GIMP.
I sent this .bin to my old videogame dev tutor... LOL. Lucky we're friends

Posted: Fri May 03, 2013 12:52 pm
by Stef
Hehe, excellent

Glad you got it working correctly

Posted: Fri May 03, 2013 1:15 pm
by POLYGAMe
Stef wrote:Hehe, excellent

Glad you got it working correctly

Got sound now too but my wav file is being played at different speeds, depending on the playback rate... I assumed the rate is just the quality... any ideas?
Posted: Fri May 03, 2013 1:28 pm
by Stef
POLYGAMe wrote:Stef wrote:Hehe, excellent

Glad you got it working correctly

Got sound now too but my wav file is being played at different speeds, depending on the playback rate... I assumed the rate is just the quality... any ideas?
The rate is indeed the quality but right now SGDK automatically convert any wav file to 16Khz sample as this is the sample rate used by 4 PCM sound driver. The first idea was to make it easier so people does not need to convert it to 16 Khz but then you cannot use the other available sample rate for the single PCM driver, or you have to use .raw file directly which is not practical. I have to thing about way of improving that...
Posted: Fri May 03, 2013 10:03 pm
by POLYGAMe
Stef wrote:POLYGAMe wrote:Stef wrote:Hehe, excellent

Glad you got it working correctly

Got sound now too but my wav file is being played at different speeds, depending on the playback rate... I assumed the rate is just the quality... any ideas?
The rate is indeed the quality but right now SGDK automatically convert any wav file to 16Khz sample as this is the sample rate used by 4 PCM sound driver. The first idea was to make it easier so people does not need to convert it to 16 Khz but then you cannot use the other available sample rate for the single PCM driver, or you have to use .raw file directly which is not practical. I have to thing about way of improving that...
Okay, so what do I need to do to stop it adjusting the speed?!?
Posted: Fri May 03, 2013 10:23 pm
by Stef
If you play it at 16 Khz it should be at correct speed.
If you rename your file to .wavpcm then SGDK will convert your wav file to adpcm sound file, then you can use the 2ADPCM driver to play it (22 Khz but smaller rom usage as sample is compressed).
Posted: Fri May 03, 2013 11:08 pm
by POLYGAMe
Stef wrote:If you play it at 16 Khz it should be at correct speed.
If you rename your file to .wavpcm then SGDK will convert your wav file to adpcm sound file, then you can use the 2ADPCM driver to play it (22 Khz but smaller rom usage as sample is compressed).
So currently there's no way to play the sounds at higher quality, without adjusting speed?
Posted: Sat May 04, 2013 7:19 pm
by kubilus1
Awesome, I see what I was doing wrong with BMP loading with the new method. Thanks!
Posted: Sat May 04, 2013 9:42 pm
by Stef
POLYGAMe wrote:Stef wrote:If you play it at 16 Khz it should be at correct speed.
If you rename your file to .wavpcm then SGDK will convert your wav file to adpcm sound file, then you can use the 2ADPCM driver to play it (22 Khz but smaller rom usage as sample is compressed).
So currently there's no way to play the sounds at higher quality, without adjusting speed?
If you keep your file as .wav --> only 16 Khz play with the method
If you rename it to .wavpcm --> only 22 Khz play with the method
If you convert it to binary file (8 bits signed) with tools as audacity or wavosaur and name your file with .raw extension then you can use whatever quality you want (always with
method).
Honestly 22Khz ADPCM is already quite good quality for the MD, you are quite limited on rom size.
Posted: Sat May 04, 2013 10:37 pm
by POLYGAMe
Stef wrote:POLYGAMe wrote:Stef wrote:If you play it at 16 Khz it should be at correct speed.
If you rename your file to .wavpcm then SGDK will convert your wav file to adpcm sound file, then you can use the 2ADPCM driver to play it (22 Khz but smaller rom usage as sample is compressed).
So currently there's no way to play the sounds at higher quality, without adjusting speed?
If you keep your file as .wav --> only 16 Khz play with the method
If you rename it to .wavpcm --> only 22 Khz play with the method
If you convert it to binary file (8 bits signed) with tools as audacity or wavosaur and name your file with .raw extension then you can use whatever quality you want (always with
method).
Honestly 22Khz ADPCM is already quite good quality for the MD, you are quite limited on rom size.
Thanks! That helps heaps
