C++ help

hello all

im new to the world of C++ and among the many questions i have, there is one that really bugs me. When i have larger loops(mostly do loops with alot of functions) and im constantly printing out to the screen, i use the system("cls") function but it leaves a flicker that gets pretty annoying. my professor said that there is a way to go in between frames(he says that there ate 8 total) but i was just wondering how this would be done.

any advice would be greatly appreciated.


  • It's surprisingly hard to get frame synchs.

    Firstly there are no such functions in the standard library, which isn't surprising as it's designed as far as possible to be hardware agnostic.

    Ideally you'd just call a fucntion waitforverticalblank(). That's how it ought to work. In practise such a function is almost never provided. You've got to do things like setting up an interrupt function to intercept the blank. This is nowhere near as complicated as it sounds. Vertical blank will cause the processor to stop what it is doing and run to a routine at an address given by a table. You overwrite the table with your interrupt function, do your stuff, and then call the old routine. A skeleton is

    volatile int flag;

    void (*oldinterrupt)(void);

    void vbinterrupt(void)
    flag = 1;
    /* now do everything else we need to service the interrupt */

    void waitforverticalblank(void)
    while(flag == 0) {};
    flag = 0;

    The principle isn't hard. It's getting the details of how your system is set up that can be difficult.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion