/** * \param procedure procedure ID * \param data unpacked message data * \param len data length * * Creates SysEx message then sends it. This function uses folowing global variables: device_id, family_id and product_id. **/ void send_message(gint procedure, gchar *data, gint len) { GString *msg = g_string_new_len("\xF0" /* SysEx status byte */ "\x00\x00\x10", /* Manufacturer ID */ 4); g_string_append_printf(msg, "%c%c%c" /* device, family, product ID */ "%c", /* procedure */ device_id, family_id, product_id, procedure); if (len > 0) { GString *tmp = pack_data(data, len); g_string_append_len(msg, tmp->str, tmp->len); g_string_free(tmp, TRUE); } g_string_append_printf(msg, "%c\xF7", calculate_checksum(&msg->str[1], msg->len - 1)); debug_msg(DEBUG_VERBOSE, "Sending %s len %d", get_message_name(procedure), len); send_data(msg->str, msg->len); g_string_free(msg, TRUE); }
// continue experiment static void experiment_cont(void* arg) { errval_t err; static bool flag = false; static int message_type = 0; // Experiment finished (with this message type) if (i == MAX_COUNT - 1) { #if CONFIG_TRACE #else // print measured times for (int j = MAX_COUNT / 10; j < MAX_COUNT; j++) { printf( "page %d took %"PRIuCYCLES"\n", j, timestamps[j].time1 - bench_tscoverhead() - timestamps[j].time0); } #endif // go to next message type message_type++; flag = false; i = 0; if (message_type > 13) { // stop tracing err = trace_event(TRACE_SUBSYS_MULTIHOP, TRACE_EVENT_MULTIHOP_BENCH_STOP, 0); if (err_is_fail(err)) { USER_PANIC_ERR(err, "trace_event failed"); } #if CONFIG_TRACE // dump trace char *buf = malloc(50*4096*4096); size_t length = trace_dump(buf, 20*4096*4096, NULL); printf("%s\n", buf); printf("length of buffer %lu\n", length); #endif printf("client done!\n"); return; } } if (!flag) { // Start experiment #if CONFIG_TRACE #else printf("Running latency test for message %s...\n", get_message_name(message_type)); #endif flag = true; timestamps[i].time0 = bench_tsc(); } else { // Continue experiment i++; timestamps[i].time0 = bench_tsc(); } // trace send event err = trace_event(TRACE_SUBSYS_MULTIHOP, TRACE_EVENT_MULTIHOP_MESSAGE_SEND, message_type); if (err_is_fail(err)) { USER_PANIC_ERR(err, "trace_event failed"); } // send next message switch (message_type) { case 0: err = binding->tx_vtbl.fsb_empty_request(binding, NOP_CONT); break; case 1: err = binding->tx_vtbl.fsb_payload32_1_request(binding, NOP_CONT, 1); break; case 2: err = binding->tx_vtbl.fsb_payload32_2_request(binding, NOP_CONT, 1, 2); break; case 3: err = binding->tx_vtbl.fsb_payload32_4_request(binding, NOP_CONT, 1, 2, 3, 4); break; case 4: err = binding->tx_vtbl.fsb_payload32_8_request(binding, NOP_CONT, 1, 2, 3, 4, 5, 6, 7, 8); break; case 5: err = binding->tx_vtbl.fsb_payload32_16_request(binding, NOP_CONT, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); break; case 6: err = binding->tx_vtbl.fsb_payload64_1_request(binding, NOP_CONT, 1); break; case 7: err = binding->tx_vtbl.fsb_payload64_2_request(binding, NOP_CONT, 1, 2); break; case 8: err = binding->tx_vtbl.fsb_payload64_4_request(binding, NOP_CONT, 1, 2, 3, 4); break; case 9: err = binding->tx_vtbl.fsb_payload64_8_request(binding, NOP_CONT, 1, 2, 3, 4, 5, 6, 7, 8); break; case 10: err = binding->tx_vtbl.fsb_payload64_16_request(binding, NOP_CONT, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16); break; case 11: err = binding->tx_vtbl.fsb_buffer_request(binding, NOP_CONT, &buffer, 1); break; case 12: err = binding->tx_vtbl.fsb_buffer_request(binding, NOP_CONT, buffer2, 100); break; case 13: err = binding->tx_vtbl.fsb_buffer_request(binding, NOP_CONT, buffer3, 1000); break; default: printf("unknown message type\n"); abort(); break; } // make sure send was successful if (err_is_fail(err)) { USER_PANIC_ERR(err, "while running experiment\n"); } // receive reply (by dispatching events from the // waitset we use for the benchmark) while (reply_received == false) { event_dispatch(&signal_waitset); } experiment(); }
void push_message(GString *msg) { MessageID msgid = get_message_id(msg); if (((unsigned char)msg->str[0] == 0xF0) && ((unsigned char)msg->str[msg->len-1] == 0xF7)) { debug_msg(DEBUG_VERBOSE, "Pushing correct message!"); } else { g_warning("Pushing incorrect message!"); } int x; if (debug_flag_is_set(DEBUG_HEX)) { for (x = 0; x<msg->len; x++) { if (x && (x % HEX_WIDTH) == 0) { printf("\n"); } printf("%02x ", (unsigned char)msg->str[x]); } if (x % HEX_WIDTH) { printf("\n"); } } debug_msg(DEBUG_VERBOSE, "Received %s", get_message_name(msgid)); SettingParam *param; switch (msgid) { case ACK: g_string_free(msg, TRUE); return; case NACK: g_warning("Received NACK!"); g_string_free(msg, TRUE); return; case RECEIVE_PARAMETER_VALUE: { unpack_message(msg); param = setting_param_new_from_data(&msg->str[8], NULL); if (debug_flag_is_set(DEBUG_MSG2HOST)) { GString *ipv = format_ipv(param->id, param->position, param->value); debug_msg(DEBUG_MSG2HOST, "RECEIVE_PARAMETER_VALUE\n%s", ipv->str); g_string_free(ipv, TRUE); } GDK_THREADS_ENTER(); apply_setting_param_to_gui(param); GDK_THREADS_LEAVE(); setting_param_free(param); g_string_free(msg, TRUE); return; } case RECEIVE_DEVICE_NOTIFICATION: unpack_message(msg); unsigned char *str = (unsigned char*)msg->str; switch (str[8]) { case NOTIFY_PRESET_MOVED: if (str[11] == PRESETS_EDIT_BUFFER && str[12] == 0) { GDK_THREADS_ENTER(); g_timeout_add(0, apply_current_preset_to_gui, NULL); GDK_THREADS_LEAVE(); debug_msg(DEBUG_MSG2HOST, "RECEIVE_DEVICE_NOTIFICATION: Loaded preset " "%d from bank %d", str[10], str[9]); } else { debug_msg(DEBUG_MSG2HOST, "RECEIVE_DEVICE_NOTIFICATION: %d %d moved to " "%d %d", str[9], str[10], str[11], str[12]); } break; case NOTIFY_MODIFIER_GROUP_CHANGED: { int i; if (debug_flag_is_set(DEBUG_HEX)) { printf("\n"); for (i = 0; i < msg->len; i++) { printf(" %02x", (unsigned char) str[i]); } printf("\n"); } debug_msg(DEBUG_MSG2HOST, "NOTIFY_MODIFIER_GROUP_CHANGED: Modifier group " "id %d changed", (str[9] << 8) | (str[10])); if (!modifier_linkable_list_request_pending) { send_message(REQUEST_MODIFIER_LINKABLE_LIST, "\x00\x01", 2); modifier_linkable_list_request_pending = TRUE; } break; } default: g_warning("Received unhandled device notification 0x%x", str[11]); } g_string_free(msg, TRUE); return; case RECEIVE_GLOBAL_PARAMETERS: unpack_message(msg); gint tot, n, x; tot = (unsigned char)msg->str[9]; if (debug_flag_is_set(DEBUG_HEX)) { for (n = 0; n < msg->len; n++) { printf("%02x ",(unsigned char) msg->str[n]); } printf("\n"); } n = 0; x = 10; do { param = setting_param_new_from_data(&msg->str[x], &x); debug_msg(DEBUG_MSG2HOST, "RECEIVE_GLOBAL_PARAMETERS ID: %5d " "Position: %2.1d Value: %6.1d: %s", param->id, param->position, param->value, "XXX"); GDK_THREADS_ENTER(); apply_setting_param_to_gui(param); GDK_THREADS_LEAVE(); setting_param_free(param); } while ( (x < msg->len) && n < tot); g_string_free(msg, TRUE); return; case RECEIVE_MODIFIER_LINKABLE_LIST: modifier_linkable_list_request_pending = FALSE; unpack_message(msg); tot = (unsigned char)msg->str[9]; if (debug_flag_is_set(DEBUG_HEX)) { for (n = 0; n < msg->len; n++) { printf("%02x ",(unsigned char) msg->str[n]); } printf("\n"); } update_modifier_linkable_list(msg); g_string_free(msg, TRUE); GDK_THREADS_ENTER(); create_modifier_group(EXP_POSITION, EXP_ASSIGN1); create_modifier_group(LFO1_POSITION, LFO_TYPE); create_modifier_group(LFO2_POSITION, LFO_TYPE); GDK_THREADS_LEAVE(); return; default: g_mutex_lock(message_queue_mutex); g_queue_push_tail(message_queue, msg); g_cond_signal(message_queue_cond); g_mutex_unlock(message_queue_mutex); break; } }
// Process a character for the briefing, // including special characters preceded by a '$'. // Return 1 when page is finished, 0 otherwise static int briefing_process_char(grs_canvas &canvas, briefing *const br) { auto &game_font = *GAME_FONT; char ch = *br->message++; if (ch == '$') { ch = *br->message++; #if defined(DXX_BUILD_DESCENT_II) if (ch=='D') { br->cur_screen = DefineBriefingBox(canvas.cv_bitmap, br->message); br->screen.reset(&Briefing_screens[br->cur_screen]); init_char_pos(br, br->screen->text_ulx, br->screen->text_uly); br->line_adjustment=0; br->prev_ch = 10; // read to eoln } else if (ch=='U') { br->cur_screen = get_message_num(br->message); br->screen.reset(&Briefing_screens[br->cur_screen]); init_char_pos(br, br->screen->text_ulx, br->screen->text_uly); br->prev_ch = 10; // read to eoln } else #endif if (ch == 'C') { auto cc = get_message_num(br->message) - 1; if (cc < 0) cc = 0; else if (cc > Briefing_text_colors.size() - 1) cc = Briefing_text_colors.size() - 1; Current_color = &Briefing_text_colors[cc]; br->prev_ch = 10; } else if (ch == 'F') { // toggle flashing cursor br->flashing_cursor = !br->flashing_cursor; br->prev_ch = 10; while (*br->message++ != 10) ; } else if (ch == 'T') { br->tab_stop = get_message_num(br->message); br->prev_ch = 10; // read to eoln } else if (ch == 'R') { br->robot_canv.reset(); #if defined(DXX_BUILD_DESCENT_II) if (br->robot_playing) { DeInitRobotMovie(br->pMovie); br->robot_playing=0; } #endif if (EMULATING_D1) { init_spinning_robot(canvas, *br); br->robot_num = get_message_num(br->message); #if defined(DXX_BUILD_DESCENT_II) while (*br->message++ != 10) ; #endif } else { #if defined(DXX_BUILD_DESCENT_II) char spinRobotName[]="RBA.MVE", kludge; // matt don't change this! kludge=*br->message++; spinRobotName[2]=kludge; // ugly but proud br->robot_playing=InitRobotMovie(spinRobotName, br->pMovie); // gr_remap_bitmap_good( &grd_curcanv->cv_bitmap, pal, -1, -1 ); if (br->robot_playing) { RotateRobot(br->pMovie); set_briefing_fontcolor(*br); } #endif } br->prev_ch = 10; // read to eoln } else if ((ch == 'N' && (br->animating_bitmap_type = 0, true)) || (ch == 'O' && (br->animating_bitmap_type = 1, true))) { br->robot_canv.reset(); br->prev_ch = 10; get_message_name(br->message, br->bitmap_name, "#0"); } else if (ch=='A') { #if defined(DXX_BUILD_DESCENT_II) br->line_adjustment=1-br->line_adjustment; #endif } else if (ch=='Z') { #if defined(DXX_BUILD_DESCENT_II) char fname[15]; int i; br->got_z=1; br->dumb_adjust=1; i=0; while ((fname[i]=*br->message) != '\n') { i++; br->message++; } fname[i]=0; if (*br->message != 10) while (*br->message++ != 10) // Get and drop eoln ; { char fname2[15]; i=0; while (fname[i]!='.') { fname2[i] = fname[i]; i++; } fname2[i++]='b'; fname2[i++]='.'; fname2[i++]='p'; fname2[i++]='c'; fname2[i++]='x'; fname2[i++]=0; if ((HIRESMODE && PHYSFSX_exists(fname2,1)) || !PHYSFSX_exists(fname,1)) strcpy(fname,fname2); load_briefing_screen(*grd_curcanv, br, fname); } #endif } else if (ch == 'B') { array<char, 32> bitmap_name; palette_array_t temp_palette; int iff_error; br->robot_canv.reset(); get_message_name(br->message, bitmap_name, ".bbm"); br->guy_bitmap.reset(); iff_error = iff_read_bitmap(&bitmap_name[0], br->guy_bitmap, &temp_palette); #if defined(DXX_BUILD_DESCENT_II) gr_remap_bitmap_good( br->guy_bitmap, temp_palette, -1, -1 ); #endif Assert(iff_error == IFF_NO_ERROR); (void)iff_error; br->prev_ch = 10; } else if (ch == 'S') { #if defined(DXX_BUILD_DESCENT_II) br->chattering = 0; br->printing_channel.reset(); #endif br->new_screen = 1; return 1; } else if (ch == 'P') { // New page. #if defined(DXX_BUILD_DESCENT_II) if (!br->got_z) { Int3(); // Hey ryan!!!! You gotta load a screen before you start // printing to it! You know, $Z !!! load_briefing_screen(*grd_curcanv, br, HIRESMODE ? "end01b.pcx" : "end01.pcx"); } br->chattering = 0; br->printing_channel.reset(); #endif br->new_page = 1; while (*br->message != 10) { br->message++; // drop carriage return after special escape sequence } br->message++; br->prev_ch = 10; return 1; } #if defined(DXX_BUILD_DESCENT_II) else if (ch == ':') { br->prev_ch = 10; auto p = br->message; /* Legacy clients do not understand $: and will instead show * the remainder of the line. However, if the next two * characters after $: are $F, legacy clients will treat * the $F as above, toggle the flashing_cursor flag, then * discard the rest of the line. This special case allows * briefing authors to hide the directive from legacy * clients, but get the same state of flashing_cursor for * both legacy and aware clients. Briefing authors will * likely need an additional $F nearby to balance this * toggle, but no additional code here is needed to support * that. * * The trailing colon is cosmetic, so that the compatibility * $F is not directly adjacent to the directive. */ if (!strncmp(p, "$F:", 3)) { br->flashing_cursor = !br->flashing_cursor; p += 3; } auto &rotate_robot_label = "Rebirth.rotate.robot "; constexpr auto rotate_robot_len = sizeof(rotate_robot_label) - 1; if (!strncmp(p, rotate_robot_label, rotate_robot_len)) { char *p2; const auto id = strtoul(p + rotate_robot_len, &p2, 10); if (*p2 == '\n') { p = p2; br->robot_canv.reset(); if (br->robot_playing) { br->robot_playing = 0; DeInitRobotMovie(br->pMovie); } init_spinning_robot(canvas, *br); /* This modifies the appearance of the frame, which * is unfortunate. However, without it, all robots * come out blue shifted. */ gr_use_palette_table("groupa.256"); br->robot_num = id; } } else { const char *p2 = p; /* Suppress non-printing characters. No need to support * encodings. */ for (char c; (c = *p2) >= ' ' && c <= '~'; ++p2) { } con_printf(CON_VERBOSE, "warning: unknown briefing directive \"%.*s\"", DXX_ptrdiff_cast_int(p2 - p), p); } for (char c; (c = *p) && (++p, c) != '\n';) { /* Discard through newline. On break, *p is '\0' or * p[-1] is '\n'. */ } br->message = p; } #endif else if (ch == '$' || ch == ';') // Print a $/; put_char_delay(game_font, br, ch); } else if (ch == '\t') { // Tab const auto &&fspacx = FSPACX(); if (br->text_x - br->screen->text_ulx < fspacx(br->tab_stop)) br->text_x = br->screen->text_ulx + fspacx(br->tab_stop); } else if ((ch == ';') && (br->prev_ch == 10)) { while (*br->message++ != 10) ; br->prev_ch = 10; } else if (ch == '\\') { br->prev_ch = ch; } else if (ch == 10) { if (br->prev_ch != '\\') { br->prev_ch = ch; #if defined(DXX_BUILD_DESCENT_II) if (br->dumb_adjust) br->dumb_adjust--; else #endif br->text_y += FSPACY(5)+FSPACY(5)*3/5; br->text_x = br->screen->text_ulx; if (br->text_y > br->screen->text_uly + br->screen->text_height) { #if defined(DXX_BUILD_DESCENT_I) load_briefing_screen(*grd_curcanv, br, D1_Briefing_screens[br->cur_screen].bs_name); #elif defined(DXX_BUILD_DESCENT_II) load_briefing_screen(*grd_curcanv, br, Briefing_screens[br->cur_screen].bs_name); #endif br->text_x = br->screen->text_ulx; br->text_y = br->screen->text_uly; } } else { if (ch == 13) //Can this happen? Above says ch==10 Int3(); br->prev_ch = ch; } } else { #if defined(DXX_BUILD_DESCENT_II) if (!br->got_z) { LevelError("briefing wrote to screen without using $Z to load a screen; loading default."); //Int3(); // Hey ryan!!!! You gotta load a screen before you start // printing to it! You know, $Z !!! load_briefing_screen(*grd_curcanv, br, HIRESMODE ? "end01b.pcx" : "end01.pcx"); } #endif put_char_delay(game_font, br, ch); } return 0; }
// ----------------------------------------------------------------------------- // Return true if message got aborted by user (pressed ESC), else return false. int show_briefing_message(int screen_num, char *message) { int prev_ch=-1; int ch, done=0; briefing_screen *bsp = &Briefing_screens[screen_num]; int delay_count = KEY_DELAY_DEFAULT; int key_check; int robot_num=-1; int rval=0; int tab_stop=0; int flashing_cursor=0; int new_page=0; int text_ulx = rescale_x(bsp->text_ulx); int text_uly = rescale_y(bsp->text_uly); Bitmap_name[0] = 0; Current_color = 0; // mprintf((0, "Going to print message [%s] at x=%i, y=%i\n", message, x, y)); gr_set_curfont( GAME_FONT ); init_char_pos(text_ulx, text_uly); while (!done) { ch = *message++; if (ch == '$') { ch = *message++; if (ch == 'C') { Current_color = get_message_num(&message)-1; Assert((Current_color >= 0) && (Current_color < MAX_BRIEFING_COLORS)); prev_ch = 10; } else if (ch == 'F') { // toggle flashing cursor flashing_cursor = !flashing_cursor; prev_ch = 10; while (*message++ != 10) ; } else if (ch == 'T') { tab_stop = get_message_num(&message); prev_ch = 10; // read to eoln } else if (ch == 'R') { if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} init_spinning_robot(); robot_num = get_message_num(&message); prev_ch = 10; // read to eoln } else if (ch == 'N') { //--grs_bitmap *bitmap_ptr; if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, Bitmap_name); strcat(Bitmap_name, "#0"); Animating_bitmap_type = 0; prev_ch = 10; } else if (ch == 'O') { if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, Bitmap_name); strcat(Bitmap_name, "#0"); Animating_bitmap_type = 1; prev_ch = 10; } else if (ch == 'B') { char bitmap_name[32]; grs_bitmap guy_bitmap; ubyte temp_palette[768]; int iff_error; if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} get_message_name(&message, bitmap_name); strcat(bitmap_name, ".bbm"); gr_init_bitmap_data (&guy_bitmap); iff_error = iff_read_bitmap(bitmap_name, &guy_bitmap, BM_LINEAR, temp_palette); Assert(iff_error == IFF_NO_ERROR); show_briefing_bitmap(&guy_bitmap); gr_free_bitmap_data (&guy_bitmap); prev_ch = 10; // } else if (ch == 'B') { // if (Robot_canv != NULL) // {free(Robot_canv); Robot_canv=NULL;} // // bitmap_num = get_message_num(&message); // if (bitmap_num != -1) // show_briefing_bitmap(Textures[bitmap_num]); // prev_ch = 10; // read to eoln } else if (ch == 'S') { int keypress; fix start_time; fix time_out_value; start_time = timer_get_fixed_seconds(); start_time = timer_get_approx_seconds(); time_out_value = start_time + i2f(60*5); // Wait 1 minute... //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key if ( timer_get_approx_seconds() > time_out_value ) { keypress = 0; break; // Time out after 1 minute.. } while (timer_get_fixed_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; flash_cursor(flashing_cursor); show_spinning_robot_frame(robot_num); show_bitmap_frame(); //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb start_time += KEY_DELAY_DEFAULT/2; } #ifndef NDEBUG if (keypress == KEY_BACKSP) Int3(); #endif if (keypress == KEY_ESC) rval = 1; flashing_cursor = 0; done = 1; } else if (ch == 'P') { // New page. new_page = 1; while (*message != 10) { message++; // drop carriage return after special escape sequence } message++; prev_ch = 10; //Begin D1X addition } else if (ch == '$' || ch == ';') { // Print a $/; prev_ch = ch; Briefing_text_x += show_char_delay((char) ch, delay_count, robot_num, flashing_cursor); //End D1X addition } } else if (ch == '\t') { // Tab if (Briefing_text_x - text_ulx < tab_stop) Briefing_text_x = text_ulx + tab_stop; } else if ((ch == ';') && (prev_ch == 10)) { while (*message++ != 10) ; prev_ch = 10; } else if (ch == '\\') { prev_ch = ch; } else if (ch == 10) { if (prev_ch != '\\') { prev_ch = ch; Briefing_text_y += GAME_FONT->ft_h+GAME_FONT->ft_h*3/5; Briefing_text_x = text_ulx; if (Briefing_text_y > text_uly + rescale_y(bsp->text_height)) { load_briefing_screen(screen_num); Briefing_text_x = text_ulx; Briefing_text_y = text_uly; } } else { if (ch == 13) Int3(); prev_ch = ch; } } else { prev_ch = ch; Briefing_text_x += show_char_delay((char) ch, delay_count, robot_num, flashing_cursor); } //added/changed on 9/13/98 by adb to speed up briefings after pressing a key with SDL // Check for Esc -> abort. if(delay_count) key_check=local_key_inkey(); else key_check=0; //end change - adb if ( key_check == KEY_ESC ) { rval = 1; done = 1; } if ( key_check == KEY_ALTED+KEY_F2 ) title_save_game(); if ((key_check == KEY_SPACEBAR) || (key_check == KEY_ENTER)) delay_count = 0; if (Briefing_text_x > text_ulx + rescale_x(bsp->text_width)) { Briefing_text_x = text_ulx; Briefing_text_y += GAME_FONT->ft_h+GAME_FONT->ft_h*3/5; } if ((new_page) || (Briefing_text_y > text_uly + rescale_y(bsp->text_height))) { fix start_time = 0; fix time_out_value = 0; int keypress; new_page = 0; start_time = timer_get_approx_seconds(); time_out_value = start_time + i2f(60*5); // Wait 1 minute... //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb while ( (keypress = local_key_inkey()) == 0 ) { // Wait for a key if ( timer_get_approx_seconds() > time_out_value ) { keypress = 0; break; // Time out after 1 minute.. } while (timer_get_approx_seconds() < start_time + KEY_DELAY_DEFAULT/2) ; flash_cursor(flashing_cursor); show_spinning_robot_frame(robot_num); show_bitmap_frame(); //added on 9/13/98 by adb to make arch's requiring updates work gr_update(); //end changes by adb start_time += KEY_DELAY_DEFAULT/2; } robot_num = -1; #ifndef NDEBUG if (keypress == KEY_BACKSP) Int3(); #endif if (keypress == KEY_ESC) { rval = 1; done = 1; } load_briefing_screen(screen_num); Briefing_text_x = text_ulx; Briefing_text_y = text_uly; delay_count = KEY_DELAY_DEFAULT; } } if (Robot_canv != NULL) {free(Robot_canv); Robot_canv=NULL;} return rval; }
int _ant_send_message(asm_t* self, uchar_t msg_id, uchar_t channel, const uchar_t data[], uchar_t data_size, ant_msg_t* response) { uchar_t msgbuffer[sizeof(ant_msg_t) + 1]; /* message + sync byte */ ant_msg_t *msg = (ant_msg_t*)(msgbuffer+1); uchar_t chksum, *p; size_t msg_size = (sizeof(msg->id) +sizeof(msg->size) +sizeof(msg->channel) +data_size); int i, error, retry=0; if (_keyboard_interrupted()) return MR_ABORTED; if (ant_is_recovering(self)) return MR_RECOVERING; /*@cstart(build message)*/ msgbuffer[0] = MESG_TX_SYNC; msg->size = data_size+1; /* +1 for channel */ msg->id = msg_id; msg->channel = channel; memcpy(msg->data, data, data_size); chksum = 0; for (i = 0, p = msgbuffer; i < (int)msg_size+1; i++, p++) chksum ^= *p; msg->data[data_size++] = chksum; msg->data[data_size++] = 0; msg->data[data_size] = 0; #if _DEBUG_LEVEL >= 1 print_log("#_ant_send_message: %s(%i) ", get_message_name(msg->id), (int)msg->channel); print_message_bytes(msg); print_log("-%u\n", (ushort_t)(ant_clock() & 0xFFFF)); #endif if (ant_is_waiting_for_response(self)) CHECK(MR_WRONG_STATE); /*@(build message)*/ _try_again: CHECK(_ant_write(self, msgbuffer, msg_size+4)); /* 4 == +sizeof(sync)+sizeof(checksum)+2*sizeof(0) */ error = _ant_wait_for_response(self, msg, response, 0); /*@cstart(time out handling)*/ if (error == MR_TIMEOUT && retry < 10 && msg_id != MESG_ACKNOWLEDGED_DATA_ID && msg_id != MESG_BURST_DATA_ID) { char zeros[15]; retry++; memset(zeros, 0, sizeof(zeros)); _ant_write(self, zeros, sizeof(zeros)); goto _try_again; } /*@(time out handling)*/ CHECK(error); BEGIN_EXCEPT; print_exception(); END_EXCEPT; return error; }