Esempio n. 1
0
void check_execution_abort() {
  if(execution_in_progress) {
    HourGlass();
    short unsigned int key = PRGM_GetKey();
    if(key == KEY_PRGM_ACON) esc_flag = 1;
  }
}
Esempio n. 2
0
void viewTOTPcode(totp* tkn) {
  unsigned short key = 0; int keyCol, keyRow;
  Bdisp_AllClr_VRAM();
  drawScreenTitle(tkn->name);
  int shown_since_beginning = 0;
  while(key != KEY_PRGM_EXIT && key != KEY_PRGM_LEFT) {
    int ThirtySecCode = computeTOTP(tkn);
    char buffer[10];
    itoa_zeropad(tkn->totpcode, buffer, 6);
    long long int ms_spent_ll = currentUTCUEBT() - (long long int)ThirtySecCode * 30LL * 1000LL;
    int ms_spent = (int)(ms_spent_ll);

    drawCircularCountdownIndicator(LCD_WIDTH_PX/2, 104, 44, COLOR_BLACK, COLOR_WHITE,
                                   (ms_spent*43)/30000, getCurrentSecond() < 30 ? 0 : 1);
    // fade in/out animation for text
    int val = 0;
    if(ms_spent >= 29000) {
      val += (-29000 + ms_spent)/4;
    } else if (ms_spent <= 1020) {
      val += (1020 - ms_spent)/4;
    }
    int color = drawRGB24toRGB565(val, val, val);
    printCentered(buffer, 164, color, COLOR_WHITE);
    if(ms_spent < 2500) shown_since_beginning = 1;
    else if(ms_spent < 15000 && shown_since_beginning)
      DefineStatusMessage((char*)totpHelpMessages[(ms_spent-2500)/2500], 1, 0, 0);
    else
      DefineStatusMessage((char*)"", 1, 0, 0);
    DisplayStatusArea();
    Bdisp_PutDisp_DD();
    key = PRGM_GetKey();
    if(key == KEY_PRGM_MENU)
      GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); //this is here to handle the Menu key
    if(key == KEY_PRGM_OPTN) {
      DefineStatusMessage((char*)"", 1, 0, 0);
      GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key); // clear keybuffer
      RTCunadjustedWizard(0, 1);
      setTimezone();
      return; // so we don't have to redraw etc.
      // Also, this way the Shift+Menu instruction shown in the adjustment wizard becomes vali
      // immediately, which is great if the user wants to repeat the adjustment.
    }
  }
  DefineStatusMessage((char*)"", 1, 0, 0);
  // clear keybuffer:
  GetKeyWait_OS(&keyCol, &keyRow, 2, 0, 0, &key);
}
Esempio n. 3
0
void game() {
	/* MAIN LOOP, DO NOT BREAK */
	while (1) {
		/* GETKEY */
		keyupdate();
		// handle [menu]
		if (PRGM_GetKey()==48) {
			GetKey(&key);
		}

		// direction keys
		if (keydownlast(KEY_PRGM_LEFT) && cursor_pos[0]>33) {
			cursor_pos[0] -= cursor_speed;
		} else if (keydownlast(KEY_PRGM_RIGHT) && cursor_pos[0]<LCD_WIDTH_PX-33) {
			cursor_pos[0] += cursor_speed;
		}
		if (keydownlast(KEY_PRGM_UP) && cursor_pos[1]>0) {
			cursor_pos[1] -= cursor_speed;
		} else if (keydownlast(KEY_PRGM_DOWN) && cursor_pos[1]<(LCD_HEIGHT_PX-dash_height-cart_height-man_height-10)) {
			cursor_pos[1] += cursor_speed;
		}

		// control keys
		// shift
		if (keydownlast(KEY_PRGM_SHIFT) && man_is_hanging) {
			// drop man
			man_is_hanging = false;
			man_pos[0] = copter_pos[0];
			man_pos[1] = copter_pos[1]+9;
		}

		/* OPERATIONS */
		// move copter
		if (cursor_pos[0] > copter_pos[0]) {
			copter_pos[0]+=copter_speed;
		} else if (cursor_pos[0] < copter_pos[0]) {
			copter_pos[0]-=copter_speed;
		}

		if (cursor_pos[1] > copter_pos[1]) {
			copter_pos[1]+=copter_speed;
		} else if (cursor_pos[1] < copter_pos[1]) {
			copter_pos[1]-=copter_speed;
		}

		// if man is falling, drop him
		if (!man_is_hanging) {
			man_pos[1] += man_speed;
		}
		// if man is below cart level, check if he is in the cart
		if (!man_is_hanging && man_pos[1]>(LCD_HEIGHT_PX-dash_height-cart_height-5)) {
			if (!man_is_dead && man_pos[0]>cart_pos && man_pos[0]<cart_pos+35) {
				next_try();
			} else {
				die_animation(man_pos[0], man_pos[1]);
			}
		}

		// move cart
		cart_counter = (cart_counter+1) % LCD_WIDTH_PX;
		cart_pos = cart_counter-70;
		// update frame
		cart_frame = (cart_frame+1) % 2;

		/* GRAPHICS */
		// clear screen
		Bdisp_AllClr_VRAM();

		// display functions
		draw_copter(copter_pos[0], copter_pos[1], man_is_hanging);
		draw_cart(cart_pos, LCD_HEIGHT_PX-dash_height-cart_height, cart_frame);

		// if man is falling, draw him
		if (!man_is_hanging /* && !man_is_dead */) {
			draw_man(man_pos[0], man_pos[1]);
		}

		// draw dash
		draw_dash();

		// draw cursor on top of everything
		draw_cursor(cursor_pos[0], cursor_pos[1]);
		
		// copy VRAM to screen
		Bdisp_PutDisp_DD();
	}
}
Esempio n. 4
0
void I_StartTic (void)
{
    static event_t event = {(evtype_t)0,0,0,0};
    static int iOldKey = 0;
    int iKey = PRGM_GetKey();
    int iFilter = 1;
    switch(iKey)
    {
    case KEY_PRGM_POWER:CGCheat();break;
    case 32:R_SetViewSizeChange(-1);break;
    case 42:R_SetViewSizeChange(1);break;
    case 25:CGSwitchClip();break;
    case 65:CGFreeMem();break;
    case 58:CGRefreshSwitch();break;
        break;

    default:iFilter = 0;
    }
    if(iFilter)
    {
        while(PRGM_GetKey());
        return;
    }
    if(iKey == iOldKey)
    {
        return;
    }
    if(iOldKey)
    {
        event.type= ev_keyup;
        D_PostEvent(&event);
    }
    iOldKey = iKey;
    if(!iKey)
    {
        return;
    }
    event.type= ev_keydown;
    switch(iKey)
    {
    case KEY_PRGM_LEFT:event.data1 = KEY_LEFTARROW;break;
    case KEY_PRGM_RIGHT:event.data1 = KEY_RIGHTARROW;break;
    case KEY_PRGM_UP:event.data1 = KEY_UPARROW;break;
    case KEY_PRGM_DOWN:event.data1 = KEY_DOWNARROW;break;
    case KEY_PRGM_RETURN:event.data1 = ' ';break;
    case KEY_PRGM_ALPHA:event.data1 = KEY_RCTRL;break;
    case KEY_PRGM_MENU:I_Quit();break;
    case KEY_PRGM_F1:event.data1 = '1';break;
    case KEY_PRGM_F2:event.data1 = '2';break;
    case KEY_PRGM_F3:event.data1 = '3';break;
    case KEY_PRGM_F4:event.data1 = '4';break;
    case KEY_PRGM_F5:event.data1 = '5';break;
    case KEY_PRGM_F6:event.data1 = '6';break;
    case KEY_PRGM_SHIFT:event.data1 = '7';break;
    case KEY_PRGM_EXIT:event.data1 = KEY_TAB;break;
    case KEY_PRGM_OPTN:event.data1 = KEY_PAUSE;break;
    case 61:event.data1 = KEY_SRIGHTARROW;break;
    case 71:event.data1 = KEY_SLEFTARROW;break;
    default:return;
    }
    D_PostEvent(&event);
}