×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Screen Refresh/ Display

Screen Refresh/ Display

Screen Refresh/ Display

(OP)


  I am still a newbie to assembly. I try
to display a box in the screen and move it. I draw it pixel by pixel. It moves.  Logic works ok but it flickers.
How I can refresh the picture accordingly? (to keep up with the refresh rate of monitor) I thought of creating two pages and drawing picture in the back page after it's drawn, flip the page. It doesnt work . Some distorted graphics appear. What is the best way of displaying a moving box ? (in video mode 13) And I don't use direct video access. If I'd know...

Thanks in advance

RE: Screen Refresh/ Display

The easiest way is to use 320x200x256 mode where you can directly put data to video area of system memory. If you do so, many problems perish.

RE: Screen Refresh/ Display

The flicker is probably caused by not using direct video access.  If you're doing BIOS access (omg!) it'll be ridiculously slow even on later processors.

Also, drawing pixel by pixel is not recommended for any 16-color video mode, especially for horizontal lines since you can draw up to 8 pixels at a time in a horizontal line.  For a 256-color mode, mode X can be used to draw up to 4 pixels at a time but of course that's advanced.

What is more if you're using the 320x200x256 mode (13h, is that 'mode 13' a 13decimal or 13hex??) IIRC you can only have one page, if you try to use two the two pages will overlap.  To improve performance, use direct video access and if possible use mode X.

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

RE: Screen Refresh/ Display

Wow, you're getting yourself into a lovely interesting area. I can think of no better introduction to PC graphics than Abrash's big black book, which is probably still available in paper form, and can be downloaded (or used to be downloadable) from various places.
You are in the right forum for this, since graphics stuff the way you want to do it inevitably requires assembler. I agree with AmkG entirely about the pixel-drawing interrupt in BIOS. It is universal to all modes (wow!) but unbelievably slow.
The last time I drew a box on screen (using 16 colour 640*480 graphics) I first did fast horizontal and vertical line drawers, and used these. I wanted to alternate pixel colour to make a dithered colour effect, which was why I was doing it myself.

There are several quite separate reasons for not drawing pixel by pixel.
(1) to avoid the bios interrupt. But if you write your own single-pixel drawer, you'll find it is still quicker than bios.
(2) because in a 16 colour mode you can draw 8 horizontal pixels together, which saves time on the horizontal lines of your box. Note that there's no such benefit for the verticals!! The code will be much messier than single-pixel code, because you have to handle the ends of the line specially, where less than 8 pixels need drawing. Remember a very small box might have its left and right edges in the same byte, which gets even messier. But this is worth dealing with, because video ram is very slow, so repeated moves to video are frowned on.
(3) because drawing a single dot requires setting up registers in the VGA card, using in and out instructions. These are hideously, dreadfully slow compared to "normal" assembler. Very often you will be setting them to the same values for a succession of pixels, so a line drawer that sets them once, and leaves them, will be more efficient than a pixel drawer called repeatedly. This is a BIG gain, so it's worth doing. In my dithered example I could set a bit-mask in the VGA just once for the entire vertical line, saving potentially hundreds of "out"s.
(4) because doing a call and rts is also time consuming, especially if associated with instructions to maintain a stack-frame and preserve registers. But this is small compared to outs.

The only sad thing about all this is that less and less people are interested or know anything, because simple things like box drawing are provided ready-made by any respectable language or graphic user interface.

hope that helps. Get Abrash's book!
Lionel

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close