Having difficulty getting 320x224 image on screen SGDK

SGDK only sub forum

Moderator: Stef

Post Reply
sendbit
Newbie
Posts: 7
Joined: Wed Apr 25, 2012 4:54 pm

Having difficulty getting 320x224 image on screen SGDK

Post by sendbit » Wed Apr 25, 2012 8:22 pm

I cannot figure out how to make headers which could replace P1010667_pal.h and P1010667_tile.h from the WIKI page at: http://code.google.com/p/sgdk/wiki/sgdk_tile_functions . I can compile correctly when I use those given files, but I want to use my own images instead. The best I have been able to get is something that is really wrapped and upside-down that almost resembles my art.

If anyone knows how to display a 320x224 image on screen with SGDK, would you please help me with this? Simple step by steps would be greatly appreciated.

thanks.

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

Post by Stef » Wed Apr 25, 2012 9:03 pm

The simplest method is to use one of these functions :

Code: Select all

/**
 *      Load and draw a Genesis 4 BPP bitmap.
 *      A Genesis bitmap is a 4 bpp bitmap which has been converted via the bintos tool.
 *      The resulting file contains bitmap size info and 16 colors palette.
 *
 * \param genbmp16
 *      Genesis bitmap data buffer.
 * \param x
 *      X coordinate.
 * \param y
 *      y coordinate.
 * \param numpal
 *      Palette (index) to use to load the bitmap palette information.
 */
void BMP_loadGenBmp16(const u16 *genbmp16, u16 x, u16 y, u16 numpal);


/**
 *      Load and draw a Genesis 4 BPP bitmap with specified dimension.
 *      A Genesis bitmap is a 4 bpp bitmap which has been converted via the bintos tool.
 *      The resulting file contains bitmap size info and 16 colors palette.
 *      The bitmap is scaled to the specified dimension.
 *
 * \param genbmp16
 *      Genesis bitmap data buffer.
 * \param x
 *      X coordinate.
 * \param y
 *      y coordinate.
 * \param w
 *      width (expected to be relative to bitmap resolution : 1 pixel = 1 byte).
 * \param h
 *      height.
 * \param numpal
 *      Palette (index) to use to load the bitmap palette information.
 */
void BMP_loadAndScaleGenBmp16(const u16 *genbmp16, u16 x, u16 y, u16 w, u16 h, u16 numpal);
You just should have your bitmap file in same directory than your sources files or in a "res" sub-directory, the makefile will automatically generate the corresponding bin and header file.

Be sure your bitmap is 16 colors only.

If your bitmap file is named "image.bmp" the resulting header file is "image.h" and so your code will look like :

Code: Select all

#include "genesis.h"
#include "image.h"

int main()
{
    //set up the screen
    VDP_setScreenWidth320();
    VDP_setHInterrupt(0);
    VDP_setHilightShadow(0);

    // display bitmap at position (0, 0) and use palette 0
    BMP_loadGenBmp16(image, 0, 0, 0);

    while(1);
}

The code described in the tutorial is not than easy but correspond to the "usual way" of uploading tile data to video processor then use them to display image.
The methods above are not fast enough to be used "in game".

sendbit
Newbie
Posts: 7
Joined: Wed Apr 25, 2012 4:54 pm

Post by sendbit » Thu Apr 26, 2012 8:33 am

Thanks, that was helpful!

P.S. :
I found that paint can export 16color pretty well by changing the first 16 colors of its palette after creating an optimized 16 indexed color with dith in GIMP.

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

Post by Stef » Thu Apr 26, 2012 11:07 am

Yeah you can even use Paint.
One problem i didn't mentioned, color 0 is transparent so you should not use it in your bitmap.

Post Reply