示例#1
0
 private void initTimer() {
   TriggerAction div_ta =
       new TriggerAction() {
         @Override
         public void execute() {
           div += 1;
         }
       };
   IntervalTrigger div_t = new IntervalTrigger(GBInterval.ticksFromHz(16384), div_ta);
   clock.register(T_DIV, div_t);
 }
示例#2
0
  private void setTimer() {
    boolean timerOn = (tac & 0x04) != 0;

    if (!timerOn) {
      IntervalTrigger removedTimer = (IntervalTrigger) clock.unregister(T_TIMA);
      // Initially there will be no registered timer
      if (removedTimer != null) removedTimer.reset();
    } else
      switch (tac & 0x3) {
        case 0:
          clock.register(T_TIMA, T_00);
          break;
        case 1:
          clock.register(T_TIMA, T_01);
          break;
        case 2:
          clock.register(T_TIMA, T_02);
          break;
        case 3:
          clock.register(T_TIMA, T_03);
          break;
      }
  }