Mail Archives: djgpp/1997/02/09/08:09:13
steve wilcox writes:
>hi can someone tell me a fast way to copy the contents of
>buffer array ( byte buffer[w*h]; ) direct to the display ?
>i am using allegro 2.1
In VGA 320x200 mode, dosmemput(buffer, w*h, 0xA0000) will do the trick.
If you are using an SVGA mode, you need to deal with bank switching,
which can most easily be done by just calling the Allegro blit()
function. To do this you will need to make your buffer into an Allegro
bitmap, but that's easily done. Instead of malloc() or whatever you
currently use to create this buffer, call:
BITMAP *buffer_bmp = create_bitmap(w, h);
byte *buffer = buffer_bmp->line[0];
Then you can write to your buffer with whatever code you are currently
using, and copy it to the screen with:
blit(buffer_bmp, screen, 0, 0, 0, 0, w, h);
If you don't want to use my bitmap struct, it's pretty easy to write
your own blit function. Try something like:
int y;
unsigned long addr;
for (y=0; y<h; y++) {
addr = bmp_write_line(screen, y);
movedata(_my_ds(), buffer[y*w], screen->seg, addr, w);
}
/*
* Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
* Ghoti: 'gh' as in 'enough', 'o' as in 'women', and 'ti' as in 'nation'.
*/
- Raw text -