1 / 12

Vertical Retrace Interval

Vertical Retrace Interval. An introduction to VGA techniques for smooth graphics animation. 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). . Image “persistence”.

bernad
Download Presentation

Vertical Retrace Interval

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 • Erase the previous screen • Draw a new screen-image • Get ready to draw another screen • But wait for a vertical retrace to begin • 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

More Related