Array of Bitmaps

SGDK only sub forum

Moderator: Stef

Post Reply
MrTamk1s
Very interested
Posts: 75
Joined: Sun Jan 04, 2015 10:27 pm
Location: Pennsylvania
Contact:

Array of Bitmaps

Post by MrTamk1s » Wed Feb 18, 2015 11:47 pm

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?
SGDK homebrew dev and Unity3D Indie dev.
Sega does what Nintendont!

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

Post by Stef » Thu Feb 19, 2015 12:46 pm

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).

MrTamk1s
Very interested
Posts: 75
Joined: Sun Jan 04, 2015 10:27 pm
Location: Pennsylvania
Contact:

Post by MrTamk1s » Thu Feb 19, 2015 9:46 pm

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?
SGDK homebrew dev and Unity3D Indie dev.
Sega does what Nintendont!

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

Post by Stef » Fri Feb 20, 2015 9:35 am

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 :)

Post Reply