void game_over(uint8_t i) { if (game.mode == 2 || game.mode == 3) { connect_put(CONN_GAMEOVER); connect_put(i); if (connect_get() != CONN_READY) { game_connFailed(); return; } } sound_freq(SOUND_FAILED); game_record(i); RECTANGLE(GAME_OVER); tft_setZoom(2); STRING(GAME_OVER_STR); tft_setXY(GAME_OVER_LOST_X, GAME_OVER_LOST_Y); tft_setColour(GAME_OVER_LOST_FGC, GAME_OVER_LOST_BGC); tft_print_string("Player"); tft_print_uint16(i + 1); tft_print_string(" LOST"); tft_setXY(GAME_OVER_HIGH_X, GAME_OVER_HIGH_Y); tft_setColour(GAME_OVER_HIGH_FGC, GAME_OVER_HIGH_BGC); tft_print_uint16(eeprom_read_word(&NVScore[0])); tft_print_string("/"); tft_print_uint16(eeprom_read_word(&NVScore[1])); tft_setXY(GAME_OVER_REC_X, GAME_OVER_REC_Y); tft_setColour(GAME_OVER_REC_FGC, GAME_OVER_REC_BGC); tft_print_uint16(eeprom_read_word(&NVOverCnt[0])); tft_print_string("/"); tft_print_uint16(eeprom_read_word(&NVOverCnt[1])); STRING(GAME_OVER_CLN); get: switch (ROE_get()) { case ROE_SW2: case ROE_SW1: game_record(2); sound_freq(SOUND_CONF); break; case ROE_N: goto get; } sound_freq(SOUND_CANCEL); while (ROE_get() != ROE_N); }
bool rtouch_calibrate(void) //void * data ) { //int * state = (int *) data; rtouch_event_t event; bool in_progress = true; static int state = 0; static rtouch_event_handler_t oldHandler; switch (state) { case 0: //TFT_SetClipping( 0, 0, TFT_GetWidth(), TFT_GetHeight() ); //TFT_color_t MEM_RAMTYPE * pixmap; //pixmap = MEM_ALLOC_ARRAY( TFT_color_t, (240UL * 320UL) ); tft_print_string( 10, 10, "Touch screen calibration...", RTOUCH_COLOR); points.point1.panelX = 30; points.point1.panelY = 30; points.point2.panelX = 170; points.point2.panelY = 220; points.point3.panelX = 300; points.point3.panelY = 120; tft_draw_filled_circle( points.point1.panelX, points.point1.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); state = 1; oldHandler = rtouch_get_event_handler(); rtouch_set_event_handler( calibratehandler ); break; case 1: if (rtouch_is_touched() == false) { break; } tft_draw_filled_circle( points.point1.panelX, points.point1.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); rtouch_get_event(&event); points.point1.rawX = event.rawX; points.point1.rawY = event.rawY; state = 2; break; case 2: if (rtouch_is_touched() == true) { break; } tft_draw_filled_circle( points.point2.panelX, points.point2.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); state = 3; break; case 3: if (rtouch_is_touched() == false) { break; } tft_draw_filled_circle( points.point2.panelX, points.point2.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); rtouch_get_event(&event); points.point2.rawX = event.rawX; points.point2.rawY = event.rawY; state = 4; break; case 4: if (rtouch_is_touched() == true) { break; } tft_draw_filled_circle( points.point3.panelX, points.point3.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); state = 5; break; case 5: if (rtouch_is_touched() == false) { break; } tft_draw_filled_circle( points.point3.panelX, points.point3.panelY, 2, RTOUCH_COLOR, TFT_WHOLE ); rtouch_get_event(&event); points.point3.rawX = event.rawX; points.point3.rawY = event.rawY; state = 6; break; case 6: if (rtouch_is_touched() == true) { break; } rtouch_compute_calibration_matrix(&points, &matrix); rtouch_set_calibration_matrix(&matrix); state = 7; rtouch_set_event_handler(oldHandler); in_progress = false; state = 0; // TODO redraw the background if needed break; default: break; } return in_progress; }