Page 1 of 1

Code Crashes Emulator

Posted: Sat Oct 07, 2017 1:00 am
by Scorpion Illuminati
Hi,

I am trying to learn the SGDK and am stuck on literately the 3rd tutorial which is drawing a background using tiles. Here is a link to the source code. When i compile it it compiles fine, however when I run it it crashes my emulator. Any assistance in this matter would be greatly appreciated.

Sincerely,

Scorpion Illuminati

Re: Code Crashes Emulator

Posted: Sat Oct 07, 2017 7:33 am
by dub
Works at home. Test with blastem, kfusion and genskmod.

I also tried to change tile number with TILE_USERINDEX and also works.
same source with my binary file.
https://www.dropbox.com/s/o1u9wz5ef9d6w ... t.zip?dl=0

Code: Select all

//we load our unique tile data at position 1 on VRAM
    VDP_loadTileData( (const u32 *)titleScreen_Tiles, TILE_USERINDEX, 1, 0);

    //write our tile 1 on plane B at (5,5) with pal 0
    VDP_setTileMapXY(PLAN_B, TILE_USERINDEX, 5, 5);
Image

Does your batch launch binary in good directory : c:\blastem\blastem.exe -d c:\segadevc\out\rom.bin

Re: Code Crashes Emulator

Posted: Sun Oct 08, 2017 12:39 am
by Scorpion Illuminati
dub wrote:
Sat Oct 07, 2017 7:33 am
Works at home. Test with blastem, kfusion and genskmod.

I also tried to change tile number with TILE_USERINDEX and also works.
same source with my binary file.
https://www.dropbox.com/s/o1u9wz5ef9d6w ... t.zip?dl=0

Code: Select all

//we load our unique tile data at position 1 on VRAM
    VDP_loadTileData( (const u32 *)titleScreen_Tiles, TILE_USERINDEX, 1, 0);

    //write our tile 1 on plane B at (5,5) with pal 0
    VDP_setTileMapXY(PLAN_B, TILE_USERINDEX, 5, 5);
Image

Does your batch launch binary in good directory : c:\blastem\blastem.exe -d c:\segadevc\out\rom.bin
Thanks, your code made it work for me. Not sure what TILE_USERINDEX s but it fixed it for me. So now the question is how do I setup the palette so I can show more then different shades of black? There aren't any tutorials that I could find for setting up the palette manually without going through the trouble of drawing an image just to convert it. Any assistance in this matter would be greatly appreciated.

Sincerely,

Scorpion Illuminati

Re: Code Crashes Emulator

Posted: Sun Oct 08, 2017 7:43 am
by dub
You can read the tuto here : https://github.com/Stephane-D/SGDK/wiki/Tuto-Intro

TILE_USERINDEX is the beginning of the vram for the user and who not used by the system.

For the palette, I always use Image but in the source code and the doc, you must fnd a way with "VDP_setPalette (u16 num, const u16 * pal );"
If you change the first 16 colors :: num = 0 to 15 => PAL0

For the palette color :
Color is defined with 3 bits for each component : xxxxBBBxGGGxRRRx
https://github.com/Stephane-D/SGDK/blob ... /vdp_pal.c

So red = 000R, blue = 0B00 and red+blue = 0B0R

VDP_setPalette(0, 0x0002);
VDP_setPalette(1, 0x0200);

Code: Select all

const u16 palette_red[16] =
{
    0x0000,
    0x0002,
    0x0004,
    0x0006,
    0x0008,
    0x000A,
    0x000C,
    0x000E,

    0x000E,
    0x000E,
    0x000E,
    0x000E,
    0x000E,
    0x000E,
    0x000E,
    0x000E
};
Not tested :wink:

Re: Code Crashes Emulator

Posted: Sun Oct 08, 2017 7:49 am
by cero
Read through the include files. They describe every available function in detail.