static void basicdsk_default_geometry(const struct FloppyFormat *format, struct basicdsk_geometry *geometry) { optreserr_t err; int sector_length; memset(geometry, 0, sizeof(*geometry)); err = option_resolution_getdefault(format->param_guidelines, PARAM_HEADS, &geometry->heads); assert(!err); err = option_resolution_getdefault(format->param_guidelines, PARAM_TRACKS, &geometry->tracks); assert(!err); err = option_resolution_getdefault(format->param_guidelines, PARAM_SECTORS, &geometry->sectors); assert(!err); err = option_resolution_getdefault(format->param_guidelines, PARAM_FIRST_SECTOR_ID, &geometry->first_sector_id); assert(!err); err = option_resolution_getdefault(format->param_guidelines, PARAM_SECTOR_LENGTH, §or_length); assert(!err); geometry->sector_length = sector_length; }
static BOOL prepare_editbox(HWND control, const option_guide *guide, const char *optspec) { optreserr_t err = OPTIONRESOLUTION_ERROR_SUCCESS; char buf[32]; int val, has_option, option_count; has_option = guide && optspec; buf[0] = '\0'; if (has_option) { switch(guide->option_type) { case OPTIONTYPE_STRING: break; case OPTIONTYPE_INT: err = option_resolution_getdefault(optspec, guide->parameter, &val); if (err) goto done; _snprintf(buf, ARRAY_LENGTH(buf), "%d", val); break; default: err = OPTIONRESOLTUION_ERROR_INTERNAL; goto done; } } if (has_option) { option_count = get_option_count(guide, optspec); if (option_count <= 1) has_option = FALSE; } done: assert(err != OPTIONRESOLTUION_ERROR_INTERNAL); win_set_window_text_utf8(control, buf); EnableWindow(control, !err && has_option); return err == OPTIONRESOLUTION_ERROR_SUCCESS; }
static void basicdsk_default_geometry(const struct FloppyFormat *format, struct basicdsk_geometry *geometry) { optreserr_t err; int sector_length; memset(geometry, 0, sizeof(*geometry)); err = option_resolution_getdefault(format->param_guidelines, PARAM_HEADS, &geometry->heads); assert(!err); err = option_resolution_getdefault(format->param_guidelines, PARAM_TRACKS, &geometry->tracks); assert(!err); err = option_resolution_getdefault(format->param_guidelines, PARAM_SECTORS, &geometry->sectors); assert(!err); err = option_resolution_getdefault(format->param_guidelines, PARAM_FIRST_SECTOR_ID, &geometry->first_sector_id); assert(!err); err = option_resolution_getdefault(format->param_guidelines, PARAM_INTERLEAVE, &geometry->interleave); if (err!=0) { geometry->interleave = 1; } err = option_resolution_getdefault(format->param_guidelines, PARAM_SECTOR_LENGTH, §or_length); assert(!err); geometry->sector_length = sector_length; if (geometry->interleave > 1) { int sector = 0; for (int i = 0; i < geometry->sectors; i++) { geometry->sector_map[i] = sector; sector += geometry->interleave; if (sector >= geometry->sectors) sector -= geometry->sectors; } geometry->translate_sector = internal_basicdsk_translate_sector_interleave; } }
static BOOL prepare_combobox(HWND control, const option_guide *guide, const char *optspec) { struct OptionRange ranges[128]; int default_value, default_index, current_index, option_count; int i, j, k; BOOL has_option; TCHAR buf1[256]; TCHAR buf2[256]; LPTSTR tempstr; SendMessage(control, CB_GETLBTEXT, SendMessage(control, CB_GETCURSEL, 0, 0), (LPARAM) buf1); SendMessage(control, CB_RESETCONTENT, 0, 0); has_option = guide && optspec; if (has_option) { if ((guide->option_type != OPTIONTYPE_INT) && (guide->option_type != OPTIONTYPE_ENUM_BEGIN)) goto unexpected; option_resolution_listranges(optspec, guide->parameter, ranges, ARRAY_LENGTH(ranges)); option_resolution_getdefault(optspec, guide->parameter, &default_value); option_count = 0; default_index = -1; current_index = -1; for (i = 0; ranges[i].min >= 0; i++) { for (j = ranges[i].min; j <= ranges[i].max; j++) { if (guide->option_type == OPTIONTYPE_INT) { _sntprintf(buf2, ARRAY_LENGTH(buf2), TEXT("%d"), j); SendMessage(control, CB_ADDSTRING, 0, (LPARAM) buf2); } else if (guide->option_type == OPTIONTYPE_ENUM_BEGIN) { for (k = 1; guide[k].option_type == OPTIONTYPE_ENUM_VALUE; k++) { if (guide[k].parameter == j) break; } if (guide[k].option_type != OPTIONTYPE_ENUM_VALUE) goto unexpected; tempstr = tstring_from_utf8(guide[k].display_name); SendMessage(control, CB_ADDSTRING, 0, (LPARAM) tempstr); osd_free(tempstr); } else goto unexpected; SendMessage(control, CB_SETITEMDATA, option_count, j); if (j == default_value) default_index = option_count; if (!_tcscmp(buf1, buf2)) current_index = option_count; option_count++; } } // if there is only one option, it is effectively disabled if (option_count <= 1) has_option = FALSE; if (current_index >= 0) SendMessage(control, CB_SETCURSEL, current_index, 0); else if (default_index >= 0) SendMessage(control, CB_SETCURSEL, default_index, 0); } else { // this item is non applicable SendMessage(control, CB_ADDSTRING, 0, (LPARAM) TEXT("N/A")); SendMessage(control, CB_SETCURSEL, 0, 0); } EnableWindow(control, has_option); return TRUE; unexpected: assert(FALSE); return FALSE; }