src/mess/tools/messtest/testmess.c
| r6274 | r6275 | |
| 216 | 216 | if (write_file) |
| 217 | 217 | { |
| 218 | 218 | /* dump a screenshot */ |
| 219 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 219 | snprintf(buf, ARRAY_LENGTH(buf), |
| 220 | 220 | (screenshot_num >= 0) ? "_%s_%d.png" : "_%s.png", |
| 221 | 221 | current_testcase.name, screenshot_num); |
| 222 | 222 | filerr = mame_fopen(SEARCHPATH_SCREENSHOT, buf, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE, &fp); |
| r6274 | r6275 | |
| 280 | 280 | char *s; |
| 281 | 281 | int pos, nextpos; |
| 282 | 282 | |
| 283 | | vsnprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), format, argptr); |
| 283 | vsnprintf(buffer, ARRAY_LENGTH(buffer), format, argptr); |
| 284 | 284 | |
| 285 | 285 | pos = 0; |
| 286 | 286 | while(buffer[pos] != '\0') |
| r6274 | r6275 | |
| 451 | 451 | |
| 452 | 452 | if (current_testcase.wavwrite) |
| 453 | 453 | { |
| 454 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "snap/_%s.wav", current_testcase.name); |
| 454 | snprintf(buf, ARRAY_LENGTH(buf), "snap/_%s.wav", current_testcase.name); |
| 455 | 455 | wavptr = wav_open(buf, machine->sample_rate, 2); |
| 456 | 456 | } |
| 457 | 457 | else |
| r6274 | r6275 | |
| 777 | 777 | filename = current_command->u.image_args.filename; |
| 778 | 778 | if (!filename) |
| 779 | 779 | { |
| 780 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s.%s", |
| 780 | snprintf(buf, ARRAY_LENGTH(buf), "%s.%s", |
| 781 | 781 | current_testcase.name, file_extensions); |
| 782 | 782 | osd_get_temp_filename(buf, ARRAY_LENGTH(buf), buf); |
| 783 | 783 | filename = buf; |
| r6274 | r6275 | |
| 951 | 951 | for (cpu = cpu_first(machine->config); cpu != NULL; cpu = cpu_next(cpu)) |
| 952 | 952 | { |
| 953 | 953 | if (cpu_next(cpu_first(machine->config)) == NULL) |
| 954 | | snprintf(filename, sizeof(filename) / sizeof(filename[0]), "_%s.tr", current_testcase.name); |
| 954 | snprintf(filename, ARRAY_LENGTH(filename), "_%s.tr", current_testcase.name); |
| 955 | 955 | else |
| 956 | | snprintf(filename, sizeof(filename) / sizeof(filename[0]), "_%s.%d.tr", current_testcase.name, cpunum); |
| 956 | snprintf(filename, ARRAY_LENGTH(filename), "_%s.%d.tr", current_testcase.name, cpunum); |
| 957 | 957 | |
| 958 | 958 | file = fopen(filename, "w"); |
| 959 | 959 | if (file) |
| r6274 | r6275 | |
| 1055 | 1055 | return; |
| 1056 | 1056 | } |
| 1057 | 1057 | |
| 1058 | | for (i = 0; i < sizeof(commands) / sizeof(commands[i]); i++) |
| 1058 | for (i = 0; i < ARRAY_LENGTH(commands); i++) |
| 1059 | 1059 | { |
| 1060 | 1060 | if (current_command->command_type == commands[i].command_type) |
| 1061 | 1061 | { |
src/mess/tools/imgtool/windows/wimgtool.c
| r6274 | r6275 | |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | 189 | if (source) |
| 190 | | snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%s: %s", source, error_text); |
| 190 | snprintf(buffer, ARRAY_LENGTH(buffer), "%s: %s", source, error_text); |
| 191 | 191 | else |
| 192 | 192 | message = error_text; |
| 193 | 193 | win_message_box_utf8(window, message, wimgtool_producttext, MB_OK); |
| r6274 | r6275 | |
| 314 | 314 | info = get_wimgtool_info(window); |
| 315 | 315 | |
| 316 | 316 | /* retrieve temporary file path */ |
| 317 | | GetTempPath(sizeof(file_path) / sizeof(file_path[0]), file_path); |
| 317 | GetTempPath(ARRAY_LENGTH(file_path), file_path); |
| 318 | 318 | |
| 319 | 319 | if (extension != FOLDER_ICON) |
| 320 | 320 | { |
| r6274 | r6275 | |
| 449 | 449 | |
| 450 | 450 | if (entry->directory) |
| 451 | 451 | { |
| 452 | | _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), TEXT("<DIR>")); |
| 452 | _sntprintf(buffer, ARRAY_LENGTH(buffer), TEXT("<DIR>")); |
| 453 | 453 | } |
| 454 | 454 | else |
| 455 | 455 | { |
| 456 | 456 | // set the file size |
| 457 | | _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), |
| 457 | _sntprintf(buffer, ARRAY_LENGTH(buffer), |
| 458 | 458 | TEXT("%d"), entry->filesize); |
| 459 | 459 | } |
| 460 | 460 | column_index = 1; |
| r6274 | r6275 | |
| 466 | 466 | if (entry->creation_time != 0) |
| 467 | 467 | { |
| 468 | 468 | local_time = localtime(&entry->creation_time); |
| 469 | | _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _tasctime(local_time)); |
| 469 | _sntprintf(buffer, ARRAY_LENGTH(buffer), _tasctime(local_time)); |
| 470 | 470 | tstring_rtrim(buffer); |
| 471 | 471 | ListView_SetItemText(info->listview, new_index, column_index, buffer); |
| 472 | 472 | } |
| r6274 | r6275 | |
| 479 | 479 | if (entry->lastmodified_time != 0) |
| 480 | 480 | { |
| 481 | 481 | local_time = localtime(&entry->lastmodified_time); |
| 482 | | _sntprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), _tasctime(local_time)); |
| 482 | _sntprintf(buffer, ARRAY_LENGTH(buffer), _tasctime(local_time)); |
| 483 | 483 | tstring_rtrim(buffer); |
| 484 | 484 | ListView_SetItemText(info->listview, new_index, column_index, buffer); |
| 485 | 485 | } |
| r6274 | r6275 | |
| 577 | 577 | err = imgtool_partition_get_free_space(info->partition, &filesize); |
| 578 | 578 | if (err) |
| 579 | 579 | goto done; |
| 580 | | snprintf(size_buf, sizeof(size_buf) / sizeof(size_buf[0]), "%u bytes free", (unsigned) filesize); |
| 580 | snprintf(size_buf, ARRAY_LENGTH(size_buf), "%u bytes free", (unsigned) filesize); |
| 581 | 581 | } |
| 582 | 582 | |
| 583 | 583 | } |
| r6274 | r6275 | |
| 621 | 621 | { |
| 622 | 622 | // get file title from Windows |
| 623 | 623 | t_filename = tstring_from_utf8(info->filename); |
| 624 | | GetFileTitle(t_filename, file_title_buf, sizeof(file_title_buf) / sizeof(file_title_buf[0])); |
| 624 | GetFileTitle(t_filename, file_title_buf, ARRAY_LENGTH(file_title_buf)); |
| 625 | 625 | free(t_filename); |
| 626 | 626 | file_title = utf8_from_tstring(file_title_buf); |
| 627 | 627 | |
| r6274 | r6275 | |
| 639 | 639 | // has a current directory |
| 640 | 640 | if (imageinfo) |
| 641 | 641 | { |
| 642 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 642 | snprintf(buf, ARRAY_LENGTH(buf), |
| 643 | 643 | "%s (\"%s\") - %s", file_title, imageinfo, info->current_directory); |
| 644 | 644 | } |
| 645 | 645 | else |
| 646 | 646 | { |
| 647 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 647 | snprintf(buf, ARRAY_LENGTH(buf), |
| 648 | 648 | "%s - %s", file_title, info->current_directory); |
| 649 | 649 | } |
| 650 | 650 | } |
| 651 | 651 | else |
| 652 | 652 | { |
| 653 | 653 | // no current directory |
| 654 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 654 | snprintf(buf, ARRAY_LENGTH(buf), |
| 655 | 655 | imageinfo ? "%s (\"%s\")" : "%s", |
| 656 | 656 | file_title, imageinfo); |
| 657 | 657 | } |
| r6274 | r6275 | |
| 663 | 663 | } |
| 664 | 664 | else |
| 665 | 665 | { |
| 666 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 666 | snprintf(buf, ARRAY_LENGTH(buf), |
| 667 | 667 | "%s %s", wimgtool_producttext, build_version); |
| 668 | 668 | statusbar_text[0] = NULL; |
| 669 | 669 | statusbar_text[1] = NULL; |
| r6274 | r6275 | |
| 671 | 671 | |
| 672 | 672 | win_set_window_text_utf8(window, buf); |
| 673 | 673 | |
| 674 | | for (i = 0; i < sizeof(statusbar_text) / sizeof(statusbar_text[0]); i++) |
| 674 | for (i = 0; i < ARRAY_LENGTH(statusbar_text); i++) |
| 675 | 675 | { |
| 676 | 676 | TCHAR *tempstr = statusbar_text[i] ? tstring_from_utf8(statusbar_text[i]) : NULL; |
| 677 | 677 | SendMessage(info->statusbar, SB_SETTEXT, i, (LPARAM) tempstr); |
| r6274 | r6275 | |
| 897 | 897 | |
| 898 | 898 | if (!entry.eof) |
| 899 | 899 | { |
| 900 | | snprintf(local_subpath, sizeof(local_subpath) / sizeof(local_subpath[0]), |
| 900 | snprintf(local_subpath, ARRAY_LENGTH(local_subpath), |
| 901 | 901 | "%s\\%s", local_path, entry.filename); |
| 902 | 902 | subpath = imgtool_partition_path_concatenate(partition, path, entry.filename); |
| 903 | 903 | |
| r6274 | r6275 | |
| 933 | 933 | if (err) |
| 934 | 934 | goto done; |
| 935 | 935 | |
| 936 | | _sntprintf(local_subpath, sizeof(local_subpath) / sizeof(local_subpath[0]), TEXT("%s\\*.*"), local_path, wfd.cFileName); |
| 936 | _sntprintf(local_subpath, ARRAY_LENGTH(local_subpath), TEXT("%s\\*.*"), local_path, wfd.cFileName); |
| 937 | 937 | |
| 938 | 938 | h = FindFirstFile(local_subpath, &wfd); |
| 939 | 939 | if (h && (h != INVALID_HANDLE_VALUE)) |
| r6274 | r6275 | |
| 942 | 942 | { |
| 943 | 943 | if (_tcscmp(wfd.cFileName, TEXT(".")) && _tcscmp(wfd.cFileName, TEXT(".."))) |
| 944 | 944 | { |
| 945 | | _sntprintf(local_subpath, sizeof(local_subpath) / sizeof(local_subpath[0]), TEXT("%s\\%s"), local_path, wfd.cFileName); |
| 945 | _sntprintf(local_subpath, ARRAY_LENGTH(local_subpath), TEXT("%s\\%s"), local_path, wfd.cFileName); |
| 946 | 946 | filename = utf8_from_tstring(wfd.cFileName); |
| 947 | 947 | subpath = imgtool_partition_path_concatenate(partition, path, filename); |
| 948 | 948 | free(filename); |
| r6274 | r6275 | |
| 1194 | 1194 | |
| 1195 | 1195 | /* figure out which filters are appropriate for this file */ |
| 1196 | 1196 | imgtool_partition_suggest_file_filters(info->partition, NULL, stream, suggestion_info.suggestions, |
| 1197 | | sizeof(suggestion_info.suggestions) / sizeof(suggestion_info.suggestions[0])); |
| 1197 | ARRAY_LENGTH(suggestion_info.suggestions)); |
| 1198 | 1198 | |
| 1199 | 1199 | /* do we need to show an option dialog? */ |
| 1200 | 1200 | writefile_optguide = (const option_guide *) imgtool_partition_get_info_ptr(info->partition, IMGTOOLINFO_PTR_WRITEFILE_OPTGUIDE); |
| r6274 | r6275 | |
| 1316 | 1316 | if (!entry->directory) |
| 1317 | 1317 | { |
| 1318 | 1318 | imgtool_partition_suggest_file_filters(info->partition, filename, NULL, suggestion_info.suggestions, |
| 1319 | | sizeof(suggestion_info.suggestions) / sizeof(suggestion_info.suggestions[0])); |
| 1319 | ARRAY_LENGTH(suggestion_info.suggestions)); |
| 1320 | 1320 | |
| 1321 | 1321 | suggestion_info.selected = 0; |
| 1322 | | for (i = 0; i < sizeof(suggestion_info.suggestions) / sizeof(suggestion_info.suggestions[0]); i++) |
| 1322 | for (i = 0; i < ARRAY_LENGTH(suggestion_info.suggestions); i++) |
| 1323 | 1323 | { |
| 1324 | 1324 | if (suggestion_info.suggestions[i].viability == SUGGESTION_RECOMMENDED) |
| 1325 | 1325 | { |
| r6274 | r6275 | |
| 1437 | 1437 | |
| 1438 | 1438 | case EN_CHANGE: |
| 1439 | 1439 | GetWindowText(info->edit_box, |
| 1440 | | info->buf, sizeof(info->buf) / sizeof(info->buf[0])); |
| 1440 | info->buf, ARRAY_LENGTH(info->buf)); |
| 1441 | 1441 | EnableWindow(info->ok_button, info->buf[0] != '\0'); |
| 1442 | 1442 | break; |
| 1443 | 1443 | } |
| r6274 | r6275 | |
| 1573 | 1573 | CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, window, NULL, NULL, NULL); |
| 1574 | 1574 | if (!info->statusbar) |
| 1575 | 1575 | return -1; |
| 1576 | | SendMessage(info->statusbar, SB_SETPARTS, sizeof(status_widths) / sizeof(status_widths[0]), |
| 1576 | SendMessage(info->statusbar, SB_SETPARTS, ARRAY_LENGTH(status_widths), |
| 1577 | 1577 | (LPARAM) status_widths); |
| 1578 | 1578 | |
| 1579 | 1579 | // create imagelists |
| r6274 | r6275 | |
| 1632 | 1632 | count = DragQueryFile(drop, 0xFFFFFFFF, NULL, 0); |
| 1633 | 1633 | for (i = 0; i < count; i++) |
| 1634 | 1634 | { |
| 1635 | | DragQueryFile(drop, i, buffer, sizeof(buffer) / sizeof(buffer[0])); |
| 1635 | DragQueryFile(drop, i, buffer, ARRAY_LENGTH(buffer)); |
| 1636 | 1636 | filename = utf8_from_tstring(buffer); |
| 1637 | 1637 | |
| 1638 | 1638 | // figure out the file/dir name on the image |
| 1639 | | snprintf(subpath, sizeof(subpath) / sizeof(subpath[0]), "%s%s", |
| 1639 | snprintf(subpath, ARRAY_LENGTH(subpath), "%s%s", |
| 1640 | 1640 | info->current_directory ? info->current_directory : "", osd_basename(filename)); |
| 1641 | 1641 | |
| 1642 | 1642 | if (GetFileAttributes(buffer) & FILE_ATTRIBUTE_DIRECTORY) |
src/mess/tools/imgtool/windows/secview.c
| r6274 | r6275 | |
| 216 | 216 | info = get_sectorview_info(dialog); |
| 217 | 217 | |
| 218 | 218 | if (info->track != ~0) |
| 219 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%u", (unsigned int) info->track); |
| 219 | snprintf(buf, ARRAY_LENGTH(buf), "%u", (unsigned int) info->track); |
| 220 | 220 | else |
| 221 | 221 | buf[0] = '\0'; |
| 222 | 222 | win_set_window_text_utf8(GetDlgItem(dialog, IDC_TRACKEDIT), buf); |
| 223 | 223 | |
| 224 | 224 | if (info->head != ~0) |
| 225 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%u", (unsigned int) info->head); |
| 225 | snprintf(buf, ARRAY_LENGTH(buf), "%u", (unsigned int) info->head); |
| 226 | 226 | else |
| 227 | 227 | buf[0] = '\0'; |
| 228 | 228 | win_set_window_text_utf8(GetDlgItem(dialog, IDC_HEADEDIT), buf); |
| 229 | 229 | |
| 230 | 230 | if (info->sector != ~0) |
| 231 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%u", (unsigned int) info->sector); |
| 231 | snprintf(buf, ARRAY_LENGTH(buf), "%u", (unsigned int) info->sector); |
| 232 | 232 | else |
| 233 | 233 | buf[0] = '\0'; |
| 234 | 234 | win_set_window_text_utf8(GetDlgItem(dialog, IDC_SECTOREDIT), buf); |
| r6274 | r6275 | |
| 245 | 245 | |
| 246 | 246 | info = get_sectorview_info(dialog); |
| 247 | 247 | |
| 248 | | GetWindowText(GetDlgItem(dialog, IDC_TRACKEDIT), buf, sizeof(buf) / sizeof(buf[0])); |
| 248 | GetWindowText(GetDlgItem(dialog, IDC_TRACKEDIT), buf, ARRAY_LENGTH(buf)); |
| 249 | 249 | new_track = (UINT32) _ttoi(buf); |
| 250 | | GetWindowText(GetDlgItem(dialog, IDC_HEADEDIT), buf, sizeof(buf) / sizeof(buf[0])); |
| 250 | GetWindowText(GetDlgItem(dialog, IDC_HEADEDIT), buf, ARRAY_LENGTH(buf)); |
| 251 | 251 | new_head = (UINT32) _ttoi(buf); |
| 252 | | GetWindowText(GetDlgItem(dialog, IDC_SECTOREDIT), buf, sizeof(buf) / sizeof(buf[0])); |
| 252 | GetWindowText(GetDlgItem(dialog, IDC_SECTOREDIT), buf, ARRAY_LENGTH(buf)); |
| 253 | 253 | new_sector = (UINT32) _ttoi(buf); |
| 254 | 254 | |
| 255 | 255 | if ((info->track != new_track) || (info->head != new_head) || (info->sector != new_sector)) |
src/mess/tools/imgtool/filtbas.c
| r6274 | r6275 | |
| 2800 | 2800 | |
| 2801 | 2801 | static const basictoken_tableent cocobas_tokenents[] = |
| 2802 | 2802 | { |
| 2803 | | { 0x00, 0x80, cocobas_statements, sizeof(cocobas_statements) / sizeof(cocobas_statements[0]) }, |
| 2804 | | { 0xff, 0x80, cocobas_functions, sizeof(cocobas_functions) / sizeof(cocobas_functions[0]) } |
| 2803 | { 0x00, 0x80, cocobas_statements, ARRAY_LENGTH(cocobas_statements) }, |
| 2804 | { 0xff, 0x80, cocobas_functions, ARRAY_LENGTH(cocobas_functions) } |
| 2805 | 2805 | }; |
| 2806 | 2806 | |
| 2807 | 2807 | static const basictokens cocobas_tokens = |
| r6274 | r6275 | |
| 2810 | 2810 | 3, |
| 2811 | 2811 | TRUE, |
| 2812 | 2812 | cocobas_tokenents, |
| 2813 | | sizeof(cocobas_tokenents) / sizeof(cocobas_tokenents[0]) |
| 2813 | ARRAY_LENGTH(cocobas_tokenents) |
| 2814 | 2814 | }; |
| 2815 | 2815 | |
| 2816 | 2816 | static imgtoolerr_t cocobas_readfile(imgtool_partition *partition, const char *filename, |
| r6274 | r6275 | |
| 2844 | 2844 | |
| 2845 | 2845 | static const basictoken_tableent dragonbas_tokenents[] = |
| 2846 | 2846 | { |
| 2847 | | { 0x00, 0x80, dragonbas_statements, sizeof(dragonbas_statements) / sizeof(dragonbas_statements[0]) }, |
| 2848 | | { 0xff, 0x80, dragonbas_functions, sizeof(dragonbas_functions) / sizeof(dragonbas_functions[0]) } |
| 2847 | { 0x00, 0x80, dragonbas_statements, ARRAY_LENGTH(dragonbas_statements) }, |
| 2848 | { 0xff, 0x80, dragonbas_functions, ARRAY_LENGTH(dragonbas_functions) } |
| 2849 | 2849 | }; |
| 2850 | 2850 | |
| 2851 | 2851 | static const basictokens dragonbas_tokens = |
| r6274 | r6275 | |
| 2854 | 2854 | 4, |
| 2855 | 2855 | TRUE, |
| 2856 | 2856 | dragonbas_tokenents, |
| 2857 | | sizeof(dragonbas_tokenents) / sizeof(dragonbas_tokenents[0]) |
| 2857 | ARRAY_LENGTH(dragonbas_tokenents) |
| 2858 | 2858 | }; |
| 2859 | 2859 | |
| 2860 | 2860 | static imgtoolerr_t dragonbas_readfile(imgtool_partition *partition, const char *filename, |
| r6274 | r6275 | |
| 2888 | 2888 | |
| 2889 | 2889 | static const basictoken_tableent vzbas_tokenents[] = |
| 2890 | 2890 | { |
| 2891 | | { 0x00, 0x80, vzbas, sizeof(vzbas) / sizeof(vzbas[0]) } |
| 2891 | { 0x00, 0x80, vzbas, ARRAY_LENGTH(vzbas) } |
| 2892 | 2892 | }; |
| 2893 | 2893 | |
| 2894 | 2894 | |
| r6274 | r6275 | |
| 2899 | 2899 | 0, |
| 2900 | 2900 | FALSE, |
| 2901 | 2901 | vzbas_tokenents, |
| 2902 | | sizeof(vzbas_tokenents) / sizeof(vzbas_tokenents[0]) |
| 2902 | ARRAY_LENGTH(vzbas_tokenents) |
| 2903 | 2903 | }; |
| 2904 | 2904 | |
| 2905 | 2905 | static imgtoolerr_t vzbas_readfile(imgtool_partition *partition, const char *filename, |
src/mess/tools/imgtool/main.c
| r6274 | r6275 | |
| 96 | 96 | if (*fork) |
| 97 | 97 | goto optionalreadyspecified; |
| 98 | 98 | |
| 99 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s", value); |
| 99 | snprintf(buf, ARRAY_LENGTH(buf), "%s", value); |
| 100 | 100 | *fork = buf; |
| 101 | 101 | } |
| 102 | 102 | else |
| r6274 | r6275 | |
| 567 | 567 | imgtoolerr_t err; |
| 568 | 568 | int i; |
| 569 | 569 | |
| 570 | | err = imgtool_identify_file(argv[0], modules, sizeof(modules) / sizeof(modules[0])); |
| 570 | err = imgtool_identify_file(argv[0], modules, ARRAY_LENGTH(modules)); |
| 571 | 571 | if (err) |
| 572 | 572 | goto error; |
| 573 | 573 | |
| r6274 | r6275 | |
| 786 | 786 | while(opt_guide->option_type != OPTIONTYPE_END) |
| 787 | 787 | { |
| 788 | 788 | range_buffer[0] = 0; |
| 789 | | snprintf(opt_name, sizeof(opt_name) / sizeof(opt_name[0]), "--%s", opt_guide->identifier); |
| 789 | snprintf(opt_name, ARRAY_LENGTH(opt_name), "--%s", opt_guide->identifier); |
| 790 | 790 | opt_desc = opt_guide->display_name; |
| 791 | 791 | |
| 792 | 792 | /* is this option relevant? */ |
| r6274 | r6275 | |
| 799 | 799 | switch(opt_guide->option_type) { |
| 800 | 800 | case OPTIONTYPE_INT: |
| 801 | 801 | option_resolution_listranges(opt_spec, opt_guide->parameter, |
| 802 | | range, sizeof(range) / sizeof(range[0])); |
| 802 | range, ARRAY_LENGTH(range)); |
| 803 | 803 | |
| 804 | 804 | for (i = 0; range[i].max >= 0; i++) |
| 805 | 805 | { |
| 806 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 806 | snprintf(buf, ARRAY_LENGTH(buf), |
| 807 | 807 | (range[i].min == range[i].max) ? "%i" : "%i-%i", |
| 808 | 808 | range[i].min, |
| 809 | 809 | range[i].max); |
| r6274 | r6275 | |
| 938 | 938 | if (argc > 1) |
| 939 | 939 | { |
| 940 | 940 | /* figure out what command they are running, and run it */ |
| 941 | | for (i = 0; i < (sizeof(cmds) / sizeof(cmds[0])); i++) |
| 941 | for (i = 0; i < ARRAY_LENGTH(cmds); i++) |
| 942 | 942 | { |
| 943 | 943 | c = &cmds[i]; |
| 944 | 944 | if (!mame_stricmp(c->name, argv[1])) |
| r6274 | r6275 | |
| 977 | 977 | |
| 978 | 978 | /* Usage */ |
| 979 | 979 | fprintf(stderr, "imgtool - Generic image manipulation tool for use with MESS\n\n"); |
| 980 | | for (i = 0; i < (sizeof(cmds) / sizeof(cmds[0])); i++) |
| 980 | for (i = 0; i < ARRAY_LENGTH(cmds); i++) |
| 981 | 981 | { |
| 982 | 982 | writeusage(stdout, (i == 0), &cmds[i], argv); |
| 983 | 983 | } |
src/mess/tools/imgtool/modules/ti99.c
| r6274 | r6275 | |
| 4253 | 4253 | { |
| 4254 | 4254 | if (iter->listing_subdirs) |
| 4255 | 4255 | { |
| 4256 | | fname_to_str(ent->filename, iter->image->u.dsk.catalogs[0].subdirs[iter->index[iter->level]].name, sizeof(ent->filename) / sizeof(ent->filename[0])); |
| 4256 | fname_to_str(ent->filename, iter->image->u.dsk.catalogs[0].subdirs[iter->index[iter->level]].name, ARRAY_LENGTH(ent->filename)); |
| 4257 | 4257 | |
| 4258 | 4258 | /* set type of DIR */ |
| 4259 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "DIR"); |
| 4259 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "DIR"); |
| 4260 | 4260 | |
| 4261 | 4261 | /* len in physrecs */ |
| 4262 | 4262 | /* @BN@ return length in bytes */ |
| r6274 | r6275 | |
| 4277 | 4277 | if (reply) |
| 4278 | 4278 | return IMGTOOLERR_READERROR; |
| 4279 | 4279 | #if 0 |
| 4280 | | fname_to_str(ent->filename, fdr.name, sizeof(ent->filename) / sizeof(ent->filename[0])); |
| 4280 | fname_to_str(ent->filename, fdr.name, ARRAY_LENGTH(ent->filename)); |
| 4281 | 4281 | #else |
| 4282 | 4282 | { |
| 4283 | 4283 | char buf[11]; |
| r6274 | r6275 | |
| 4285 | 4285 | ent->filename[0] = '\0'; |
| 4286 | 4286 | if (iter->level) |
| 4287 | 4287 | { |
| 4288 | | fname_to_str(ent->filename, iter->image->u.dsk.catalogs[0].subdirs[iter->index[0]].name, sizeof(ent->filename) / sizeof(ent->filename[0])); |
| 4289 | | strncat(ent->filename, ".", sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 4288 | fname_to_str(ent->filename, iter->image->u.dsk.catalogs[0].subdirs[iter->index[0]].name, ARRAY_LENGTH(ent->filename)); |
| 4289 | strncat(ent->filename, ".", ARRAY_LENGTH(ent->filename) - 1); |
| 4290 | 4290 | } |
| 4291 | 4291 | fname_to_str(buf, fdr.name, 11); |
| 4292 | | strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 4292 | strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1); |
| 4293 | 4293 | } |
| 4294 | 4294 | #endif |
| 4295 | 4295 | /* parse flags */ |
| 4296 | 4296 | if (fdr.flags & fdr99_f_program) |
| 4297 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "PGM%s", |
| 4297 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "PGM%s", |
| 4298 | 4298 | (fdr.flags & fdr99_f_wp) ? " R/O" : ""); |
| 4299 | 4299 | else |
| 4300 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "%c/%c %d%s", |
| 4300 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "%c/%c %d%s", |
| 4301 | 4301 | (fdr.flags & fdr99_f_int) ? 'I' : 'D', |
| 4302 | 4302 | (fdr.flags & fdr99_f_var) ? 'V' : 'F', |
| 4303 | 4303 | fdr.reclen, |
| r6274 | r6275 | |
| 4377 | 4377 | if (iter->listing_subdirs) |
| 4378 | 4378 | { |
| 4379 | 4379 | #if 0 |
| 4380 | | fname_to_str(ent->filename, iter->catalog[iter->level].subdirs[iter->index[iter->level]].name, sizeof(ent->filename) / sizeof(ent->filename[0])); |
| 4380 | fname_to_str(ent->filename, iter->catalog[iter->level].subdirs[iter->index[iter->level]].name, ARRAY_LENGTH(ent->filename)); |
| 4381 | 4381 | #else |
| 4382 | 4382 | { |
| 4383 | 4383 | char buf[11]; |
| r6274 | r6275 | |
| 4386 | 4386 | for (i=0; i<iter->level; i++) |
| 4387 | 4387 | { |
| 4388 | 4388 | fname_to_str(buf, iter->catalog[i].subdirs[iter->index[i]].name, 11); |
| 4389 | | strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 4390 | | strncat(ent->filename, ".", sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 4389 | strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1); |
| 4390 | strncat(ent->filename, ".", ARRAY_LENGTH(ent->filename) - 1); |
| 4391 | 4391 | } |
| 4392 | 4392 | fname_to_str(buf, iter->catalog[iter->level].subdirs[iter->index[iter->level]].name, 11); |
| 4393 | | strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 4393 | strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1); |
| 4394 | 4394 | } |
| 4395 | 4395 | #endif |
| 4396 | 4396 | |
| 4397 | 4397 | /* set type of DIR */ |
| 4398 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "DIR"); |
| 4398 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "DIR"); |
| 4399 | 4399 | |
| 4400 | 4400 | /* len in physrecs */ |
| 4401 | 4401 | /* @BN@ return length in bytes */ |
| r6274 | r6275 | |
| 4420 | 4420 | if (reply) |
| 4421 | 4421 | return IMGTOOLERR_READERROR; |
| 4422 | 4422 | #if 0 |
| 4423 | | fname_to_str(ent->filename, iter->catalog[iter->level].files[iter->index[iter->level]].name, sizeof(ent->filename) / sizeof(ent->filename[0])); |
| 4423 | fname_to_str(ent->filename, iter->catalog[iter->level].files[iter->index[iter->level]].name, ARRAY_LENGTH(ent->filename)); |
| 4424 | 4424 | #else |
| 4425 | 4425 | { |
| 4426 | 4426 | char buf[11]; |
| r6274 | r6275 | |
| 4429 | 4429 | for (i=0; i<iter->level; i++) |
| 4430 | 4430 | { |
| 4431 | 4431 | fname_to_str(buf, iter->catalog[i].subdirs[iter->index[i]].name, 11); |
| 4432 | | strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 4433 | | strncat(ent->filename, ".", sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 4432 | strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1); |
| 4433 | strncat(ent->filename, ".", ARRAY_LENGTH(ent->filename) - 1); |
| 4434 | 4434 | } |
| 4435 | 4435 | fname_to_str(buf, iter->catalog[iter->level].files[iter->index[iter->level]].name, 11); |
| 4436 | | strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 4436 | strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1); |
| 4437 | 4437 | } |
| 4438 | 4438 | #endif |
| 4439 | 4439 | /* parse flags */ |
| 4440 | 4440 | if (fdr.flags & fdr99_f_program) |
| 4441 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "PGM%s", |
| 4441 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "PGM%s", |
| 4442 | 4442 | (fdr.flags & fdr99_f_wp) ? " R/O" : ""); |
| 4443 | 4443 | else |
| 4444 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "%c/%c %d%s", |
| 4444 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "%c/%c %d%s", |
| 4445 | 4445 | (fdr.flags & fdr99_f_int) ? 'I' : 'D', |
| 4446 | 4446 | (fdr.flags & fdr99_f_var) ? 'V' : 'F', |
| 4447 | 4447 | fdr.reclen, |
src/mess/tools/imgtool/modules/os9.c
| r6274 | r6275 | |
| 274 | 274 | |
| 275 | 275 | /* read all sector map entries */ |
| 276 | 276 | max_entries = (disk_info->sector_size - 16) / 5; |
| 277 | | max_entries = MIN(max_entries, sizeof(info->sector_map) / sizeof(info->sector_map[0]) - 1); |
| 277 | max_entries = MIN(max_entries, ARRAY_LENGTH(info->sector_map) - 1); |
| 278 | 278 | for (i = 0; i < max_entries; i++) |
| 279 | 279 | { |
| 280 | 280 | lsn = pick_integer_be(header, 16 + (i * 5) + 0, 3); |
| r6274 | r6275 | |
| 392 | 392 | /* first find out the size of our sector map */ |
| 393 | 393 | sector_map_length = 0; |
| 394 | 394 | lsn = 0; |
| 395 | | while((lsn < current_lsn_count) && (sector_map_length < sizeof(file_info->sector_map) / sizeof(file_info->sector_map[0]))) |
| 395 | while((lsn < current_lsn_count) && (sector_map_length < ARRAY_LENGTH(file_info->sector_map))) |
| 396 | 396 | { |
| 397 | 397 | if (file_info->sector_map[sector_map_length].count == 0) |
| 398 | 398 | return os9_corrupt_file_error(file_info); |
| r6274 | r6275 | |
| 433 | 433 | { |
| 434 | 434 | file_info->sector_map[sector_map_length - 1].count++; |
| 435 | 435 | } |
| 436 | | else if (sector_map_length >= sizeof(file_info->sector_map) / sizeof(file_info->sector_map[0])) |
| 436 | else if (sector_map_length >= ARRAY_LENGTH(file_info->sector_map)) |
| 437 | 437 | { |
| 438 | 438 | return IMGTOOLERR_NOSPACE; |
| 439 | 439 | } |
| r6274 | r6275 | |
| 460 | 460 | /* do we have to write the sector map? */ |
| 461 | 461 | if (sector_map_length >= 0) |
| 462 | 462 | { |
| 463 | | for (i = 0; i < MIN(sector_map_length + 1, sizeof(file_info->sector_map) / sizeof(file_info->sector_map[0])); i++) |
| 463 | for (i = 0; i < MIN(sector_map_length + 1, ARRAY_LENGTH(file_info->sector_map)); i++) |
| 464 | 464 | { |
| 465 | 465 | place_integer_be(header, 16 + (i * 5) + 0, 3, file_info->sector_map[i].lsn); |
| 466 | 466 | place_integer_be(header, 16 + (i * 5) + 3, 2, file_info->sector_map[i].count); |
| r6274 | r6275 | |
| 959 | 959 | return err; |
| 960 | 960 | |
| 961 | 961 | /* fill out imgtool_dirent structure */ |
| 962 | | snprintf(ent->filename, sizeof(ent->filename) / sizeof(ent->filename[0]), "%s", filename); |
| 963 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "%c%c%c%c%c%c%c%c", |
| 962 | snprintf(ent->filename, ARRAY_LENGTH(ent->filename), "%s", filename); |
| 963 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "%c%c%c%c%c%c%c%c", |
| 964 | 964 | file_info.directory ? 'd' : '-', |
| 965 | 965 | file_info.non_sharable ? 's' : '-', |
| 966 | 966 | file_info.public_execute ? 'x' : '-', |
| r6274 | r6275 | |
| 1158 | 1158 | if (err) |
| 1159 | 1159 | return err; |
| 1160 | 1160 | |
| 1161 | | for (i = 0; (i < sizeof(file_info.sector_map) / sizeof(file_info.sector_map[0])) && file_info.sector_map[i].count; i++) |
| 1161 | for (i = 0; (i < ARRAY_LENGTH(file_info.sector_map)) && file_info.sector_map[i].count; i++) |
| 1162 | 1162 | { |
| 1163 | 1163 | lsn = file_info.sector_map[i].lsn; |
| 1164 | 1164 | for (j = 0; j < file_info.sector_map[i].count; j++) |
src/mess/tools/imgtool/modules/ti990hd.c
| r6274 | r6275 | |
| 1245 | 1245 | else |
| 1246 | 1246 | { |
| 1247 | 1247 | #if 0 |
| 1248 | | fname_to_str(ent->filename, iter->xdr[iter->level].fdr.fnm, sizeof(ent->filename) / sizeof(ent->filename[0])); |
| 1248 | fname_to_str(ent->filename, iter->xdr[iter->level].fdr.fnm, ARRAY_LENGTH(ent->filename)); |
| 1249 | 1249 | #else |
| 1250 | 1250 | { |
| 1251 | 1251 | int i; |
| r6274 | r6275 | |
| 1255 | 1255 | for (i=0; i<iter->level; i++) |
| 1256 | 1256 | { |
| 1257 | 1257 | fname_to_str(buf, iter->xdr[i].fdr.fnm, 9); |
| 1258 | | strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 1259 | | strncat(ent->filename, ".", sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 1258 | strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1); |
| 1259 | strncat(ent->filename, ".", ARRAY_LENGTH(ent->filename) - 1); |
| 1260 | 1260 | } |
| 1261 | 1261 | fname_to_str(buf, iter->xdr[iter->level].fdr.fnm, 9); |
| 1262 | | strncat(ent->filename, buf, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1); |
| 1262 | strncat(ent->filename, buf, ARRAY_LENGTH(ent->filename) - 1); |
| 1263 | 1263 | } |
| 1264 | 1264 | #endif |
| 1265 | 1265 | |
| r6274 | r6275 | |
| 1267 | 1267 | flag = get_UINT16BE(iter->xdr[iter->level].fdr.flg); |
| 1268 | 1268 | if (flag & fdr_flg_cdr) |
| 1269 | 1269 | { |
| 1270 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "CHANNEL"); |
| 1270 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "CHANNEL"); |
| 1271 | 1271 | |
| 1272 | 1272 | ent->filesize = 0; |
| 1273 | 1273 | } |
| r6274 | r6275 | |
| 1285 | 1285 | |
| 1286 | 1286 | fname_to_str(buf, target_fdr.fnm, 9); |
| 1287 | 1287 | |
| 1288 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), "ALIAS OF %s", buf); |
| 1288 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "ALIAS OF %s", buf); |
| 1289 | 1289 | |
| 1290 | 1290 | ent->filesize = 0; |
| 1291 | 1291 | } |
| r6274 | r6275 | |
| 1335 | 1335 | } |
| 1336 | 1336 | break; |
| 1337 | 1337 | } |
| 1338 | | snprintf(ent->attr, sizeof(ent->attr) / sizeof(ent->attr[0]), |
| 1338 | snprintf(ent->attr, ARRAY_LENGTH(ent->attr), |
| 1339 | 1339 | "%s %c %s%s%s%s%s", fmt, (flag & fdr_flg_all) ? 'N' : 'C', type, |
| 1340 | 1340 | (flag & fdr_flg_blb) ? "" : " BLK", |
| 1341 | 1341 | (flag & fdr_flg_tmp) ? " TMP" : "", |
src/mess/tools/imgtool/modules/mac.c
| r6274 | r6275 | |
| 5371 | 5371 | } |
| 5372 | 5372 | |
| 5373 | 5373 | /* copy info */ |
| 5374 | | mac_to_c_strncpy(ent->filename, sizeof(ent->filename) / sizeof(ent->filename[0]), cur_dir_entry->name); |
| 5374 | mac_to_c_strncpy(ent->filename, ARRAY_LENGTH(ent->filename), cur_dir_entry->name); |
| 5375 | 5375 | ent->filesize = get_UINT32BE(cur_dir_entry->dataPhysicalSize) |
| 5376 | 5376 | + get_UINT32BE(cur_dir_entry->rsrcPhysicalSize); |
| 5377 | 5377 | |
| r6274 | r6275 | |
| 5463 | 5463 | } |
| 5464 | 5464 | |
| 5465 | 5465 | /* initialize file path buffer */ |
| 5466 | | cur_name_head = sizeof(ent->filename) / sizeof(ent->filename[0]); |
| 5466 | cur_name_head = ARRAY_LENGTH(ent->filename); |
| 5467 | 5467 | if (cur_name_head > 0) |
| 5468 | 5468 | { |
| 5469 | 5469 | cur_name_head--; |
| r6274 | r6275 | |
| 5471 | 5471 | } |
| 5472 | 5472 | |
| 5473 | 5473 | /* insert folder/file name in buffer */ |
| 5474 | | mac_to_c_strncpy(ent->filename, sizeof(ent->filename) / sizeof(ent->filename[0]), catrec_key->cName); |
| 5475 | | // concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, buf); |
| 5474 | mac_to_c_strncpy(ent->filename, ARRAY_LENGTH(ent->filename), catrec_key->cName); |
| 5475 | // concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, buf); |
| 5476 | 5476 | |
| 5477 | 5477 | #if 0 |
| 5478 | 5478 | /* extract parent directory ID */ |
| r6274 | r6275 | |
| 5487 | 5487 | if (err) |
| 5488 | 5488 | { |
| 5489 | 5489 | /* error */ |
| 5490 | | concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, ":"); |
| 5491 | | concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, "???"); |
| 5490 | concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, ":"); |
| 5491 | concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, "???"); |
| 5492 | 5492 | |
| 5493 | | memmove(ent->filename, ent->filename+cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - cur_name_head); |
| 5493 | memmove(ent->filename, ent->filename+cur_name_head, ARRAY_LENGTH(ent->filename) - cur_name_head); |
| 5494 | 5494 | ent->corrupt = 1; |
| 5495 | 5495 | return err; |
| 5496 | 5496 | } |
| r6274 | r6275 | |
| 5500 | 5500 | if (dataRecType != hcrt_FolderThread) |
| 5501 | 5501 | { |
| 5502 | 5502 | /* error */ |
| 5503 | | concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0])-1, ":"); |
| 5504 | | concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0])-1, "???"); |
| 5503 | concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename)-1, ":"); |
| 5504 | concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename)-1, "???"); |
| 5505 | 5505 | |
| 5506 | | memmove(ent->filename, ent->filename+cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0])-cur_name_head); |
| 5506 | memmove(ent->filename, ent->filename+cur_name_head, ARRAY_LENGTH(ent->filename)-cur_name_head); |
| 5507 | 5507 | ent->corrupt = 1; |
| 5508 | 5508 | return IMGTOOLERR_CORRUPTIMAGE; |
| 5509 | 5509 | } |
| r6274 | r6275 | |
| 5511 | 5511 | /* got folder thread record: insert the folder name at the start of |
| 5512 | 5512 | file path, then iterate */ |
| 5513 | 5513 | mac_to_c_strncpy(buf, sizeof(buf), catrec_data->thread.nodeName); |
| 5514 | | concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, ":"); |
| 5515 | | concat_fname(ent->filename, &cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) - 1, buf); |
| 5514 | concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, ":"); |
| 5515 | concat_fname(ent->filename, &cur_name_head, ARRAY_LENGTH(ent->filename) - 1, buf); |
| 5516 | 5516 | |
| 5517 | 5517 | /* extract parent directory ID */ |
| 5518 | 5518 | parID = get_UINT32BE(catrec_data->thread.parID); |
| 5519 | 5519 | } |
| 5520 | | memmove(ent->filename, ent->filename+cur_name_head, sizeof(ent->filename) / sizeof(ent->filename[0]) -cur_name_head); |
| 5520 | memmove(ent->filename, ent->filename+cur_name_head, ARRAY_LENGTH(ent->filename) -cur_name_head); |
| 5521 | 5521 | #endif |
| 5522 | 5522 | return IMGTOOLERR_SUCCESS; |
| 5523 | 5523 | } |
| r6274 | r6275 | |
| 6167 | 6167 | const void *fref; |
| 6168 | 6168 | UINT32 resource_length; |
| 6169 | 6169 | |
| 6170 | | assert((sizeof(attrs) / sizeof(attrs[0]) - 1) |
| 6171 | | == (sizeof(attr_values) / sizeof(attr_values[0]))); |
| 6170 | assert((ARRAY_LENGTH(attrs) - 1) |
| 6171 | == ARRAY_LENGTH(attr_values)); |
| 6172 | 6172 | |
| 6173 | 6173 | /* first retrieve type and creator code */ |
| 6174 | 6174 | err = mac_image_getattrs(partition, path, attrs, attr_values); |
src/mess/inputx.c
| r6274 | r6275 | |
| 376 | 376 | static const char_info *find_charinfo(unicode_char target_char) |
| 377 | 377 | { |
| 378 | 378 | int low = 0; |
| 379 | | int high = sizeof(charinfo) / sizeof(charinfo[0]); |
| 379 | int high = ARRAY_LENGTH(charinfo); |
| 380 | 380 | int i; |
| 381 | 381 | unicode_char ch; |
| 382 | 382 | |
| r6274 | r6275 | |
| 592 | 592 | const char_info *ci; |
| 593 | 593 | |
| 594 | 594 | /* check to make sure that charinfo is in order */ |
| 595 | | for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++) |
| 595 | for (i = 0; i < ARRAY_LENGTH(charinfo); i++) |
| 596 | 596 | { |
| 597 | 597 | if (last_char >= charinfo[i].ch) |
| 598 | 598 | { |
| r6274 | r6275 | |
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | /* check to make sure that I can look up everything on alternate_charmap */ |
| 606 | | for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++) |
| 606 | for (i = 0; i < ARRAY_LENGTH(charinfo); i++) |
| 607 | 607 | { |
| 608 | 608 | ci = find_charinfo(charinfo[i].ch); |
| 609 | 609 | if (ci != &charinfo[i]) |
| r6274 | r6275 | |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | keybuf->buffer[keybuf->end_pos++] = ch; |
| 818 | | keybuf->end_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]); |
| 818 | keybuf->end_pos %= ARRAY_LENGTH(keybuf->buffer); |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | |
| r6274 | r6275 | |
| 824 | 824 | { |
| 825 | 825 | key_buffer *keybuf; |
| 826 | 826 | keybuf = get_buffer(machine); |
| 827 | | return ((keybuf->end_pos + 1) % (sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]))) == keybuf->begin_pos; |
| 827 | return ((keybuf->end_pos + 1) % ARRAY_LENGTH(keybuf->buffer)) == keybuf->begin_pos; |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | |
| r6274 | r6275 | |
| 901 | 901 | while((keybuf->begin_pos != keybuf->end_pos) && queue_chars(&keybuf->buffer[keybuf->begin_pos], 1)) |
| 902 | 902 | { |
| 903 | 903 | keybuf->begin_pos++; |
| 904 | | keybuf->begin_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]); |
| 904 | keybuf->begin_pos %= ARRAY_LENGTH(keybuf->buffer); |
| 905 | 905 | |
| 906 | 906 | if (attotime_compare(current_rate, attotime_zero) != 0) |
| 907 | 907 | break; |
| r6274 | r6275 | |
| 914 | 914 | { |
| 915 | 915 | keybuf->status_keydown = FALSE; |
| 916 | 916 | keybuf->begin_pos++; |
| 917 | | keybuf->begin_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]); |
| 917 | keybuf->begin_pos %= ARRAY_LENGTH(keybuf->buffer); |
| 918 | 918 | } |
| 919 | 919 | else |
| 920 | 920 | { |
| r6274 | r6275 | |
| 1106 | 1106 | |
| 1107 | 1107 | if (ch == '{') |
| 1108 | 1108 | { |
| 1109 | | for (j = 0; j < sizeof(codes) / sizeof(codes[0]); j++) |
| 1109 | for (j = 0; j < ARRAY_LENGTH(codes); j++) |
| 1110 | 1110 | { |
| 1111 | 1111 | key_len = strlen(codes[j].key); |
| 1112 | 1112 | if (i + key_len + 2 <= text_len) |
| r6274 | r6275 | |
| 1181 | 1181 | |
| 1182 | 1182 | while(text_len > 0) |
| 1183 | 1183 | { |
| 1184 | | if (len == (sizeof(buf) / sizeof(buf[0]))) |
| 1184 | if (len == ARRAY_LENGTH(buf)) |
| 1185 | 1185 | { |
| 1186 | 1186 | inputx_postn(machine, buf, len); |
| 1187 | 1187 | len = 0; |
| r6274 | r6275 | |
| 1260 | 1260 | |
| 1261 | 1261 | while(text_len > 0) |
| 1262 | 1262 | { |
| 1263 | | if (len == (sizeof(buf) / sizeof(buf[0]))) |
| 1263 | if (len == ARRAY_LENGTH(buf)) |
| 1264 | 1264 | { |
| 1265 | 1265 | inputx_postn(machine, buf, len); |
| 1266 | 1266 | len = 0; |
src/mess/osd/windows/dialog.c
| r6274 | r6275 | |
| 297 | 297 | case WM_COMMAND: |
| 298 | 298 | command = LOWORD(wparam); |
| 299 | 299 | |
| 300 | | win_get_window_text_utf8((HWND) lparam, buf, sizeof(buf) / sizeof(buf[0])); |
| 300 | win_get_window_text_utf8((HWND) lparam, buf, ARRAY_LENGTH(buf)); |
| 301 | 301 | if (!strcmp(buf, DLGTEXT_OK)) |
| 302 | 302 | command = IDOK; |
| 303 | 303 | else if (!strcmp(buf, DLGTEXT_CANCEL)) |
| r6274 | r6275 | |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | |
| 527 | | for (i = 0; i < sizeof(objpool->objects) / sizeof(objpool->objects[0]); i++) |
| 527 | for (i = 0; i < ARRAY_LENGTH(objpool->objects); i++) |
| 528 | 528 | { |
| 529 | 529 | if (!objpool->objects[i]) |
| 530 | 530 | break; |
| 531 | 531 | } |
| 532 | | if (i >= sizeof(objpool->objects) / sizeof(objpool->objects[0])) |
| 532 | if (i >= ARRAY_LENGTH(objpool->objects)) |
| 533 | 533 | return 1; |
| 534 | 534 | |
| 535 | 535 | objpool->objects[i] = obj; |
| r6274 | r6275 | |
| 622 | 622 | static LRESULT dialog_get_adjuster_value(dialog_box *dialog, HWND dialog_item, UINT message, WPARAM wparam, LPARAM lparam) |
| 623 | 623 | { |
| 624 | 624 | TCHAR buf[32]; |
| 625 | | GetWindowText(dialog_item, buf, sizeof(buf) / sizeof(buf[0])); |
| 625 | GetWindowText(dialog_item, buf, ARRAY_LENGTH(buf)); |
| 626 | 626 | return _ttoi(buf); |
| 627 | 627 | } |
| 628 | 628 | |
| r6274 | r6275 | |
| 873 | 873 | id = GetWindowLong(sbwnd, GWL_ID); |
| 874 | 874 | dlgwnd = GetParent(sbwnd); |
| 875 | 875 | editwnd = GetDlgItem(dlgwnd, id - 1); |
| 876 | | win_get_window_text_utf8(editwnd, buf, sizeof(buf) / sizeof(buf[0])); |
| 876 | win_get_window_text_utf8(editwnd, buf, ARRAY_LENGTH(buf)); |
| 877 | 877 | value = atoi(buf); |
| 878 | 878 | |
| 879 | 879 | switch(wparam) |
| r6274 | r6275 | |
| 893 | 893 | value = stuff->min_value; |
| 894 | 894 | else if (value > stuff->max_value) |
| 895 | 895 | value = stuff->max_value; |
| 896 | | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", value); |
| 896 | _snprintf(buf, ARRAY_LENGTH(buf), "%d", value); |
| 897 | 897 | win_set_window_text_utf8(editwnd, buf); |
| 898 | 898 | result = 0; |
| 899 | 899 | } |
| r6274 | r6275 | |
| 958 | 958 | goto error; |
| 959 | 959 | x += dialog->layout->combo_width - DIM_ADJUSTER_SCR_WIDTH; |
| 960 | 960 | |
| 961 | | _sntprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 961 | _sntprintf(buf, ARRAY_LENGTH(buf), |
| 962 | 962 | is_percentage ? TEXT("%d%%") : TEXT("%d"), |
| 963 | 963 | default_value); |
| 964 | 964 | s = win_dialog_tcsdup(dialog, buf); |
| r6274 | r6275 | |
| 1575 | 1575 | objpool = dialog->objpool; |
| 1576 | 1576 | if (objpool) |
| 1577 | 1577 | { |
| 1578 | | for (i = 0; i < sizeof(objpool->objects) / sizeof(objpool->objects[0]); i++) |
| 1578 | for (i = 0; i < ARRAY_LENGTH(objpool->objects); i++) |
| 1579 | 1579 | DeleteObject(objpool->objects[i]); |
| 1580 | 1580 | } |
| 1581 | 1581 | |
src/mess/osd/windows/menu.c
| r6274 | r6275 | |
| 209 | 209 | /* check to see if there is any custom artwork for this configure dialog, |
| 210 | 210 | * and if so, retrieve the info */ |
| 211 | 211 | portslot_count = artwork_get_inputscreen_customizations(&png, cust_type, section, |
| 212 | | customizations, sizeof(customizations) / sizeof(customizations[0])); |
| 212 | customizations, ARRAY_LENGTH(customizations)); |
| 213 | 213 | |
| 214 | 214 | /* zero out the portslots that correspond to customizations */ |
| 215 | 215 | memset(portslots, 0, sizeof(portslots[0]) * portslot_count); |
| r6274 | r6275 | |
| 263 | 263 | * want to reorder the tab order */ |
| 264 | 264 | if (customizations[i].ipt == IPT_END) |
| 265 | 265 | i = portslot_count++; |
| 266 | | if (i < (sizeof(portslots) / sizeof(portslots[0]))) |
| 266 | if (i < ARRAY_LENGTH(portslots)) |
| 267 | 267 | { |
| 268 | 268 | portslots[i].field = field; |
| 269 | 269 | portslots[i].pr = pr; |
| r6274 | r6275 | |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /* finally add the portselects to the dialog */ |
| 277 | | if (portslot_count > (sizeof(portslots) / sizeof(portslots[0]))) |
| 278 | | portslot_count = sizeof(portslots) / sizeof(portslots[0]); |
| 277 | if (portslot_count > ARRAY_LENGTH(portslots)) |
| 278 | portslot_count = ARRAY_LENGTH(portslots); |
| 279 | 279 | for (i = 0; i < portslot_count; i++) |
| 280 | 280 | { |
| 281 | 281 | if (portslots[i].field) |
| r6274 | r6275 | |
| 528 | 528 | input_field_get_user_settings(field, &settings); |
| 529 | 529 | name = input_field_name(field); |
| 530 | 530 | |
| 531 | | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 531 | _snprintf(buf, ARRAY_LENGTH(buf), |
| 532 | 532 | "%s %s", name, ui_getstring(UI_keyjoyspeed)); |
| 533 | 533 | if (win_dialog_add_adjuster(dlg, buf, settings.delta, 1, 255, FALSE, store_delta, (void *) field)) |
| 534 | 534 | goto done; |
| 535 | 535 | |
| 536 | | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 536 | _snprintf(buf, ARRAY_LENGTH(buf), |
| 537 | 537 | "%s %s", name, ui_getstring(UI_centerspeed)); |
| 538 | 538 | if (win_dialog_add_adjuster(dlg, buf, settings.centerdelta, 1, 255, FALSE, store_centerdelta, (void *) field)) |
| 539 | 539 | goto done; |
| 540 | 540 | |
| 541 | | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 541 | _snprintf(buf, ARRAY_LENGTH(buf), |
| 542 | 542 | "%s %s", name, ui_getstring(UI_reverse)); |
| 543 | 543 | if (win_dialog_add_combobox(dlg, buf, settings.reverse ? 1 : 0, store_reverse, (void *) field)) |
| 544 | 544 | goto done; |
| r6274 | r6275 | |
| 547 | 547 | if (win_dialog_add_combobox_item(dlg, ui_getstring(UI_on), 1)) |
| 548 | 548 | goto done; |
| 549 | 549 | |
| 550 | | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), |
| 550 | _snprintf(buf, ARRAY_LENGTH(buf), |
| 551 | 551 | "%s %s", name, ui_getstring(UI_sensitivity)); |
| 552 | 552 | if (win_dialog_add_adjuster(dlg, buf, settings.sensitivity, 1, 255, TRUE, store_sensitivity, (void *) field)) |
| 553 | 553 | goto done; |
| r6274 | r6275 | |
| 587 | 587 | } |
| 588 | 588 | else |
| 589 | 589 | { |
| 590 | | snprintf(state_filename, sizeof(state_filename) / sizeof(state_filename[0]), |
| 590 | snprintf(state_filename, ARRAY_LENGTH(state_filename), |
| 591 | 591 | "%s State.sta", machine->gamedrv->description); |
| 592 | 592 | dir = NULL; |
| 593 | 593 | |
| r6274 | r6275 | |
| 685 | 685 | while((wnd = FindWindowEx(dlgwnd, wnd, NULL, NULL)) != NULL) |
| 686 | 686 | { |
| 687 | 687 | // get label text, removing trailing NULL |
| 688 | | GetWindowText(wnd, t_buf1, sizeof(t_buf1) / sizeof(t_buf1[0])); |
| 688 | GetWindowText(wnd, t_buf1, ARRAY_LENGTH(t_buf1)); |
| 689 | 689 | buf1 = utf8_from_tstring(t_buf1); |
| 690 | 690 | assert(buf1[strlen(buf1)-1] == ':'); |
| 691 | 691 | buf1[strlen(buf1)-1] = '\0'; |
| r6274 | r6275 | |
| 746 | 746 | *(params->fdparams->create_args) = resolution; |
| 747 | 747 | } |
| 748 | 748 | |
| 749 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", val); |
| 749 | snprintf(buf, ARRAY_LENGTH(buf), "%d", val); |
| 750 | 750 | option_resolution_add_param(resolution, params->guide_entry->identifier, buf); |
| 751 | 751 | } |
| 752 | 752 | |
| r6274 | r6275 | |
| 817 | 817 | switch(guide_entry->option_type) |
| 818 | 818 | { |
| 819 | 819 | case OPTIONTYPE_INT: |
| 820 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s:", guide_entry->display_name); |
| 820 | snprintf(buf, ARRAY_LENGTH(buf), "%s:", guide_entry->display_name); |
| 821 | 821 | if (win_dialog_add_combobox(dialog, buf, 0, storeval_option_resolution, storeval_params)) |
| 822 | 822 | goto error; |
| 823 | 823 | break; |
| r6274 | r6275 | |
| 977 | 977 | && (image_device_get_creation_option_guide(device) != NULL) |
| 978 | 978 | && (image_device_get_creatable_formats(device) != NULL)) |
| 979 | 979 | { |
| 980 | | dialog = build_option_dialog(device, filter, sizeof(filter) / sizeof(filter[0]), &create_format, &create_args); |
| 980 | dialog = build_option_dialog(device, filter, ARRAY_LENGTH(filter), &create_format, &create_args); |
| 981 | 981 | if (!dialog) |
| 982 | 982 | goto done; |
| 983 | 983 | } |
| 984 | 984 | else |
| 985 | 985 | { |
| 986 | 986 | // build a normal filter |
| 987 | | build_generic_filter(device, is_save, filter, sizeof(filter) / sizeof(filter[0])); |
| 987 | build_generic_filter(device, is_save, filter, ARRAY_LENGTH(filter)); |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | // display the dialog |
| 991 | 991 | result = win_file_dialog(device->machine, wnd, is_save ? WIN_FILE_DIALOG_SAVE : WIN_FILE_DIALOG_OPEN, |
| 992 | | dialog, filter, initial_dir, filename, sizeof(filename) / sizeof(filename[0])); |
| 992 | dialog, filter, initial_dir, filename, ARRAY_LENGTH(filename)); |
| 993 | 993 | if (result) |
| 994 | 994 | { |
| 995 | 995 | // mount the image |
| r6274 | r6275 | |
| 1251 | 1251 | { |
| 1252 | 1252 | for (i = 0; i < joystick_count; i++) |
| 1253 | 1253 | { |
| 1254 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "Joystick %i", i + 1); |
| 1254 | snprintf(buf, ARRAY_LENGTH(buf), "Joystick %i", i + 1); |
| 1255 | 1255 | append_menu_utf8(joystick_menu, MF_STRING, ID_JOYSTICK_0 + i, buf); |
| 1256 | 1256 | child_count++; |
| 1257 | 1257 | } |
| r6274 | r6275 | |
| 1485 | 1485 | s = image_exists(img) ? image_filename(img) : ui_getstring(UI_emptyslot); |
| 1486 | 1486 | flags = MF_POPUP; |
| 1487 | 1487 | |
| 1488 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%s: %s", image_typename_id(img), s); |
| 1488 | snprintf(buf, ARRAY_LENGTH(buf), "%s: %s", image_typename_id(img), s); |
| 1489 | 1489 | append_menu_utf8(device_menu, flags, (UINT_PTR) sub_menu, buf); |
| 1490 | 1490 | } |
| 1491 | 1491 | } |
| r6274 | r6275 | |
| 1675 | 1675 | static void help_about_thissystem(running_machine *machine, HWND wnd) |
| 1676 | 1676 | { |
| 1677 | 1677 | char buf[256]; |
| 1678 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "mess.chm::/sysinfo/%s.htm", machine->gamedrv->name); |
| 1678 | snprintf(buf, ARRAY_LENGTH(buf), "mess.chm::/sysinfo/%s.htm", machine->gamedrv->name); |
| 1679 | 1679 | help_display(wnd, buf); |
| 1680 | 1680 | } |
| 1681 | 1681 | |
| r6274 | r6275 | |
| 2031 | 2031 | |
| 2032 | 2032 | // get the device icons |
| 2033 | 2033 | memset(device_icons, 0, sizeof(device_icons)); |
| 2034 | | for (i = 0; i < sizeof(bitmap_ids) / sizeof(bitmap_ids[0]); i++) |
| 2034 | for (i = 0; i < ARRAY_LENGTH(bitmap_ids); i++) |
| 2035 | 2035 | device_icons[bitmap_ids[i][0]] = LoadIcon(module, MAKEINTRESOURCE(bitmap_ids[i][1])); |
| 2036 | 2036 | |
| 2037 | 2037 | // remove the profiler menu item if it doesn't exist |
| r6274 | r6275 | |
| 2058 | 2058 | return 1; |
| 2059 | 2059 | for(i = 0; i < frameskip_level_count(); i++) |
| 2060 | 2060 | { |
| 2061 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%i", i); |
| 2061 | snprintf(buf, ARRAY_LENGTH(buf), "%i", i); |
| 2062 | 2062 | append_menu_utf8(frameskip_menu, MF_STRING, ID_FRAMESKIP_0 + i, buf); |
| 2063 | 2063 | } |
| 2064 | 2064 | |
| 2065 | 2065 | // set the help menu to refer to this machine |
| 2066 | | snprintf(buf, sizeof(buf) / sizeof(buf[0]), "About %s (%s)...", machine->gamedrv->description, machine->gamedrv->name); |
| 2066 | snprintf(buf, ARRAY_LENGTH(buf), "About %s (%s)...", machine->gamedrv->description, machine->gamedrv->name); |
| 2067 | 2067 | set_menu_text(menu_bar, ID_HELP_ABOUTSYSTEM, buf); |
| 2068 | 2068 | return 0; |
| 2069 | 2069 | } |
src/mess/osd/windows/opcntrl.c
| r6274 | r6275 | |
| 32 | 32 | int count = 0, i; |
| 33 | 33 | |
| 34 | 34 | option_resolution_listranges(optspec, guide->parameter, |
| 35 | | ranges, sizeof(ranges) / sizeof(ranges[0])); |
| 35 | ranges, ARRAY_LENGTH(ranges)); |
| 36 | 36 | |
| 37 | 37 | for (i = 0; ranges[i].min >= 0; i++) |
| 38 | 38 | count += ranges[i].max - ranges[i].min + 1; |
| r6274 | r6275 | |
| 62 | 62 | goto unexpected; |
| 63 | 63 | |
| 64 | 64 | option_resolution_listranges(optspec, guide->parameter, |
| 65 | | ranges, sizeof(ranges) / sizeof(ranges[0])); |
| 65 | ranges, ARRAY_LENGTH(ranges)); |
| 66 | 66 | option_resolution_getdefault(optspec, guide->parameter, &default_value); |
| 67 | 67 | |
| 68 | 68 | option_count = 0; |
| r6274 | r6275 | |
| 75 | 75 | { |
| 76 | 76 | if (guide->option_type == OPTIONTYPE_INT) |
| 77 | 77 | { |
| 78 | | _sntprintf(buf2, sizeof(buf2) / sizeof(buf2[0]), TEXT("%d"), j); |
| 78 | _sntprintf(buf2, ARRAY_LENGTH(buf2), TEXT("%d"), j); |
| 79 | 79 | SendMessage(control, CB_ADDSTRING, 0, (LPARAM) buf2); |
| 80 | 80 | } |
| 81 | 81 | else if (guide->option_type == OPTIONTYPE_ENUM_BEGIN) |
| r6274 | r6275 | |
| 157 | 157 | err = option_resolution_getdefault(optspec, guide->parameter, &val); |
| 158 | 158 | if (err) |
| 159 | 159 | goto done; |
| 160 | | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", val); |
| 160 | _snprintf(buf, ARRAY_LENGTH(buf), "%d", val); |
| 161 | 161 | break; |
| 162 | 162 | |
| 163 | 163 | default: |
| r6274 | r6275 | |
| 194 | 194 | guide = (const option_guide *) GetProp(control, guide_prop); |
| 195 | 195 | optspec = (const char *) GetProp(control, spec_prop); |
| 196 | 196 | |
| 197 | | win_get_window_text_utf8(control, buf, sizeof(buf) / sizeof(buf[0])); |
| 197 | win_get_window_text_utf8(control, buf, ARRAY_LENGTH(buf)); |
| 198 | 198 | |
| 199 | 199 | switch(guide->option_type) |
| 200 | 200 | { |
| r6274 | r6275 | |
| 205 | 205 | { |
| 206 | 206 | h = GetProp(control, value_prop); |
| 207 | 207 | val = (FPTR) h; |
| 208 | | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", val); |
| 208 | _snprintf(buf, ARRAY_LENGTH(buf), "%d", val); |
| 209 | 209 | win_set_window_text_utf8(control, buf); |
| 210 | 210 | } |
| 211 | 211 | else |
| r6274 | r6275 | |
| 283 | 283 | return TRUE; |
| 284 | 284 | |
| 285 | 285 | option_resolution_listranges(optspec, guide->parameter, |
| 286 | | ranges, sizeof(ranges) / sizeof(ranges[0])); |
| 286 | ranges, ARRAY_LENGTH(ranges)); |
| 287 | 287 | |
| 288 | | win_get_window_text_utf8(control, buf, sizeof(buf) / sizeof(buf[0])); |
| 288 | win_get_window_text_utf8(control, buf, ARRAY_LENGTH(buf)); |
| 289 | 289 | original_val = atoi(buf); |
| 290 | 290 | val = original_val + delta; |
| 291 | 291 | |
| r6274 | r6275 | |
| 306 | 306 | |
| 307 | 307 | if (val != original_val) |
| 308 | 308 | { |
| 309 | | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), "%d", val); |
| 309 | _snprintf(buf, ARRAY_LENGTH(buf), "%d", val); |
| 310 | 310 | win_set_window_text_utf8(control, buf); |
| 311 | 311 | } |
| 312 | 312 | return TRUE; |
| r6274 | r6275 | |
| 323 | 323 | const char *old_text; |
| 324 | 324 | int i; |
| 325 | 325 | |
| 326 | | if (!win_get_window_text_utf8(control, buf, sizeof(buf) / sizeof(buf[0]))) |
| 326 | if (!win_get_window_text_utf8(control, buf, ARRAY_LENGTH(buf))) |
| 327 | 327 | { |
| 328 | 328 | err = OPTIONRESOLTUION_ERROR_INTERNAL; |
| 329 | 329 | return err; |
src/mess/osd/winui/messui.c
| r6274 | r6275 | |
| 282 | 282 | { |
| 283 | 283 | for (drv = drivers[drvindex]; drv; drv = driver_get_clone(drv)) |
| 284 | 284 | { |
| 285 | | _snprintf(buffer, sizeof(buffer) / sizeof(buffer[0]), "%s/%s", drv->name, iconname); |
| 285 | _snprintf(buffer, ARRAY_LENGTH(buffer), "%s/%s", drv->name, iconname); |
| 286 | 286 | hIcon = LoadIconFromFile(buffer); |
| 287 | 287 | if (hIcon) |
| 288 | 288 | break; |
| r6274 | r6275 | |
| 433 | 433 | pszSoftware = GetSelectedSoftware(drvindex, config, dev); |
| 434 | 434 | if (!pszSoftware || !*pszSoftware) |
| 435 | 435 | { |
| 436 | | snprintf(szMessage, sizeof(szMessage) / sizeof(szMessage[0]), |
| 436 | snprintf(szMessage, ARRAY_LENGTH(szMessage), |
| 437 | 437 | "System '%s' requires that device %s must have an image to load\n", |
| 438 | 438 | drivers[drvindex]->description, |
| 439 | 439 | device_typename(info.type)); |
| r6274 | r6275 | |
| 815 | 815 | // allocate the machine config |
| 816 | 816 | config = machine_config_alloc_with_mess_devices(drivers[drvindex]); |
| 817 | 817 | |
| 818 | | SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev); |
| 818 | SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev); |
| 819 | 819 | |
| 820 | 820 | if (CommonFileImageDialog(last_directory, cfd, filename, config, imagetypes)) |
| 821 | 821 | { |
| r6274 | r6275 | |
| 911 | 911 | } |
| 912 | 912 | |
| 913 | 913 | astring_free(as); |
| 914 | | SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev); |
| 914 | SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev); |
| 915 | 915 | bResult = CommonFileImageDialog(s, GetOpenFileName, pszFilename, config, imagetypes); |
| 916 | 916 | |
| 917 | 917 | return bResult; |
| r6274 | r6275 | |
| 972 | 972 | |
| 973 | 973 | astring_free(as); |
| 974 | 974 | |
| 975 | | SetupImageTypes(config, imagetypes, sizeof(imagetypes) / sizeof(imagetypes[0]), TRUE, dev); |
| 975 | SetupImageTypes(config, imagetypes, ARRAY_LENGTH(imagetypes), TRUE, dev); |
| 976 | 976 | bResult = CommonFileImageDialog(s, GetSaveFileName, pszFilename, config, imagetypes); |
| 977 | 977 | |
| 978 | 978 | return bResult; |
| r6274 | r6275 | |
| 1104 | 1104 | MessSpecifyImage(drvindex, NULL, pszFullName); |
| 1105 | 1105 | |
| 1106 | 1106 | // Set up s_szSelecteItem, for the benefit of UpdateScreenShot() |
| 1107 | | strncpyz(g_szSelectedItem, pszName, sizeof(g_szSelectedItem) / sizeof(g_szSelectedItem[0])); |
| 1107 | strncpyz(g_szSelectedItem, pszName, ARRAY_LENGTH(g_szSelectedItem)); |
| 1108 | 1108 | s = strrchr(g_szSelectedItem, '.'); |
| 1109 | 1109 | if (s) |
| 1110 | 1110 | *s = '\0'; |
| r6274 | r6275 | |
| 1355 | 1355 | |
| 1356 | 1356 | memset(&opts, 0, sizeof(opts)); |
| 1357 | 1357 | opts.pCallbacks = &s_softwareTabViewCallbacks; |
| 1358 | | opts.nTabCount = sizeof(s_tabs) / sizeof(s_tabs[0]); |
| 1358 | opts.nTabCount = ARRAY_LENGTH(s_tabs); |
| 1359 | 1359 | |
| 1360 | 1360 | SetupTabView(GetDlgItem(GetMainWindow(), IDC_SWTAB), &opts); |
| 1361 | 1361 | } |
src/mess/formats/ap_dsk35.c
| r6274 | r6275 | |
| 200 | 200 | int sectors; |
| 201 | 201 | |
| 202 | 202 | assert(track >= 0); |
| 203 | | assert(track < sizeof(apple35_tracklen_800kb) / sizeof(apple35_tracklen_800kb[0])); |
| 203 | assert(track < ARRAY_LENGTH(apple35_tracklen_800kb)); |
| 204 | 204 | |
| 205 | 205 | if (get_apple35_tag(image)->is_1440k) |
| 206 | 206 | sectors = 18; |
| r6274 | r6275 | |
| 426 | 426 | |
| 427 | 427 | tag = get_apple35_tag(floppy); |
| 428 | 428 | |
| 429 | | if (track >= (sizeof(apple35_tracklen_800kb) / sizeof(apple35_tracklen_800kb[0]))) |
| 429 | if (track >= ARRAY_LENGTH(apple35_tracklen_800kb)) |
| 430 | 430 | return ~0; |
| 431 | 431 | if (head >= tag->sides) |
| 432 | 432 | return ~0; |
| r6274 | r6275 | |
| 576 | 576 | |
| 577 | 577 | tag = get_apple35_tag(floppy); |
| 578 | 578 | |
| 579 | | if (track >= (sizeof(apple35_tracklen_800kb) / sizeof(apple35_tracklen_800kb[0]))) |
| 579 | if (track >= ARRAY_LENGTH(apple35_tracklen_800kb)) |
| 580 | 580 | return FLOPPY_ERROR_SEEKERROR; |
| 581 | 581 | if (offset != 0) |
| 582 | 582 | return FLOPPY_ERROR_UNSUPPORTED; |
| r6274 | r6275 | |
| 588 | 588 | for (sector = 0; sector < sector_count; sector++) |
| 589 | 589 | { |
| 590 | 590 | /* read the sector */ |
| 591 | | err = apple35_read_sector_td(floppy, head, track, sector, sector_data, sizeof(sector_data) / sizeof(sector_data[0])); |
| 591 | err = apple35_read_sector_td(floppy, head, track, sector, sector_data, ARRAY_LENGTH(sector_data)); |
| 592 | 592 | if (err) |
| 593 | 593 | return err; |
| 594 | 594 | sony_nibblize35(sector_data, nibble_data, checksum); |
| 595 | 595 | |
| 596 | | for (i = 0; i < (sizeof(blk1) / sizeof(blk1[0])); i++) |
| 596 | for (i = 0; i < ARRAY_LENGTH(blk1); i++) |
| 597 | 597 | sony_filltrack(buffer, buflen, &pos, blk1[i]); |
| 598 | 598 | |
| 599 | 599 | sum = (track ^ sector ^ side ^ tag->format_byte) & 0x3F; |
| r6274 | r6275 | |
| 604 | 604 | sony_filltrack(buffer, buflen, &pos, diskbytes[tag->format_byte]); |
| 605 | 605 | sony_filltrack(buffer, buflen, &pos, diskbytes[sum]); |
| 606 | 606 | |
| 607 | | for (i = 0; i < (sizeof(blk2) / sizeof(blk2[0])); i++) |
| 607 | for (i = 0; i < ARRAY_LENGTH(blk2); i++) |
| 608 | 608 | sony_filltrack(buffer, buflen, &pos, blk2[i]); |
| 609 | 609 | |
| 610 | 610 | sony_filltrack(buffer, buflen, &pos, diskbytes[sector]); |
| 611 | 611 | |
| 612 | | for (i = 0; i < (sizeof(nibble_data) / sizeof(nibble_data[0])); i++) |
| 612 | for (i = 0; i < ARRAY_LENGTH(nibble_data); i++) |
| 613 | 613 | sony_filltrack(buffer, buflen, &pos, diskbytes[nibble_data[i]]); |
| 614 | 614 | |
| 615 | 615 | for (i = 3; i >= 0; i--) |
| 616 | 616 | sony_filltrack(buffer, buflen, &pos, diskbytes[checksum[i]]); |
| 617 | 617 | |
| 618 | | for (i = 0; i < (sizeof(blk3) / sizeof(blk3[0])); i++) |
| 618 | for (i = 0; i < ARRAY_LENGTH(blk3); i++) |
| 619 | 619 | sony_filltrack(buffer, buflen, &pos, blk3[i]); |
| 620 | 620 | } |
| 621 | 621 | return FLOPPY_ERROR_SUCCESS; |
| r6274 | r6275 | |
| 637 | 637 | |
| 638 | 638 | tag = get_apple35_tag(floppy); |
| 639 | 639 | |
| 640 | | if (track >= (sizeof(apple35_tracklen_800kb) / sizeof(apple35_tracklen_800kb[0]))) |
| 640 | if (track >= ARRAY_LENGTH(apple35_tracklen_800kb)) |
| 641 | 641 | return FLOPPY_ERROR_SEEKERROR; |
| 642 | 642 | if (offset != 0) |
| 643 | 643 | return FLOPPY_ERROR_UNSUPPORTED; |
| r6274 | r6275 | |
| 712 | 712 | continue; |
| 713 | 713 | j++; |
| 714 | 714 | |
| 715 | | for (i = 0; i < (sizeof(nibble_data) / sizeof(nibble_data[0])); i++) |
| 715 | for (i = 0; i < ARRAY_LENGTH(nibble_data); i++) |
| 716 | 716 | { |
| 717 | 717 | nibble_data[i] = rev_diskbytes[sony_fetchtrack(buffer, buflen, &pos)]; |
| 718 | 718 | j++; |
| r6274 | r6275 | |
| 734 | 734 | sony_denibblize35(sector_data, nibble_data, checksum); |
| 735 | 735 | |
| 736 | 736 | /* write the sector */ |
| 737 | | err = apple35_write_sector_td(floppy, head, track, sector, sector_data, sizeof(sector_data) / sizeof(sector_data[0]), 0); |
| 737 | err = apple35_write_sector_td(floppy, head, track, sector, sector_data, ARRAY_LENGTH(sector_data), 0); |
| 738 | 738 | if (err) |
| 739 | 739 | return err; |
| 740 | 740 | |