Using vsync() gives a smooth scrolling, but with a timer, things are not good. I set up a volatile int frame_counter to be incremented 3606 times per minute (or 3600 if exactly 60hz). On screen refresh (bitmap blitting), I check the state of frame_counter in a while(0 == frame_counter) loop, waiting for a tick. Then, the blit occurs and the frame_counter=0. I suspect this is the error, but any help on it? As I said, the scrolling seems to gasp.
Code:
//the following is a sketch only
volatile int frame_counter=0;
void gfx_timer_clock(void)
{
frame_counter++;
}
END_OF_FUNCTION(gfx_timer_clock) //however, this statement doesn't seem to be REALLY necessary.
void blit_to_screen(BITMAP *bmp)
{
blit(bmp,screen, ... ); //parameters don't matter.
while(0 == frame_counter) {
Sleep(0); //it doesn't impact in the timer as you would might imagine...
}
frame_counter = 0;
//using an old_frame_counter to compare with frame_counter gives the exact same bad effect.
//it just don't reset the counter.
}
void gfx_timer_init(void)
{
install_timer();
LOCK_FUNCTION(gfx_timer_clock);
LOCK_VARIABLE(frame_counter);
install_int_ex(gfx_timer_clock,BPM_TO_TIMER(3606));
}
volatile int frame_counter=0;
void gfx_timer_clock(void)
{
frame_counter++;
}
END_OF_FUNCTION(gfx_timer_clock) //however, this statement doesn't seem to be REALLY necessary.
void blit_to_screen(BITMAP *bmp)
{
blit(bmp,screen, ... ); //parameters don't matter.
while(0 == frame_counter) {
Sleep(0); //it doesn't impact in the timer as you would might imagine...
}
frame_counter = 0;
//using an old_frame_counter to compare with frame_counter gives the exact same bad effect.
//it just don't reset the counter.
}
void gfx_timer_init(void)
{
install_timer();
LOCK_FUNCTION(gfx_timer_clock);
LOCK_VARIABLE(frame_counter);
install_int_ex(gfx_timer_clock,BPM_TO_TIMER(3606));
}