Page 1 of 10

struggling with loading bitmap

Posted: Tue Feb 04, 2014 10:28 pm
by matteus
Hi,
I've successfully ran the hello world tutorial and am now doing the tile and tilemap tutorial but i get compile errors.

Launching tool 'Make': C:\Dev\md\sdk\bin\make -f C:\Dev\md\sdk\makefile.gen (in C:\Users\Matt\DevWork\md\TheGame)
stdout> C:/Dev/md/sdk/bin/mkdir -p out
stdout> C:/Dev/md/sdk/bin/mkdir -p out/src
stdout> C:/Dev/md/sdk/bin/mkdir -p out/res
stdout> C:/Dev/md/sdk/bin/gcc -m68000 -Wall -O1 -fomit-frame-pointer -fno-builtin-memset -fno-builtin-memcpy -IC:/Dev/md/sdk/include -Iinclude -Isrc -Ires -c main.c -o out/main.o
stderr> main.c: In function `main':
stderr> main.c:8: error: subscripted value is neither array nor pointer
stderr> main.c:10: error: subscripted value is neither array nor pointer
stderr> main.c:13: error: subscripted value is neither array nor pointer
stderr> main.c:20: error: subscripted value is neither array nor pointer
stderr> make: *** [out/main.o] Error 1
Tool execution terminated with status 2

Posted: Wed Feb 05, 2014 12:33 am
by Stef
I updated the tutorial so it should now compile with the last version of SGDK :
http://code.google.com/p/sgdk/wiki/Tiles

I only fixed the tutorial, the archives is still in old format. There is a lot of changes to do on the tutorial to reflect the last SGDK capabilities !

Posted: Wed Feb 05, 2014 5:53 am
by bastien
Did you have a syntaxe exemple for using the new rescomp.?
Thanks

Posted: Wed Feb 05, 2014 9:22 am
by Stef
bastien wrote:Did you have a syntaxe exemple for using the new rescomp.?
Thanks
You can look into music and sprite samples provided with SGDK.
Also the rescomp.txt explain you how to write your res file.
Here are the sprite sample examples :
http://code.google.com/p/sgdk/source/br ... /music.res
http://code.google.com/p/sgdk/source/br ... es/gfx.res

One important thing is to always have the filename between quotes ;)

Posted: Wed Feb 05, 2014 11:50 am
by bastien
Oh i see we don t need to call it from command line for.converting each file !
Wonderfull tools really :D

Posted: Wed Feb 05, 2014 2:43 pm
by Stef
Indeed, you just need to write your .res file and rescomp will convert it for you and generate header file (.h) according to the .res file =)
Actually that is the same idea as genres but i believe genres was not generating header file and supporting less resource type.
I worked hardly on this tool and it still need improvements but i believe it is already quite useful in its state ;)

Posted: Thu Feb 06, 2014 6:21 pm
by matteus
Wow things are becoming a lot more OO in syntax :)

still having trouble is would seem!

I'm running CodeBlocks, I couldn't get it anything to compile in codebocks due to an error (someone suggested reinstalling which i tried with no joy).

I've created a custom "make" Option in Tools, which compiles from the cmd prompt.

I've got hello world working easily enough just struggling with this. I've modified my code from the old tutorial to reflect the new

Code: Select all

#include <genesis.h>
#include "car.h"

int main( )
{

    // get the image width (in pixel) ==> should be 8pix aligned
    u16 w = car.w;
    // get the image height (in pixel)  ==> should be 8px aligned
    u16 h = car.h;

    // get the palette at moon[2 to 17]
    VDP_setPalette(PAL1, car.palette->data);

    // load bitmap data at moon[18....] in VRAM
    // w/8 = width in tiles we want to load
    // h/8 = height in tile we want to load
    // w/8 = width in tiles of the bitamp
    // the 3rd arg is needed because you could load only a part of the bitmap if you want but SGDK needs the width as reference
    VDP_loadBMPTileData(car.image, 1, w / 8, h / 8, w/8 );
    
    VDP_fillTileMapRectInc(BPLAN, TILE_ATTR_FULL(PAL1, 0, 0, 0, 1), 12, 12, w / 8, h / 8);

	while(1)
	{
		VDP_waitVSync();
	}
	return 0;
}
car.h

Code: Select all

#ifndef _CAR_H_
#define _CAR_H_

extern const Bitmap car;

#endif // _CAR_H_

Posted: Thu Feb 06, 2014 7:04 pm
by Stef
What problem are you getting exactly ? error log could help :)

Posted: Thu Feb 06, 2014 7:08 pm
by matteus
sorry! I forgot to post it :D

stderr> main.c:13: error: request for member `data' in something not a structure or union
stderr> main.c:21: warning: passing arg 1 of `VDP_loadBMPTileData' from incompatible pointer type

Posted: Thu Feb 06, 2014 11:09 pm
by Stef
matteus wrote:sorry! I forgot to post it :D

stderr> main.c:13: error: request for member `data' in something not a structure or union
stderr> main.c:21: warning: passing arg 1 of `VDP_loadBMPTileData' from incompatible pointer type
The warning is normal and can be freely ignored (it will be remove in the next version, but the error should not be there.
The message you got is like you were trying to pass "car.palette.data" instead of "car.palette->data" parameter...
Did you updated all your SGDK files ?

Posted: Fri Feb 07, 2014 1:55 pm
by matteus
Stef wrote:
matteus wrote:sorry! I forgot to post it :D

stderr> main.c:13: error: request for member `data' in something not a structure or union
stderr> main.c:21: warning: passing arg 1 of `VDP_loadBMPTileData' from incompatible pointer type
The warning is normal and can be freely ignored (it will be remove in the next version, but the error should not be there.
The message you got is like you were trying to pass "car.palette.data" instead of "car.palette->data" parameter...
Did you updated all your SGDK files ?
I will make sure I'm up to date with the SGDK files. Thank you for your support Stef it is very much appreciated. It's great that you've created the SGDK and hopefully in time I will create something worth playing from it :) Just need to get the basics under my belt first! :D

Posted: Fri Feb 07, 2014 2:09 pm
by matteus
Out of interest would doing things like this not work?

Code: Select all


#include <genesis.h> 
#include "car.h" 

int main( ) 
{ 
   // Load Palette
   VDP_setPalette(PAL1, car.palette->data); 

   // Load Tiles into VRAM
   VDP_loadBMPTileData(car.image, 1, car.w / 8, car.h / 8, car.w / 8 ); 
    
   // Load Tiles and Palette to Plane B (background B)	
   VDP_fillTileMapRectInc(BPLAN, TILE_ATTR_FULL(PAL1, 0, 0, 0, 1), 12, 12, car.w / 8, car.h / 8 ); 

   while(1) 
   { 
      VDP_waitVSync(); 
   } 
   return 0; 
} 

When the project is built is my image output to an object /class file that has properties?

car.w - width property
car.h - height property
car.palette - palette data
car.image - image data

Posted: Fri Feb 07, 2014 3:36 pm
by Stef
Of course it would work, you can even use simpler methods now :

Code: Select all

u16 VDP_drawBitmap(u16 plan, const Bitmap *bitmap, u16 x, u16 y);
or

Code: Select all

u16 VDP_drawImage(u16 plan, const Image *image, u16 x, u16 y);
depending you declared your image resource as BITMAP or IMAGE :)

Posted: Fri Feb 07, 2014 3:56 pm
by matteus
Stef wrote:Of course it would work, you can even use simpler methods now :

Code: Select all

u16 VDP_drawBitmap(u16 plan, const Bitmap *bitmap, u16 x, u16 y);
or

Code: Select all

u16 VDP_drawImage(u16 plan, const Image *image, u16 x, u16 y);
depending you declared your image resource as BITMAP or IMAGE :)
You've removed the need to load the palette and tiles now too?!?

Posted: Fri Feb 07, 2014 4:24 pm
by matteus
Stef wrote:Of course it would work, you can even use simpler methods now :

Code: Select all

u16 VDP_drawBitmap(u16 plan, const Bitmap *bitmap, u16 x, u16 y);
or

Code: Select all

u16 VDP_drawImage(u16 plan, const Image *image, u16 x, u16 y);
depending you declared your image resource as BITMAP or IMAGE :)
Ok I've only just discovered the doc folder in the SGDK, I wondered where everyone was getting their information from... :)