fork of PCE focusing on macplus, supporting DaynaPort SCSI network emulation
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

pfi: Specify slack space in miliseconds

+75 -27
+7 -3
src/utils/pfi/encode.c
··· 5 5 /***************************************************************************** 6 6 * File name: src/utils/pfi/encode.c * 7 7 * Created: 2014-01-03 by Hampa Hug <hampa@hampa.ch> * 8 - * Copyright: (C) 2014-2017 Hampa Hug <hampa@hampa.ch> * 8 + * Copyright: (C) 2014-2021 Hampa Hug <hampa@hampa.ch> * 9 9 *****************************************************************************/ 10 10 11 11 /***************************************************************************** ··· 39 39 unsigned long i, j, n; 40 40 unsigned long dclk, sclk; 41 41 unsigned long val, rem, cnt, tmp; 42 + unsigned long s1, s2; 42 43 const unsigned char *s; 43 44 44 45 pfi_trk_reset (dtrk); ··· 47 48 sclk = strk->clock; 48 49 dclk = dtrk->clock; 49 50 50 - j = ((100 - (par_slack1 % 100)) * strk->size) / 100; 51 + s1 = (unsigned long) (par_slack1 * strk->clock + 0.5); 52 + s2 = (unsigned long) (par_slack2 * strk->clock + 0.5); 53 + 54 + j = (strk->size - s1 % strk->size) % strk->size; 51 55 n = par_revolution * strk->size; 52 - n += ((par_slack1 + par_slack2) * strk->size + 99) / 100; 56 + n += s1 + s2; 53 57 s = strk->data; 54 58 55 59 cnt = 0;
+49 -10
src/utils/pfi/main.c
··· 65 65 66 66 unsigned par_revolution = 1; 67 67 68 - unsigned par_slack1 = 10; 69 - unsigned par_slack2 = 10; 68 + double par_slack1 = 0.01; 69 + double par_slack2 = 0.01; 70 70 71 71 int par_weak_bits = 0; 72 72 unsigned long par_weak_i1 = 0; ··· 142 142 " set-rpm-mac Set Macintosh RPMs at 500 kbit/s\n" 143 143 " set-rpm-mac-490 Set Macintosh RPMs at 489.6 kbit/s\n" 144 144 " set-rpm-mac-500 Set Macintosh RPMs at 500 kbit/s\n" 145 + " slack <ms> Limit the slack space\n" 145 146 " shift-index <offset> Shift the index by offset clock cycles\n" 146 147 " shift-index-us <us> Shift the index by us microseconds\n" 147 148 " wpcom Simulate write precompensation\n" ··· 340 341 } 341 342 342 343 if (*str != 0) { 344 + return (1); 345 + } 346 + 347 + return (0); 348 + } 349 + 350 + int pfi_parse_time (const char *str, double *val, double def) 351 + { 352 + char *end; 353 + 354 + if ((str == NULL) || (*str == 0)) { 355 + fprintf (stderr, "%s: bad value (%s)\n", arg0, str); 356 + return (1); 357 + } 358 + 359 + *val = strtod (str, &end); 360 + 361 + if (end == NULL) { 362 + fprintf (stderr, "%s: bad value (%s)\n", arg0, str); 363 + return (1); 364 + } 365 + 366 + while ((*end == ' ') || (*end == '\t')) { 367 + end += 1; 368 + } 369 + 370 + if (*end == 0) { 371 + *val *= def; 372 + } 373 + else if (strcmp (end, "s") == 0) { 374 + ; 375 + } 376 + else if (strcmp (end, "ms") == 0) { 377 + *val /= 1000.0; 378 + } 379 + else if (strcmp (end, "us") == 0) { 380 + *val /= 1000.0 * 1000.0; 381 + } 382 + else if (strcmp (end, "ns") == 0) { 383 + *val /= 1000.0 * 1000.0 * 1000.0; 384 + } 385 + else { 386 + fprintf (stderr, "%s: bad value (%s)\n", arg0, str); 343 387 return (1); 344 388 } 345 389 ··· 728 772 } 729 773 } 730 774 else if (strcmp (name, "slack") == 0) { 731 - if (pfi_parse_uint (val, &par_slack1)) { 775 + if (pfi_parse_time (val, &par_slack1, 0.001)) { 732 776 return (1); 733 777 } 734 778 735 - par_slack1 %= 100; 736 779 par_slack2 = par_slack1; 737 780 } 738 781 else if (strcmp (name, "slack1") == 0) { 739 - if (pfi_parse_uint (val, &par_slack1)) { 782 + if (pfi_parse_time (val, &par_slack1, 0.001)) { 740 783 return (1); 741 784 } 742 - 743 - par_slack1 %= 100; 744 785 } 745 786 else if (strcmp (name, "slack2") == 0) { 746 - if (pfi_parse_uint (val, &par_slack2)) { 787 + if (pfi_parse_time (val, &par_slack2, 0.001)) { 747 788 return (1); 748 789 } 749 - 750 - par_slack2 %= 100; 751 790 } 752 791 else if (strcmp (name, "weak-bits") == 0) { 753 792 if (pfi_parse_bool (val, &par_weak_bits)) {
+3 -2
src/utils/pfi/main.h
··· 47 47 48 48 extern unsigned par_revolution; 49 49 50 - extern unsigned par_slack1; 51 - extern unsigned par_slack2; 50 + extern double par_slack1; 51 + extern double par_slack2; 52 52 53 53 extern int par_weak_bits; 54 54 extern unsigned long par_weak_i1; ··· 72 72 int pfi_parse_uint (const char *str, unsigned *val); 73 73 int pfi_parse_bool (const char *str, int *val); 74 74 int pfi_parse_rate (const char *str, unsigned long *val); 75 + int pfi_parse_time (const char *str, double *val, double def); 75 76 76 77 int pfi_for_all_tracks (pfi_img_t *img, pfi_trk_cb fct, void *opaque); 77 78 int pfi_parse_range (const char *str, unsigned long *v1, unsigned long *v2, char *all);
+6 -6
src/utils/pfi/pfi.1
··· 1 - .TH PFI 1 "2021-06-18" "HH" "pce" 1 + .TH PFI 1 "2021-12--4" "HH" "pce" 2 2 \ 3 3 .SH NAME 4 4 pfi \- convert and modify PFI flux images ··· 193 193 .BI "shift-index-us " "us" 194 194 Add \fIus\fR microseconds to all index positions. 195 195 .TP 196 - .BI "slack " percentage 197 - Limit the slack data before the first and after the last index to at 198 - most \fIpercentage\fR percent of a full revolution. 196 + .BI "slack " ms 197 + Limit the slack data before the first and after the last index to 198 + \fIms\fR miliseconds. 199 199 .TP 200 200 .BI wpcom 201 201 Simulate write precompensation. ··· 266 266 .TP 267 267 .B slack1 268 268 When extracting revolutions using the \fBrevolutions\fR operation include 269 - this much slack space before the first index. The value specifies a percentage 270 - of a complete revolution. The default is 10. 269 + this much slack space before the first index. The value is in miliseconds. 270 + The default is 10. 271 271 .TP 272 272 .B slack2 273 273 The amount of slack space after the last index. The default is 10.
+10 -6
src/utils/pfi/track-edit.c
··· 112 112 pos1 = trk->index[rev1 - 1]; 113 113 pos2 = trk->index[rev2]; 114 114 115 - add1 = (par_slack1 * (trk->index[rev1] - trk->index[rev1 - 1])) / 100; 116 - add2 = (par_slack2 * (trk->index[rev2] - trk->index[rev2 - 1])) / 100; 115 + add1 = (unsigned long) (par_slack1 * trk->clock + 0.5); 116 + add2 = (unsigned long) (par_slack2 * trk->clock + 0.5); 117 117 118 118 pos1 = (pos1 < add1) ? 0 : (pos1 - add1); 119 119 pos2 = pos2 + add2; ··· 130 130 clk2 = 0; 131 131 132 132 while ((clk1 < pos2) && (pfi_trk_get_pulse (trk, &pulse, &index) == 0)) { 133 - if ((clk1 >= pos1) && (clk1 < pos2)) { 133 + if (pulse == 0) { 134 + pfi_trk_add_index (dst, clk2 + index); 135 + break; 136 + } 137 + 138 + if (((clk1 + pulse) > pos1) && (clk1 < pos2)) { 134 139 pfi_trk_add_pulse (dst, pulse); 135 140 136 - if ((pulse == 0) || (index < pulse)) { 141 + if (index < pulse) { 137 142 pfi_trk_add_index (dst, clk2 + index); 138 143 } 139 144 ··· 173 178 { 174 179 unsigned revs[2]; 175 180 176 - if (pfi_parse_uint (str, &par_slack1)) { 181 + if (pfi_parse_time (str, &par_slack1, 0.001)) { 177 182 return (1); 178 183 } 179 184 180 - par_slack1 %= 100; 181 185 par_slack2 = par_slack1; 182 186 183 187 revs[0] = 0;