const char* file_config_list(const char* const_list, const char* (*expand_dir)(const char* tag), const char* ref_dir) { char* list = strdup(const_list); int i; FL.list_buffer[0] = 0; i = 0; while (list[i]) { char c; const char* file; file = stoken(&c, &i, list, ";", ""); if (FL.list_buffer[0]) sncat(FL.list_buffer, sizeof(FL.list_buffer), ";"); if (ref_dir) sncat(FL.list_buffer, sizeof(FL.list_buffer), file_abs(ref_dir, file)); else sncat(FL.list_buffer, sizeof(FL.list_buffer), file); } free(list); return FL.list_buffer; }
static void draw_text_bar(int x, int by1, int by2, int dx) { char buffer[256]; unsigned i; snprintf(buffer, sizeof(buffer), " AdvanceVIDEO Config - " __DATE__); draw_text_left(x, by1, dx, buffer, COLOR_BAR); sncpy(buffer, sizeof(buffer), ""); for(i=0;i<video_driver_vector_max();++i) { if (video_driver_vector_pos(i) != 0) { if (*buffer) sncat(buffer, sizeof(buffer), "/"); sncat(buffer, sizeof(buffer), video_driver_vector_pos(i)->name); } } draw_text_left(x + dx - strlen(buffer), by1, strlen(buffer), buffer, COLOR_BAR); snprintf(buffer, sizeof(buffer), " # x y pclock hclock vclock name"); draw_text_left(x, by1+2, dx, buffer, COLOR_TITLE); snprintf(buffer, sizeof(buffer), " F1 Help F2 Save SPACE Select TAB Rename ENTER Test ESC Exit"); draw_text_left(x, by2, dx, buffer, COLOR_BAR); }
/** * Report the available drivers. * The driver names are copied in the string separated by spaces. */ void joystickb_report_driver_all(char* s, unsigned size) { *s = 0; /* the order is not relevant */ #ifdef USE_JOYSTICK_EVENT sncat(s, size, " event"); #endif #ifdef USE_JOYSTICK_SVGALIB sncat(s, size, " svgalib"); #endif #ifdef USE_JOYSTICK_RAW sncat(s, size, " raw"); #endif #ifdef USE_JOYSTICK_LGRAWINPUT sncat(s, size, " lgrawinput"); #endif #ifdef USE_JOYSTICK_SDL sncat(s, size, " sdl"); #endif #ifdef USE_JOYSTICK_ALLEGRO sncat(s, size, " allegro"); #endif #ifdef USE_JOYSTICK_LGALLEGRO sncat(s, size, " lgallegro"); #endif #ifdef USE_JOYSTICK_NONE sncat(s, size, " none"); #endif }
/** * Report the available drivers. * The driver names are copied in the string separated by spaces. */ void soundb_report_driver_all(char* s, unsigned size) { *s = 0; #ifdef USE_SOUND_SEAL sncat(s, size, " seal"); #endif #ifdef USE_SOUND_ALLEGRO sncat(s, size, " allegro"); #endif #ifdef USE_SOUND_VSYNC sncat(s, size, " vsync"); #endif #ifdef USE_SOUND_ALSA sncat(s, size, " alsa"); #endif #ifdef USE_SOUND_OSS sncat(s, size, " oss"); #endif #ifdef USE_SOUND_SDL sncat(s, size, " sdl"); #endif #ifdef USE_SOUND_NONE sncat(s, size, " none"); #endif }
void monitor_print(char* buffer, unsigned size, const adv_monitor* monitor) { unsigned i; buffer[0] = 0; for(i=0;i<monitor->mode_mac;++i) { char mode_buffer[1024]; if (i != 0) sncat(buffer, size, " ; "); monitor_range_print(mode_buffer, size, &monitor->mode_map[i].pclock, 1E6); sncat(buffer, size, mode_buffer); sncat(buffer, size, " / "); monitor_range_print(mode_buffer, sizeof(mode_buffer), &monitor->mode_map[i].hclock, 1E3); sncat(buffer, size, mode_buffer); sncat(buffer, size, " / "); monitor_range_print(mode_buffer, sizeof(mode_buffer), &monitor->mode_map[i].vclock, 1); sncat(buffer, size, mode_buffer); } }
/** * Display a string on the LCD. * The string is displayed with a vertical scrolling it the LCD is too small. * \param context LCD context to use. * \param text Text to display. * \param speed Scrolling speed in 1/8th of seconds. */ adv_error adv_lcd_display(adv_lcd* context, unsigned row, const char* text, int speed) { adv_error r; char* buffer; unsigned size; char* s; unsigned i; if (context->mute_flag) { return -1; } if (speed < -16) speed = -16; if (speed > 16) speed = 16; if (speed == 0) speed = 1; if (row >= context->height) { log_std(("WARNING:lcd: output out of screen\n")); return -1; } size = 256 + strlen(text); buffer = malloc(size); snprintf(buffer, size, "widget_set advance message%d %d %d %d %d h %d \"", row, 1, row+1, context->width, row+1, speed); s = buffer + strlen(buffer); for(i=0;text[i];++i) { if (text[i] != '"' && (text[i]>=' ' && text[i]<='~')) *s++ = text[i]; } *s = 0; sncat(buffer, size, "\"\n"); r = adv_lcd_sendstr_noblock(context, buffer); free(buffer); if (r != 0) { log_std(("WARNING:lcd: output disabled\n")); context->mute_flag = 1; return -1; } return 0; }
adv_error monitor_conversion_legacy(adv_conf* context) { char buffer[1024]; adv_error p_error; adv_error h_error; adv_error v_error; const char* p; const char* h; const char* v; char* ps; char* hs; char* vs; char c; int pi,hi,vi; /* LEGACY support of old device_video_p/h/vclock format */ p_error = conf_string_section_get(context, "", "device_video_pclock", &p); h_error = conf_string_section_get(context, "", "device_video_hclock", &h); v_error = conf_string_section_get(context, "", "device_video_vclock", &v); /* check if all are missing */ if (p_error != 0 && h_error != 0 && v_error != 0) return 0; /* partially missing */ if (p_error != 0 || h_error != 0 || v_error != 0) { error_set("Missing options 'device_video_p/h/vclock'"); return -1; } buffer[0] = 0; ps = strdup(p); hs = strdup(h); vs = strdup(v); /* set the new format */ pi = 0; sskip(&pi, ps, " "); while (ps[pi]) { const char* pt; pt = stoken(&c, &pi, ps, ",", " "); hi = 0; sskip(&hi, hs, " "); while (hs[hi]) { const char* ht; ht = stoken(&c, &hi, hs, ",", " "); vi = 0; sskip(&vi, vs, " "); while (vs[vi]) { const char* vt; vt = stoken(&c, &vi, vs, ",", " "); if (*buffer != 0) sncat(buffer, sizeof(buffer), " ; "); sncatf(buffer, sizeof(buffer), "%s / %s / %s", pt, ht, vt); sskip(&vi, vs, " "); } sskip(&hi, hs, " "); } sskip(&pi, ps, " "); } free(ps); free(hs); free(vs); conf_string_set(context, "", "device_video_clock", buffer); /* remove the old copy */ conf_remove(context, "", "device_video_pclock"); conf_remove(context, "", "device_video_hclock"); conf_remove(context, "", "device_video_vclock"); return 0; }
static void ui_help_update(struct advance_ui_context* context, adv_bitmap* dst, struct ui_color_set* color) { int size_x; int size_y; int pos_x; int pos_y; unsigned cx; unsigned cy; unsigned i; unsigned pb; char msg_buffer[256]; adv_bitmap* flat; adv_color_def def = color->def; struct mame_digital_map_entry digital_map[UI_MAP_MAX]; unsigned digital_mac; mame_ui_input_map(&digital_mac, digital_map, UI_MAP_MAX); size_x = context->state.help_image->size_x; size_y = context->state.help_image->size_y; pos_x = dst->size_x / 2 - size_x / 2; pos_y = dst->size_y / 8; if (ui_alpha(def)) flat = adv_bitmap_alloc(size_x, size_y, color_def_bytes_per_pixel_get(context->state.buffer_def)); else flat = adv_bitmap_alloc(size_x, size_y, color_def_bytes_per_pixel_get(def)); pb = 0; /* black on RGB format */ for (cy = 0; cy < context->state.help_image->size_y; ++cy) { for (cx = 0; cx < context->state.help_image->size_x; ++cx) { adv_pixel c; if ((adv_bitmap_pixel_get(context->state.help_image, cx, cy)) != pb) { c = color->ui_f.f; } else { c = color->ui_b.b; } adv_bitmap_pixel_put(flat, cx, cy, c); } } msg_buffer[0] = 0; for (i = 0; i < digital_mac; ++i) { unsigned j; adv_bool pred_not = 0; if (digital_map[i].port_state) { struct mame_port* p; p = mame_port_find(digital_map[i].port); if (p) { unsigned k; /* add the port name only one time */ /* if the port list is broken, a port name may appers more than one time */ for (k = 0; k < i; ++k) if (digital_map[k].port == digital_map[i].port) break; if (k == i) { if (msg_buffer[0]) sncat(msg_buffer, sizeof(msg_buffer), ", "); sncat(msg_buffer, sizeof(msg_buffer), p->desc); } } } for (j = 0; j < MAME_INPUT_MAP_MAX && digital_map[i].seq[j] != DIGITAL_SPECIAL_NONE; ++j) { if (!pred_not) { unsigned k; unsigned ckf; unsigned ckb; switch (mame_port_player(digital_map[i].port)) { case 1: ckb = color->help_p1.b; break; case 2: ckb = color->help_p2.b; break; case 3: ckb = color->help_p3.b; break; case 4: ckb = color->help_p4.b; break; default: ckb = color->help_u.b; break; } ckf = color->ui_f.f; if (digital_map[i].port_state) { ckf = color->ui_f.f; ckb = color->ui_f.b; } for (k = 0; k < context->config.help_mac; ++k) { if (context->config.help_map[k].code == digital_map[i].seq[j]) { struct help_entry* h = context->config.help_map + k; ui_help_update_key(flat, context->state.help_image, 0, 0, h->x, h->y, h->dx, h->dy, ckf, ckb, pb); } } } pred_not = digital_map[i].seq[j] == DIGITAL_SPECIAL_NOT; } } if (ui_alpha(def)) adv_bitmap_put_alpha(dst, pos_x, pos_y, def, flat, 0, 0, flat->size_x, flat->size_y, context->state.buffer_def); else adv_bitmap_put(dst, pos_x, pos_y, flat, 0, 0, flat->size_x, flat->size_y); adv_bitmap_free(flat); if (msg_buffer[0]) ui_messagebox_center(context, dst, dst->size_x / 2, pos_y + size_y + adv_font_sizey(context->state.ui_font) * 2, msg_buffer, msg_buffer + strlen(msg_buffer), color->ui_f, color->ui_b, color->ui_alpha, color->def); }
void run(void) { char msg[1024]; char new_msg[1024]; int i, j, k; target_clock_t last; printf("Press Break to exit\n"); signal(SIGINT, sigint); last = target_clock(); msg[0] = 0; while (!done) { new_msg[0] = 0; for (i = 0; i < joystickb_count_get(); ++i) { if (i != 0) sncat(new_msg, sizeof(new_msg), "\n"); snprintf(new_msg + strlen(new_msg), sizeof(new_msg) - strlen(new_msg), "joy %d, [", i); for (j = 0; j < joystickb_button_count_get(i); ++j) { if (joystickb_button_get(i, j)) sncat(new_msg, sizeof(new_msg), "_"); else sncat(new_msg, sizeof(new_msg), "-"); } sncat(new_msg, sizeof(new_msg), "], "); for (j = 0; j < joystickb_stick_count_get(i); ++j) { for (k = 0; k < joystickb_stick_axe_count_get(i, j); ++k) { char digital; if (joystickb_stick_axe_digital_get(i, j, k, 0)) digital = '\\'; else if (joystickb_stick_axe_digital_get(i, j, k, 1)) digital = '/'; else digital = '-'; sncatf(new_msg, sizeof(new_msg), " %d/%d [%6d %c]", j, k, joystickb_stick_axe_analog_get(i, j, k), digital); } } sncat(new_msg, sizeof(new_msg), " ["); for (j = 0; j < joystickb_rel_count_get(i); ++j) { if (j != 0) sncat(new_msg, sizeof(new_msg), "/"); sncatf(new_msg, sizeof(new_msg), "%d", joystickb_rel_get(i, j)); } sncat(new_msg, sizeof(new_msg), "]"); } if (strcmp(msg, new_msg) != 0) { target_clock_t current = target_clock(); double period = (current - last) * 1000.0 / TARGET_CLOCKS_PER_SEC; last = current; sncpy(msg, sizeof(msg), new_msg); printf("%s (%4.0f ms)\n", msg, period); } os_poll(); joystickb_poll(); target_yield(); } }