Page 1 of 1

From GBA to Ps2 - Any way to do similar per pixel blitting?

Posted: Mon Jun 26, 2006 12:48 pm
by Kojima
My only console experience so far has been with The vba. And one feature I liked about it was it's mode 3 15bit mode, that let you write directly to the framebuffer,

Code: Select all

videoBuffer[ y*width+x ] = rgb3( 31,31,31 );
It wasn't too fast, but coming from the amiga like I do I have a thing for per pixel blitting that cannot be explained by words.

So basically, can this be done in the ps2?

I realise you won't be able to poke directly into the GS as it's got to go through packets to the gif (or something to that effect), but can I do this?

Code: Select all


   void * buffer = malloc ( 640*480*4 );
   
   MyPlot( 20,20,MyRgb(255,255,255) ,buffer)

Then do something like this with ps2's dma

Code: Select all


  DMA_FASTCOPY( buffer, PSLIB_GETVIDEOBUFFER() );

So basically I'd work on a 'scratch' buffer in ram (Presumably high speed? bandwidth specs for ps2 look pretty good) then dma it across into the active screen buffer.

Or is it more abstracted in the ps2 and you have to rely on gif packets for everything?

Posted: Mon Jun 26, 2006 1:09 pm
by cheriff
Yes, you can easily do that. You can either dma directly to the framebuffer (note that this still needs to be in a gif packed with giftags describing where to dump the image) and it will show.

Alternatively you can instead DMA the image to somewhere else in VRAM and then use it to tecture a full screen quad, wich can buy you nice things like scaling, alpha blending, etc.

Sources like gsKit show how to load & display a texture.. I guess there would't be much different to maintain an in-memory buffer instead of a bmp/png file...

Posted: Mon Jun 26, 2006 1:14 pm
by Kojima
Cool, now I can get to work on my mega crap software 3d engine :)

Posted: Mon Jun 26, 2006 1:18 pm
by cheriff
ohh, also you could use something pre-existing (again maybe gsKit) and simply use the pixel primitive to draw stuff. You would loose the ability to read stuff back (no biggie if you also keep a local cache) and performance would likey suck quite badly, but should be simple to get off the ground.

Posted: Mon Jun 26, 2006 1:29 pm
by Kojima
Thanks for the idea but for now I'll go with the scratch ram to vram idea I think. Only cos I've been dreaming about doing ever since I found this page, I'm a man on a mission now :)

Posted: Fri Jun 30, 2006 3:27 pm
by Kojima
So I've got the gsKit installed and running and have got a simple demo running, but does anyone know how/if I can upload a memory bank(I.e a malloced pointer) to vram using gsKit? The demos only cover primitive drawing so far.

Or do I have to treat the buffer as a texture?
If so, what's the gsKit equilivent of glTexImage2D ?


Any examples please?

Posted: Sat Jul 01, 2006 12:11 am
by SSpeare
You have two options, one is to upload the data to VRAM somewhere and then render it as a textured primitive. That would be slow, however, and pointless if you will be drawing the entire frame.

Better is to upload your image data to VRAM and point the destination address as the frame buffer. The function call in gsKit will probably have the word "texture" in it or image. I'm not familiar with gsKit. This is pretty straightforward to do and I'm sure gsKit can do it.

On the underneath side, you just build a GIF packet with the proper width/height and pixel format with the destination address on the GS as the location of the framebuffer. This is what the call to gsKit will do, so it's easier to just use gsKit and read the source if you want to know what it's doing.

You'll want to use double-buffering I'm pretty sure in this case.

Sorry, no samples from me! My dev machine is still down and I haven't looked at gsKit yet.

Posted: Sat Jul 01, 2006 12:30 am
by Kojima
Sounds pretty straight forward, thanks for the info. I'll have a look through the gskit headers see if I find anything like that. Though I'd be very happy if someone here could save me potentially having to read something by telling me what function I need :)

Posted: Sat Jul 01, 2006 12:56 am
by SSpeare
Check out the examples in gsKit. There are two texture examples there that should be a good guide.

EDIT:
Actually, current gsKit in SVN has several:
alpha
bigtex
linuz-texture
png-texture
textures

and fb looks good.

Posted: Sat Jul 01, 2006 1:10 am
by Kojima
yeah the fb one appears to be what I need, i'll have a closer look after i've finished my pong game(Don't laugh, we all have to start somewhere :) )