GP32 Mirko: Blitblit Function?


CrazyDesi

Member
Joined
Apr 13, 2004
Messages
446
I dont know what other people call it, but I call it BlitBlit functions. Anyone know if Mirkos has this or how to implement it?

Note: If you don't know what I'm talking about. I just mean a function that takes the x, y, height, and width of one image and then takes the x and y of where you wanna put it.
 
CrazyDesi posted on Jul 25 2004 at 08:52 AM said:
I dont know what other people call it, but I call it BlitBlit functions. Anyone know if Mirkos has this or how to implement it?

Note: If you don't know what I'm talking about. I just mean a function that takes the x, y, height, and width of one image and then takes the x and y of where you wanna put it.
Use Function :
void gp_drawSprite ( u16 *sprite, short put_x, short put_y, u16 *framebuffer, u16 xsize, u16 ysize );

u16 *sprite
sprite raw data 16bit

short put_x
[0-319] x-pos on screen

short put_y
[0-239] y-pos on screen

u16 *framebuffer
pointer to the framebuffer we are painting to

u16 xsize
x-size of sprite in pixel

u16 ysize
y-size of sprite in pixel

RETURNS
nothing

convert your sprite with:
./bmp2bin -p input.bmp output.raw

easy, or ???
 
Last edited by a moderator:
mr.mirko posted on Jul 25 2004 at 09:11 AM said:
CrazyDesi posted on Jul 25 2004 at 08:52 AM said:
I dont know what other people call it, but I call it BlitBlit functions. Anyone know if Mirkos has this or how to implement it?

Note: If you don't know what I'm talking about. I just mean a function that takes the x, y, height, and width of one image and then takes the x and y of where you wanna put it.
Use Function :
void gp_drawSprite ( u16 *sprite, short put_x, short put_y, u16 *framebuffer, u16 xsize, u16 ysize );

u16 *sprite
sprite raw data 16bit

short put_x
[0-319] x-pos on screen

short put_y
[0-239] y-pos on screen

u16 *framebuffer
pointer to the framebuffer we are painting to

u16 xsize
x-size of sprite in pixel

u16 ysize
y-size of sprite in pixel

RETURNS
nothing

convert your sprite with:
./bmp2bin -p input.bmp output.raw

easy, or ???
I thought that just takes an image and then takes the width and height of it starting at pixel 0, 0 of the image.

Will this take an image, start in the middle of it, and then take the height and pixel of that image. Finally put it on the screen?

Wouldn't you neeed:

X position to start on image.
Y position to start on image.
Width of image.
Height of image.
X of destination.
Y of destination.
 
Last edited by a moderator:
You're right. This will only work if each tile/sprite is in a seperate file. Mirko should add a function so you can have all your tiles in one file and do what you're saying.
 
Will you be happy enough with just setting the X coordinate of where you will cut your image ?
It will work if your image is a kind of banner. Such as a font or an animated sprite.

Your image will looks like: (case of a sprite with 8 position)
Code:
+-+-+-+-+-+-+-+-+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
And you display it by giving:
- pointer to screen
- width and height of screen (if needed)
- x and y on image
- pointer to sprite
- width and height of sprite
- localX of sprite
- localwidth of sprite

In this case, just use Mr Mirko function and instead of giving sprite pointer, give pointer+localX*spriteHeight. And instead of giving sprite width, give local width.

It should work.
 
yaouank posted on Aug 3 2004 at 03:46 PM said:
In this case, just use Mr Mirko function and instead of giving sprite pointer, give pointer+localX*spriteHeight. And instead of giving sprite width, give local width.
Will this work? Isn't the sprite stored as a contiguous array? If you tell the gp_drawSprite function an width shorter than the real width or a height shorter than the real height wouldn't it try to read it contiguously?

Also, how can pointer+localX*spriteHeight work? Wouldn't it need to account for the localY as well?

EDIT: I looked at the code and it seems that an alternative height should be OK but an alternative width should not. Am I misunderstanding what you are trying to accomplish? My thinking is you have an large image and you want to display a subsection of it. For example your master image is 1000x1000 and you want to display a 20x72 rectangle starting at point 50, 100 within the image.
 
Last edited by a moderator:
yaouank posted on Aug 3 2004 at 03:46 PM said:
Will you be happy enough with just setting the X coordinate of where you will cut your image ?
It will work if your image is a kind of banner. Such as a font or an animated sprite.

Your image will looks like: (case of a sprite with 8 position)
Code:
+-+-+-+-+-+-+-+-+
|0|1|2|3|4|5|6|7|
+-+-+-+-+-+-+-+-+
And you display it by giving:
- pointer to screen
- width and height of screen (if needed)
- x and y on image
- pointer to sprite
- width and height of sprite
- localX of sprite
- localwidth of sprite

In this case, just use Mr Mirko function and instead of giving sprite pointer, give pointer+localX*spriteHeight. And instead of giving sprite width, give local width.

It should work.
Yah mirko already pointed this out. It would still be easier to have rows but this is good enough.
 
Last edited by a moderator:
Yes as people pointed out, you can hash into the array (which is two-dimensional of course, with an x and y coordinate) using "array[x+y*width]".

Lemme see...

#define GPBITBLIT(sp, ix, iy, x,y, fb, w, h) gp_drawSprite ( (sp+(ix+iy*w)), x, y, fp, width, height )

sp - pointer to sprite
ix - index length-wise in sprite (x)
iy - index height-wise in sprite (y)
x - on screen
y - on screen
fb - framebuffer
w - width of sprite
h - height of sprite

Does that look right? You may want to include something like that in the next version of your SDK, Mirko.
 
generalnmx posted on Aug 4 2004 at 02:16 AM said:
#define GPBITBLIT(sp, ix, iy, x,y, fb, w, h) gp_drawSprite ( (sp+(ix+iy*w)), x, y, fp, width, height )
Did you test that? I don't believe that it will work.
 
Last edited by a moderator:
Dalto posted on Aug 11 2004 at 04:17 AM said:
generalnmx posted on Aug 4 2004 at 02:16 AM said:
#define GPBITBLIT(sp, ix, iy, x,y, fb, w, h) gp_drawSprite ( (sp+(ix+iy*w)), x, y, fp, width, height )
Did you test that? I don't believe that it will work.
i wrote a gp_drawTiled32 funktion, its in the next sdk version, and easy to handle
 
Last edited by a moderator:
mr.mirko posted on Aug 19 2004 at 10:18 AM said:
Dalto posted on Aug 11 2004 at 04:17 AM said:
generalnmx posted on Aug 4 2004 at 02:16 AM said:
#define GPBITBLIT(sp, ix, iy, x,y, fb, w, h) gp_drawSprite ( (sp+(ix+iy*w)), x, y, fp, width, height )
Did you test that? I don't believe that it will work.
i wrote a gp_drawTiled32 funktion, its in the next sdk version, and easy to handle
Does it work with non tile programs for page flipping?
 
Last edited by a moderator:
Back
Top