Code Crashes Emulator

SGDK only sub forum

Moderator: Stef

Post Reply
User avatar
Scorpion Illuminati
Interested
Posts: 26
Joined: Fri Oct 02, 2015 4:58 pm

Code Crashes Emulator

Post by Scorpion Illuminati » Sat Oct 07, 2017 1:00 am

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
Scorpion Illuminati - An open source rhythm game for the Sega Genesis
http://www.scorpionilluminati.tk

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

Re: Code Crashes Emulator

Post by dub » 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

User avatar
Scorpion Illuminati
Interested
Posts: 26
Joined: Fri Oct 02, 2015 4:58 pm

Re: Code Crashes Emulator

Post by Scorpion Illuminati » Sun Oct 08, 2017 12:39 am

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
Scorpion Illuminati - An open source rhythm game for the Sega Genesis
http://www.scorpionilluminati.tk

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

Re: Code Crashes Emulator

Post by dub » Sun Oct 08, 2017 7:43 am

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:

cero
Very interested
Posts: 200
Joined: Mon Nov 30, 2015 1:55 pm

Re: Code Crashes Emulator

Post by cero » Sun Oct 08, 2017 7:49 am

Read through the include files. They describe every available function in detail.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests