delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/07/30/17:59:25

Message-Id: <m0wtgcC-0003GVC@fwd05.btx.dtag.de>
Date: Wed, 30 Jul 97 23:49 MET DST
To: segercra AT cc DOT helsinki DOT fi, djgpp AT delorie DOT com
References: <5rlql4$t4t$1 AT oravannahka DOT Helsinki DOT FI>
Subject: Re: Allegro: Flashing screen, HELP!
MIME-Version: 1.0
From: Georg DOT Kolling AT t-online DOT de (Georg Kolling)

J-E Mikael B Segercrantz schrieb:
> I am writing a game using SVGA 640x480 resolution with 256 colors, using
> the Allegro 2.2 library.  I have taken the timers into my own control
> (nothing that uses graphics in them), have sounds playing (no music done
> yet), and am reading the keyboard.
>
> This is the skeleton of the routine:
>
> 	while (!(player[0].dead || player[1].dead))
> 	{
> 		/* read the keyboard */
> 		/* move players */
> 		clear(theBitmap);
> 		/* place background image (only the needed part)
> 		   on theBitmap */
> 		/* place the player images on theBitmap */
> 		/* blit theBitmap completely to screen */
> 	}
>
> Now, the screen flickers something awful (but only the background
> image), other objects blitted are steady.  I've tried with vsync(), but
> with no success.
>
> Could anyone with some experience in this help me?  Oh yes, I'm using
> with the player images both stretching and rotation - but my tests show
> that I should still have ample spare time.
>
> -- 
> - Mikael Segercrantz
>   segercra AT cc DOT helsinki DOT fi

You shouldn't copy the bitmap to the visible screen since your copy routine
is not synced with vertical retrace!
Copy it to e.g. (0, 480) and then use the scroll routine with these values.
(You don't have to make up a virtual screen since virtual height is always 
vidmem / virtual width in SVGA [at least in 256 color modes])

you can make up a function like this:

BITMAP *Visible_Page = Create_SUB_BITMAP (&screen, 0, 0, 640, 480); 
BITMAP *Hidden_Page  = Create_SUB_BITMAP (&screen, 0, 480, 640, 480);
/* This could be wrong, you'll have to try */

char Page_Flag = 0; /* 0 = Visible_Page at (0,0), else at (0, 480) */

void Page_Flip (void)
{
 BITMAP *dummy;

 dummy = Visible_Page;         /* Swaps V_P and H_P, so that        */
 Visible_Page = Hidden_Page;   /* V_P is always visible and H_P     */
 Hidden_Page = dummy;          /* is always hidden                  */

 if (Page_Flag)
 { 
  scroll_screen (0,0);
  Page_Flag = 0;
 }
 else
 {
  scroll_screen (0, 480);
  Page_Flag = 1;
 }
}
  
   

Now, you can just draw to Hidden_Page, or to a mem BITMAP and copy it to 
Hidden_Page.
After a picture is completely drawn, you have to call Page_Flip ()
It's always synced to a vertical retrace!
This works with all VBE Versions, with 1 MB vidmem



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019