Page 1 of 1

Array of Bitmaps

Posted: Wed Feb 18, 2015 11:47 pm
by MrTamk1s
How can I explicitly declare an array of Bitmaps in SGDK?
I am trying to create a function called "DrawBG", which, when supplied
with an ID param, will load the specified bitmap with it's specified
drawing configurations, and then draw it as a full-screen image.

I've tried the following below:

DrawBG.c:

Code: Select all

#include "../res/Gfx/Planes.h"
#include "../inc/DrawBG.h"
#include <vdp.h>

void DrawBG(u8 Scrn)
{
    if (Scrn==17)
    {
        plan=VDP_PLAN_B;
    }
    else
    {
        plan=VDP_PLAN_A;
    }

    VDP_drawBitmap(plan, &Screens[Scrn], 0,0);
}
DrawBG.h

Code: Select all

#include <Genesis.h>
#include <bmp.h>
#include "../res/Gfx/Planes.h"
u16 plan;

const Bitmap* Screens [] =
{
	S1, S2, S3, S4, S5, S6, S7, S8, S9, S10
	M1, M2, M3,
	FMV_BG, FMV_Text, FMV_Ani
};
Planes.h

Code: Select all

#include "Genesis.h"
#include "bmp.h"

#ifndef _PLANES_H_
#define _PLANES_H_

extern const Bitmap S1;
extern const Bitmap S2;
extern const Bitmap S3;
extern const Bitmap S4;
extern const Bitmap S5;
extern const Bitmap S6;
extern const Bitmap S7;
extern const Bitmap S8;
extern const Bitmap S9;
extern const Bitmap S10;
extern const Bitmap M1;
extern const Bitmap M2;
extern const Bitmap M3;
extern const Bitmap FMV_BG;
extern const Bitmap FMV_Text;
extern const Bitmap FMV_Ani;
#endif // _PLANES_H_
but am getting the following errors in Code::Blocks:

Code: Select all

||=== Build: default in Ultra Air Hockey (Retro) (compiler: SGDK) ===|
..\Ultra Air Hockey\inc\DrawBG.h|8|error: invalid type argument of `unary *'|
..\Ultra Air Hockey\inc\DrawBG.h|8|error: initializer element is not constant|
..\Ultra Air Hockey\inc\DrawBG.h|8|error: (near initialization for `Screens[0]')|
..\Ultra Air Hockey\inc\DrawBG.h|8|error: initializer element is not constant|
..\Ultra Air Hockey\inc\DrawBG.h|8|error: (near initialization for `Screens[1]')|
..\Ultra Air Hockey\inc\DrawBG.h|8|error: initializer element is not constant|
etc for all array elements.

Any help?

Posted: Thu Feb 19, 2015 12:46 pm
by Stef
I guess you wanted to do this :

Code: Select all

const Bitmap* Screens [] =
{
   &S1, &S2, &S3, &S4, &S5, &S6, &S7, &S8, &S9, &S10
   &M1, &M2, &M3,
   &FMV_BG, &FMV_Text, &FMV_Ani
}; 
As you declared an array of Bitmap pointer (and not just an array of Bitmap).

Posted: Thu Feb 19, 2015 9:46 pm
by MrTamk1s
The code above worked.

Also, yet another nooby question, but how do I display a single sprite using the new SGDK sprite engine (sprite_eng.h)? The tutorial here uses the older VDP_ functions. I am confused about how the Rescomp SPRITE definition works and how to operate with the newer SpriteDefinition struct. Does Rescomp automatically create internal palette and tileset data entries for SPRITE resources, or do I have to make separate definitions and then load the data using VDP_ functions?

Posted: Fri Feb 20, 2015 9:35 am
by Stef
Just look into the sprite sample given in SGDK (in sample folder) :
https://code.google.com/p/sgdk/source/b ... src/main.c

I think it's pretty straightforward and you have doxygen documentation which really help (in .h file and with your IDE if it supports it).
Still i have to update that documentation, a lot of people confuse with old methods and news one.
About the new resources system, just read the rescomp.txt file (in the bin folder). It explain all kind of supported resource and how to declare them :)