- Online Community Forums » Programming Questions » VRAM sprites scrambled under DOS

This thread is locked; no one can reply to it. rss feed Print
VRAM sprites scrambled under DOS
Member #7,638
August 2006

Hello everyone,

I am using page flipping and whenever I load sprites into VRAM, so I can do fast VRAM->VRAM blits, the sprites appear scrambled. RAM->VRAM blits in these modes work fine.

The sprites just look like static on a TV screen, as if the bitmap pointer is pointing into the wilderness or something.

Under Windows, everything looks fine though, but when compiling for DOS (using DJGPP) it won't work. I am using Allegro 4.2.0 and am limited to this release, so it won't be able to upgrade for me.

I have written a function that allows me to upload sprites into video memory:

BITMAP* pnd_LoadIntoVRAM(BITMAP* sprite)
  BITMAP* video_bitmap = create_video_bitmap(sprite->w, sprite->h);

  if (video_bitmap != NULL)
    clear_to_color(video_bitmap, bitmap_mask_color(video_bitmap));
    draw_sprite(video_bitmap, sprite, 0, 0);
    return video_bitmap;

  return NULL;

It is called with a pointer to a normal memory bitmap and is supposed to return with the pointer to the video bitmap.

I am using a video mode of 320x240 with 8-bit colours.

Under DOS, Allegro is using the Mode-X driver for this purpose (automatically set via GFX_AUTODETECT). It reports a virtual screen size of 320x819, regardless of which call I use of these:

if (set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 240 * num_pages) != 0)
  if (set_gfx_mode(GFX_AUTODETECT, 320, 240, 0, 0) != 0)
    return 0;

When I try triple buffering under DOS, there seems to be an error when loading sprites into VRAM. Again, under Windows, everything works fine.

Note: I am using DOSBox for tests of my code. I tried exupdate.c, exflip.c and ex3buf.c to see if DOSBox was responsible for this and every one of them worked fine. But they don't do any VRAM->VRAM blits as far as I know.

When trying to execute the DOS DJGPP executable under XP, the same error occurs -> scrambled sprites.

Now I suspect anything to be wrong with my code that does not show on Windows.

Thanks for any advice.

Christoph B.

Go to: