C and C++

Moderators: None (Apply to moderate this forum)
Number of threads: 28691
Number of posts: 94711

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
C++ help Posted by Dsquared on 7 May 2009 at 3:59 PM
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.

Report
Re: C++ help Posted by Malcolm_McLean on 9 May 2009 at 6:28 AM
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 */
  (*oldinterrupt)();
}

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.




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.