Информационный сервер для программистов: Исходники со всего света. Паскальные исходники со всего света
  Powered by Поисковый сервер Яndex: Найдется ВСЁ!
На Главную Исходники Форум Информер Страны мира
   Графика    >>    pageflip
 Flicker-Free Animation with Page-Flippng   Kai Rohrbacher 07.05.1990

Использование технологии переключения графических страниц для устранения мерцания при анимации спрайтов.
Using a simple technique called "page-flipping" as a solution to do fast flicker-free animation in TurboPascal.


>From: s_rohrbacher Newsgroups: comp.lang.pascal Subject: Re: flicker-free animation with TP Date: 7 May 90 20:24:27 GMT Organization: University of Karlsruhe, FRG Some days ago, one of you asked for a solution to do fast flicker-free animation in TurboPascal. I myself had the same problem and circumvented it by a simple technique called "page-flipping": nearly every graphic card has 2 independent graphic pages, so it is possible to draw at one page while showing the other. If the "background" page is finished, you just "flip" the pages: thus, at any time all actions take place in the background and you get a smooth animation! In TP, you choose the visible page with "SetVisualPage" and the working page with "SetActivePage". - Take the following program as an example: it animates a hatched square, either with or without page-flipping (adapt proc. "Initialize" if you have a Hercules instead of an EGA/VGA). The only thing to notice is that you have to store coordinates for 2 cycles to be able to erase a sprite on the correct page. There remains one last possibility of (minor) flicker: depending on your PC's BIOS, it may happen that programs flip pages while the cathode ray is in the midst of displaying data: in that case you have to bypass BIOS and synchronize switching directly with the "vertical retrace" (the moment while the cathode ray moves back from the bottom-right to the upper-left corner). As a time-critical task (the corresponding bit at port $3DA, Bitmask 8 (or $3BA, Bitmask 128 for HGC) toggles with 50Hz), you should do that in assembler. To all of you who hope to program an arcade game completely in TP, be warned: TP is just to slow to do the job (try to animate -say- 30 sprites at once)! Me too, I had to discover this (3 years ago) -and came out with a self-written TP-unit, spritedesigner and a lot of integrated assembler stuff (for the animation itself, background-saving, collision detection, scrolling and that things). I am planning to release this package (as shareware) here in FRG very soon, so if you are interested, watch out! S_ROHRBACHER@IRAV1.IRA.UKA.DE (Kai Rohrbacher)