Board index » delphi » Image flickering

Image flickering

I'm making a program that uses svga 256 colors. I have found out that the
putimage xorput does not work in this mode. I have therefor made a routine
that gets the background array before the image is being put to the screen.
Then the program overwrites the the image with the old screen and so on.

It seems to work, but I have a small problem with the routine. Sometimes the
image flicker when displayed.

How can I update the screen without this flickering. Is there a kind of
double buffering as I know from my old Amiga, and how does it work.

I would like the answer to be in Turbo Pascal 7.0

The hopefull

Martin Kronborg

 

Re:Image flickering


Quote
>It seems to work, but I have a small problem with the routine. Sometimes the
>image flicker when displayed.

>How can I update the screen without this flickering.

You must wait until the monitor is in vertcal retrace before writing to the
screen to avoid flickering. Also if the routine that writes to the screen is to
slow  you will still have flickering.

James

Re:Image flickering


hi martin,

Quote
> How can I update the screen without this flickering. Is there a kind of
> double buffering as I know from my old Amiga, and how does it work.

> I would like the answer to be in Turbo Pascal 7.0

Well, you need to wait for the vertical retrace (i.e. the delay as the
monitor redraw moves from the bottom back to the top-left....)... This
is usually long enough to do the update...  The problem is if you're
doing the actual calculation etc. during this period it will be too
slow.  I've never done this under SVGA, but under MCGA (which fits
nicely in one segment) the way I do it is to set aside a buffer in
memory.

Once you've got that, redirect your drawing routines to draw to this
'fake' screen.  Then when the vertical retrace comes, transfer the data
on the 'fake' screen to the real screen.  With fast assembler (e.g.
moving DWords - 32bits at a go) you should be able to do it within the
retrace.

You'll need to search out the vertical retrace routines for svga (Im not
sure if they would be the same)..  As for creating a fake screen - the
problem with SVGA is that it doesn't fit into a single segment - and if
your using any of the Borland Pascal progs you'll be restricted to this
in real mode.  In other words, you'll need to grab the memory in two
parts, and write as though they are two parts - but you're probably
doing this for the SVGA anyway.

All the best, hope this is of some help - If you have any questions,
feel free to ask here/email,

Martin Fitzpatrick

--
Email: poohsti...@pmail.net
ICQ#: 11077801
AOL/CServeIM: Flupert
GDT: Game Development Thingy -  Online Group Game Development Project
http://ourworld.compuserve.com/homepages/poohsticks

Re:Image flickering


Hi,

After reading the two other comments I would suggest to use double
buffering, like you used to on your amiga. Simply set up two pages of
graphical memory, and make alteration to one while displaying the
other.

The nice thing about this is that you can only swap the two pages
during a vertical retrace. :-)

Peter de Jong
dej...@kikosoft.com

Re:Image flickering


Martin Fitzpatrick <poohsti...@pmail.net> schrieb im Beitrag
<3748273E.B1AAD...@pmail.net>...

Quote
> hi martin,

> > How can I update the screen without this flickering. Is there a kind of
> > double buffering as I know from my old Amiga, and how does it work.

> > I would like the answer to be in Turbo Pascal 7.0
<snip>
> Once you've got that, redirect your drawing routines to draw to this
> 'fake' screen.  Then when the vertical retrace comes, transfer the data
> on the 'fake' screen to the real screen.  With fast assembler (e.g.
> moving DWords - 32bits at a go) you should be able to do it within the
> retrace.

You cannot assume that drawing (and memory copy) can be done during VSYNC.
For instance, the sync rate of the VESA modes is not given as it is for the
MCGA mode (70Hz). I have a refresh rate of 150Hz in that mode, so the usable
VSync time will be only a fragment of 6.67ms. Using 640*480*256, one already
has 307200bytes to copy to video memory (including bank switches if you are
using banked modes). That makes 46mb per second - which is still within the
possible if you had 6.67ms to draw the screen. However, the VSnyc time will
only be about half of it, making your program only run on extremly fast PCI
cards and AGP cards correctly - note that interruptions such as Timer,
Multitasking, not-so-fast Processor etc. will make the case worse.

Better thing to do is to use two pages in video mem, because then you just
switch the page displayed, which takes virtually no time. Depending on how
you are working with video memory (reading voideo mem is really slow) you
should still build the page in real memory, copy it to the invisible page,
and switch on sync.

Quote
> You'll need to search out the vertical retrace routines for svga (Im not
> sure if they would be the same)..

To my knowledge they are the same.

--
Arsne von Wyss - avonw...@gmx.net
 Pascal, Delphi & Personal stuff: http://bsn.ch/avonwyss
 Programming Contest Problems Archive: http://bsn.ch/contest
 Webmaster von Roger's Equine Pages: http://bsn.ch/pferde

Re:Image flickering


Hi all,
Speaking from personal experience, the 'wait for vertical retrace' thing is
pretty much a red herring.  I used to use code that did that for years in
various projects, then one time disabled it to see what happened...nothing
much.  You do need double buffering of some sort though...the simplest with
relatively decent hardware (dx2/66 +) is to allocate a chunk of memory as the
video buffer, write to that for as long as you want, then dump the whole
thing in one hit to vid memory.  Pretty easy...not exactly 'double buffering'
but still :)

Steve

Other Threads