A.D.A. Amiga Demoscene Archive

        Welcome guest!

  

  

  

log in with SceneID

  

Demos Amiga Demoscene Archive Forum / Coding / Working with OS Friendly Bitmaps

 

Author Message
BalrogSoft
Member
#1 - Posted: 12 Mar 2009 10:40
Reply Quote
Hello!

I bought recently an Efika, DevPac works perfectly on MorphOS, but my codes (rotozoom + texture mapping) access to hardware directly, so i'm trying to make it work on MOS. I'm using an example found on Aminet of RKM examples ported to asm. But i have some questions about bitmaps, and modifying data directly on memory bitplanes. What is the system friendly way to write bitplanes directly on memory?
Crumb
Member
#2 - Posted: 12 Mar 2009 20:13
Reply Quote
here's some crappy code written more than 10 years ago (some pointers will probably be bad)... the fastest thing is locking/unlocking the bitmap, but the easiest a simple WritePixelArray(). BTW, remember to use ASL requester or put an option as it usually works better than ChooseBestModeID

if (!(CyberGfxBase=OpenLibrary("cybergraphics.library ",0)))
{
printf("No se puede abrir la cgx\nHabrá que joderse y tomar por defecto los AGA...\n");
}
if (!(aslbase=OpenLibrary("asl.library",38)))
{
printf("No se puede abrir la asl.library version 38\nAbriendo pantalla por defecto...\n");
}

if ((modopantalla=(ScreenModeRequester *)AllocAslRequest(ASL_ScreenModeRequest,NULL))==NU LL)
{
fprintf(stderr,"Error: no puedo abrir requester de pantalla\n");
}
else
{
kaka=AslRequest(modopantalla,pantallatags);
pantalla=OpenScreenTags(NULL,
SA_ShowTitle, FALSE,
SA_Title,"Gora Amiga Askatasunaren Taldeak!!!",
SA_DisplayID,modopantalla->sm_DisplayID,
SA_Depth,modopantalla->sm_DisplayDepth,
SA_Width,modopantalla->sm_DisplayWidth,
SA_Height,(numerodebuffers*modopantalla->sm_Displa yHeight),
SA_Overscan,modopantalla->sm_OverscanType,
SA_AutoScroll,FALSE,
TAG_DONE);

ventana=OpenWindowTags(NULL,
WA_CustomScreen, pantalla ,
WA_Title,(ULONG) "ventana",
WA_Flags,
WFLG_ACTIVATE | WFLG_BACKDROP | WFLG_BORDERLESS | WFLG_REPORTMOUSE |
WFLG_RMBTRAP,WA_IDCMP, IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE|
IDCMP_RAWKEY|IDCMP_ACTIVEWINDOW|IDCMP_INACTIVEWIND OW/*|IDCMP_DELTAMOVE|IDCMP_VANILLAKEY*/,
TAG_DONE);
if (ventana) rastportptr=ventana->RPort;
//tsk tsk here we get the rastport of the window!




void bloquearpantalla(void){
resultadobloqueo=(APTR)LockBitMapTags(pantalla->Vi ewPort.RasInfo->BitMap/*rastportptr->BitMap*/,LBMI _BASEADDRESS, &direccionbase,TAG_DONE);
}


void desbloquearpantalla(void)
{
UnLockBitMap(resultadobloqueo);
}


//for double buffer the best thing you can do is use OS routines! I used to use an old trick (a worst one): I opened a screen with the height * number_of_buffers and I used ScrollVPort() to switch from one buffer to other.

On the other hand to draw in the screen you could also use a generic function like:
WritePixelArray8(rastportptr, 0, (bufferactual-1)*(pantalla->Height/numerodebuffers ),319,199,(UBYTE *)chunkybuffer, NULL);

check out sources in aminet like "tunnel" and ADoom or Quake.
BalrogSoft
Member
#3 - Posted: 12 Mar 2009 21:49 - Edited
Reply Quote
Hi Crumb!

I was using graphics lib instead cgfx. I got some pixels on screen with writechunkypixels, but i think that kalms c2p will work better, but i can't get it working. I will try also cgfx library, thanks you.
britelite
Member
#4 - Posted: 13 Mar 2009 08:06
Reply Quote
Kalms c2p is only useful for AGA-stuff, not for working with gfx-cards (which is the case on Efika) as the modes on gfx-cards are chunky rather than planar. So, using CGX would be the best choice on Efika, and switching to the c2p when running the same code on AGA.
Reloaded
Member
#5 - Posted: 13 Mar 2009 08:17
Reply Quote
Crumb, please, translate this important message to english ;)

printf("No se puede abrir la cgx\nHabrá que joderse y tomar por defecto los AGA...\n");
kasie
Member
#6 - Posted: 13 Mar 2009 09:18 - Edited
Reply Quote
del
BalrogSoft
Member
#7 - Posted: 13 Mar 2009 09:36 - Edited
Reply Quote
Yes, i know that Kalms C2p is useful only for AGA, but using graphics library, it should work with bitplanes for compatibility with old apps, generic c2p routines of kalms should work also on Efika using the correct way, i'm developing on Efika, and i want my code running on both, Efika with MOS and AmigaOS classic.
noname
Member
#8 - Posted: 13 Mar 2009 12:01
Reply Quote
Whats the speed of cybergraphics today, let's say for a fullscreen 320x256 effect in 256 colors? Can you reach 50 fps on any of the common cards with an 68060? I remember that I did some speedtests on my 060 with cybervision64/3d some ten years ago and the effect actually ran slower on the graphics card than it did with AGA.

Also, if you reckon things are faster today, would that be due to a more efficient library or just because of a different and faster graphics card?
kasie
Member
#9 - Posted: 13 Mar 2009 17:16 - Edited
Reply Quote
BalrogSoft, 2 different versions can be solution ? I mean check if AGA - then aga fucntion, if gfx then gfx fucntion. Or just 2 dfferent binaryes (to make stuff works fast on boch systems)
Crumb
Member
#10 - Posted: 17 Mar 2009 19:38
Reply Quote
@balrog
locking the bitmap to write directly into gfx card memory will require that you use cgx functions. Otherwise you'll have to use WritePixelArray like functions. Opening cgx library is good since it works with classic miggies with rtg (both cgx & p96 will work), MorphOS, OS4...

Its actually quite easy to support both aga c2p & cgx: you try to open a cgx screen, if you can't then set a variable aga=1. When using cgx functions instead of using the pointer of the c2p buffer and later calling kalms c2p routine you simply lock the screen bitmap and use that pointer, after drawing the screen you unlock the bitmap and that's all.

If that sounds complex for you use cgx WritePixelArray() for gfx cards and use Kalms c2p functions when no gfx card is present. Gfx card performance will not crush AGA but it will be quite good anyway (WPA will simply perform a memcopy to the gfx bitmap if the chunky buffer uses the same format)

@noname
if you use anything faster than zorroII (AteoBus, PCI, ZorroIII, Permedia2...) and you write directly into gfx mem it will be *much* faster than aga. My A4000 with CV64 and Cyberstorm MKII 060 always crushed AGA.

The bottleneck is ZorroII as its bandwitch is smaller than chipmem bandwitch. I think 25fps may be possible with ZorroII.
Crumb
Member
#11 - Posted: 18 Mar 2009 11:26
Reply Quote
@noname

btw, you'd better write 4pixels instead of just a single byte as it will usually be faster
BalrogSoft
Member
#12 - Posted: 22 Mar 2009 22:50 - Edited
Reply Quote
Thanks Crumb, one of my goals is a startup code for 4k intros compatible with AOS and MOS, and i will make it using graphics library and audio device only probably, but i have a lot of work, and i don't have to much free time for this project. Another problem is that my routines for rotozoom, and triangle drawing don't work with MOS.
Crumb
Member
#13 - Posted: 23 Mar 2009 21:52
Reply Quote
@balrogsoft

4KB intros compatible with RTG/AHI may not be easy, perhaps it's easier to make different binaries using #ifdef so size doesn't increase. 64KB ones would be much more easy

opening cybergraphx.library won't increase the size of your code much.

BTW, you can also open AHI and use it as audio.device. IIRC there was an article about it in "the vague 1".

Rotozooms work pretty well writting to the gfx card directly (twice as fast as using a memcpy from your chunkybuffer). Write 4 pixels in one go and you'll boost speed.

You could even optimize it to work in 16x16 pixel groups so it's more cache friendly with 060.

I mean... if you use a chunkybuffer it's dead easy to adapt it for gfx card use. Use WritePixelArray(). It's easy, add #include <proto/cybergraphx.h> open cgx library, close it at the end and call WritePixelArray().
BalrogSoft
Member
#14 - Posted: 23 Mar 2009 22:56 - Edited
Reply Quote
I have tested some sources of Rom Kernel Manual from aminet, and it works without modifications on MorphOS, at this moment i have tested asl.library, audio.device, graphics.library sources and all works perfectly. I will use cybergfx library if i have enough time to support it, i have too much work these days...

My last executable of my code with the old startup code have only 3,5kb crunched with Stone Cracker (library included), and it includes startup code, rotozoom, c2p, 3d objects with texture mapping and graphics. If i use graphics library for c2p instead Kalms code, i think that i can make something compatible for AOS and MOS with only one executable. You know, only Amiga makes it possible :)
Crumb
Member
#15 - Posted: 24 Mar 2009 00:54
Reply Quote
Remember that you'd better include Kalms c2p as graphics.library WritePixelArray functions aren't optimized for AGA speed (you can install BlazeWCP to gain some speed but it's not standard)

You could use kalms c2p for AGA and OS functions for RTG (cgx library even better)

 

  Please log in to comment

  

  

  

 

A.D.A. Amiga Demoscene Archive, Version 3.0