/** Send personality info packet to controller via serial port (layer 3). * * This gives the controller the opportunity to find out the kind of * device we are and how to interpret our data table packets. */ void send_personality_info(void) { frame_start(FRAME_TYPE_PERSONALITY_INFO, sizeof(personality_info) + personality_name_length); uart_putb_P((const void *)&personality_info, sizeof(personality_info)); uart_putb_P((const void *)personality_name, personality_name_length); frame_end(); }
void send_eeprom_params_in_sram(void) { const uint8_t length = pparam_sram.length; if (length == 0xff || length > sizeof(pparam_sram.params)) { send_text_P(PSTR_INVALID_EEPROM_DATA); } else { frame_start(FRAME_TYPE_PARAMS_FROM_EEPROM, length); uart_putb((const void *)pparam_sram.params, length); frame_end(); } }
void game_frame(RussiaBlock * rb, Mtime time) { frame_start(rb); clock_block_fall(rb, time); response_event(rb); solidify_block(rb, time); frame_end(rb); }
void menu_loop(struct Menu *menu) { int ret; while (1) { frame_start(); menu_draw(menu); ret = menu_ctrl(menu); if(ret != 0) break; g_frame_count++; frame_end(); } }
/** Send value table packet to controller via serial port (layer 3). * * \param reason The reason why we are sending the value table * (#packet_value_table_reason_t). * * Note that send_table() might take a significant amount of time. * For example, at 9600bps, transmitting a good 3KByte will take a * good 3 seconds. If you disable interrupts for that time and want * to continue the measurement later, you will want to properly pause * the timer. We are currently keeping interrupts enabled if we * continue measuring, which avoids this issue. * * Note that for 'I' value tables it is possible that we send fluked * values due to overflows. */ void send_table(const packet_value_table_reason_t reason) { const uint16_t duration = get_duration(); packet_value_table_header_t header = { data_table_info.bits_per_value, reason, data_table_info.type, duration, pparam_sram.length }; frame_start(FRAME_TYPE_VALUE_TABLE, sizeof(header) + pparam_sram.length + data_table_info.size); uart_putb((const void *)&header, sizeof(header)); uart_putb((const void *)pparam_sram.params, pparam_sram.length); uart_putb((const void *)data_table, data_table_info.size); frame_end(); }
/************************************************ Render the currently selected item list to screen ************************************************/ void screen_display(context_t * ctx) { SDL_Event event; int i; for(i=0; i<SCREEN_LAST; i++) { virtual_x[i] = INT_MAX; virtual_y[i] = INT_MAX; virtual_z[i] = -1.0; } while( screen_end == -1) { frame_start(ctx); if(compose) { compose = 0; compose_scr(ctx); } display_fps(); while (SDL_PollEvent(&event)) { compose |= sdl_screen_manager(ctx->window, ctx->render, &event); sdl_mouse_manager(ctx->render,&event,item_list); sdl_keyboard_manager(&event); } sdl_mouse_position_manager(ctx->render,item_list); SDL_RenderClear(ctx->render); sdl_blit_item_list(ctx->render,item_list); sdl_blit_to_screen(ctx->render); sdl_loop_manager(); } return; }
int main() { if(chdir(PKGDATADIR) != 0) { printf("data directory %s not found.", PKGDATADIR); } init(); init_camera(); init_board(&board); init_striker(&striker); init_chips(); init_orientation(&striker); init_instructions(); init_speed_text(); init_main_menu(); init_scores(); init_game_over_state(); move_to_main_menu(); while(!quit) { frame_start(); while(!quit && accumulator >= elapsed_time) { handle_events(); update(); render(); accumulator -= elapsed_time; } } close(); }