640x480x16 screen painting

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Ramanan

640x480x16 screen painting

Post by Ramanan »

Hi all,

I'm using "Mode 12h" display, ie. screen 640x480 pixels with 16 colors.
My problem is, how to paint the entire display in a flash ?

When i draw a bitmap on to the display memory, each and every
plotting of pixel is obvious to the user. How can i eliminate this?
i can't use page flipping B coz Mode 12h has only 1 page left.

Can i use virtual display to plot entire screen first and then copy it to the
display memory at one shot during vertical retrace? i never tried this technic and
I don't think it will be fast enough to do in a single vertical retrace.
so i think it will be a bad idea (its my opinion and i am not sure of it :| ).
What about ur suggestions?

I just want to display the screen as like ms-windows displays in safe mode.
I welcome any idea, code sample and suggestions.

Thanks

YogaRamanan.T
carbonBased

RE:640x480x16 screen painting

Post by carbonBased »

In a mode such as this, you're probably going to want to have an off-screen buffer setup in planes (instead of the whole thing in one buffer, setup a separate buffer for each plane (ie, in mode 0x12, you'll have 4 planes)).

Then, use the VGA ports to wait for the vertical retrace, select the first plane, and copy the whole thing to video memory, dwords at a time.  Select the next plane, and copy the next buffer, and so on, until you've copied each plane.

This will probably give you the fastest frame rate you can get (and yes, you can do it withen the timespan of a vertical retrace).

Cheers,
Jeff
Ramanan

RE:640x480x16 screen painting

Post by Ramanan »

Hi,
Thanks for ur idea. It seems good idea but when i paint the whole screen user can c a flicker with a image drawing from top to bottom. Any way its very difficult to notice b coz of its quickness.

I have to use "rep movsw" 5 times to paint entire screen. First "REP" to set entire scr to black then other 4 to fill 4 scr panes. I think it takes mo than 1 refresh cycle (may b 2 or 2.5 cycles).

I wonder how ms-windows do this ....:| they r filling the background pic in a flash.  Is there any other way?

Thanks,
YogaRamanan.T
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

RE:640x480x16 screen painting

Post by df »

using rep movsd instead of movsw and doing directlyu after a vertical retrace wait, user should not see a screen update/flicker, as CB pointed out to you.
-- Stu --
carbonBased

RE:640x480x16 screen painting

Post by carbonBased »

Why do you set the entire screen to black?  This will 'cause loads of flicker, no doubt... as a general rule, never blank/black the screen, and then draw your image.  Simply overwrite the previous image.

Think of it this way; you say it's difficult to see that flicker... that means that you are, in fact, copying about twice the screen data you expected withen a single vertical refresh (and you're even doing so with words, not dwords).  You've set the entire screen to black, and then you've gone and set it again to another display/image... that occasional flicker is visible when part of the black is still visible on the vertical retrace.

The absolute best way for performance (usually) includes only one blit to the screen (per plane) at a time (using dwords! rep movsd), and this can definitly be done in a 60th of a second.

If you _have to_ black out the screen, do it in the virtual screen buffer, not the actual screen (but you should rarely ever have to do this) and then draw your 4 planes.

Cheers,
Jeff
Post Reply