Presentation is loading. Please wait.

Presentation is loading. Please wait.

Vertical Retrace Interval An introduction to VGA techniques for smooth graphics animation.

Similar presentations


Presentation on theme: "Vertical Retrace Interval An introduction to VGA techniques for smooth graphics animation."— Presentation transcript:

1 Vertical Retrace Interval An introduction to VGA techniques for smooth graphics animation

2 The CRT Display Screen’s image consists of horizontal scanlines, drawn in top-down order, and redrawn about 60-70 times per second (depending on display mode).

3 Image “persistence” The impression of a steady screen image is purely a mental illusion of the viewer’s The pixels are drawn on the CRT screen too rapidly for the human eye to follow And the screen phosphor degrades slowly So the brain blends a rapid succession of discrete images into a continuous motion So-called ‘motion pictures’ are based on these phenomena, too (30 frames/second)

4 Color “dithering” The mind’s tendency to “blend” together distinct images that appear near to one another in time can be demonstrated by using two different colors -- alternately displayed in very rapid succession This is called “dithering” Some early graphics applications actually used this technique, to show extra colors

5 Timing mechanism Today’s computers can “redraw” screens much faster than a CRT can display them We need to “slow down” the redrawing so that the CRT circuitry will be able keep up Design of VGA hardware allows programs to “synchronize” drawing with CRT refresh Use the “INPUT STATUS REGISTER 1” accessible (read-only) at I/O port 0x3DA

6 Input Status Register One 7 6 5 4 3 2 1 0 Vertical Retrace status 1 = retrace is active 0 = retrace inactive Display Enabled status 1 = VGA is reading (and displaying) VRAM 0 = Horizontal or Vertical Retrace is active I/O port-address: 0x3DA (color display) or 0x3BA (monochrome display)

7 void vsync( void ) { // wait for current retrace to finish while ( ( inb( 0x3DA ) & 8 ) != 8 ); // wait until the next retrace begins while ( ( inb( 0x3DA ) & 8 ) == 8 ); } // This function only returns at the very beginning // of a new vertical blanking interval, to maximize // the time for drawing while the screen is blanked

8 Animation algorithm 1)Erase the previous screen 2)Draw a new screen-image 3)Get ready to draw another screen 4)But wait for a vertical retrace to begin 5)Then go back to step 1.

9 How much drawing time? Screen-refresh occurs 60 times/second So time between refreshes is 1/60 second Vertical blanking takes about 15% of time So “safe” drawing-time for screen-update is about: (1/60)*(15/100) = 1/400 second What if a screen-update takes longer? Animation will exhibit “tearing” of images

10 Programming techniques Your application may not require that the full screen be redrawn for every frame Maybe only a small region changes, so time to “erase-and-redraw” it is reduced You may be able to speed up the drawing operations, by “optimizing” your code Using assembly language can often help

11 Using off-screen VRAM You can also draw to off-screen memory, which won’t affect what’s seen on-screen When your ‘off-screen’ image is finished, you can quickly copy it to the on-screen memory area (called a ‘BitBlit’ operation) Both CPU and SVGA provide support for very rapid copying of large memory areas

12 Our ‘animate1.cpp’ demo We can demonstrate smooth animation with a “proof-of-concept” prototype It’s based on the classic “pong” game A moving ball bounces against a wall The user is able to move a “paddle” by using an input-device (such as a mouse, keyboard, or joystick) We didn’t implement user-interaction yet


Download ppt "Vertical Retrace Interval An introduction to VGA techniques for smooth graphics animation."

Similar presentations


Ads by Google