Advertisement
cr1901

VB Timer Fun

Sep 19th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.67 KB | None | 0 0
  1. void timer_handler()
  2. {
  3.     //if(precise_timer_on)
  4.     //{
  5.     precise_timer_int_cnt++;
  6.     //}
  7.    
  8.     /* Run one frame of sound driver here. */
  9.    
  10.     /* VB manual recommends this. */
  11.     HW_REGS[TCR] &= ~TIMER_INT;
  12.     HW_REGS[TCR] |= TIMER_ZCLR;
  13.     HW_REGS[TCR] |= TIMER_INT;
  14. }
  15.  
  16. void init_timer_hw()
  17. {
  18.     /* Timer interrupt will fire once every 10ms. */
  19.     HW_REGS[TLR] = 0;
  20.     HW_REGS[TLR] = TIME_MS(10);
  21.     HW_REGS[TCR] =  TIMER_100US | TIMER_INT | TIMER_ENB;
  22. }
  23.  
  24. //In another file...
  25.  
  26. extern unsigned char precise_timer_int_cnt;
  27. void fade_and_wait()
  28. {
  29.     vbFXFadeIn(3);
  30.     while(!vbPadKeyDown())
  31.     {
  32.         (* (short *)(BGMap(0) + 27)) = (short) precise_timer_int_cnt;
  33.     }
  34.     vbFXFadeOut(3);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement