1 /*
2 * Copyright (c) Tony Bybell 1999-2016.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 */
9
10 #include "globals.h"
11 #include <config.h>
12 #include <gtk/gtk.h>
13 #include "currenttime.h"
14 #include "symbol.h"
15
16 static char *time_prefix=WAVE_SI_UNITS;
17
18 static char *maxtime_label_text="Maximum Time";
19 static char *marker_label_text ="Marker Time";
20
21 static char *maxtime_label_text_hpos="Max";
22 static char *marker_label_text_hpos ="Marker";
23
24
fractional_timescale_fix(char * s)25 void fractional_timescale_fix(char *s)
26 {
27 char buf[32], sfx[2];
28 int i, len;
29 int prefix_idx = 0;
30
31 if(*s != '0') return;
32
33 len = strlen(s);
34 for(i=0;i<len;i++)
35 {
36 if((s[i]!='0')&&(s[i]!='1')&&(s[i]!='.'))
37 {
38 buf[i] = 0;
39 prefix_idx=i;
40 break;
41 }
42 else
43 {
44 buf[i] = s[i];
45 }
46 }
47
48 if(!strcmp(buf, "0.1"))
49 {
50 strcpy(buf, "100");
51 }
52 else if(!strcmp(buf, "0.01"))
53 {
54 strcpy(buf, "10");
55 }
56 else if(!strcmp(buf, "0.001"))
57 {
58 strcpy(buf, "1");
59 }
60 else
61 {
62 return;
63 }
64
65 len = strlen(WAVE_SI_UNITS);
66 for(i=0;i<len-1;i++)
67 {
68 if(s[prefix_idx] == WAVE_SI_UNITS[i]) break;
69 }
70
71 sfx[0] = WAVE_SI_UNITS[i+1];
72 sfx[1] = 0;
73 strcat(buf, sfx);
74 strcat(buf, "s");
75 /* printf("old time: '%s', new time: '%s'\n", s, buf); */
76 strcpy(s, buf);
77 }
78
79
update_maxmarker_labels(void)80 void update_maxmarker_labels(void)
81 {
82 if(GLOBALS->use_maxtime_display)
83 {
84 gtk_label_set(GTK_LABEL(GLOBALS->max_or_marker_label_currenttime_c_1),
85 (!GLOBALS->use_toolbutton_interface) ? maxtime_label_text : maxtime_label_text_hpos);
86 update_maxtime(GLOBALS->max_time);
87 }
88 else
89 {
90 gtk_label_set(GTK_LABEL(GLOBALS->max_or_marker_label_currenttime_c_1),
91 (!GLOBALS->use_toolbutton_interface) ? marker_label_text : marker_label_text_hpos);
92 update_markertime(GLOBALS->tims.marker);
93 }
94 }
95
96 /* handles floating point values with units */
unformat_time_complex(const char * s,char dim)97 static TimeType unformat_time_complex(const char *s, char dim)
98 {
99 int i, delta, rc;
100 unsigned char ch = dim;
101 double d = 0.0;
102 const char *offs = NULL, *doffs = NULL;
103
104 rc = sscanf(s, "%lf %cs", &d, &ch);
105 if(rc == 2)
106 {
107 ch = tolower(ch);
108 if(ch=='s') ch = ' ';
109 offs=strchr(time_prefix, ch);
110 if(offs)
111 {
112 doffs=strchr(time_prefix, (int)dim);
113 if(!doffs) doffs = offs; /* should *never* happen */
114
115 delta= (doffs-time_prefix) - (offs-time_prefix);
116
117 if(delta<0)
118 {
119 for(i=delta;i<0;i++)
120 {
121 d=d/1000;
122 }
123 }
124 else
125 {
126 for(i=0;i<delta;i++)
127 {
128 d=d*1000;
129 }
130 }
131 }
132 }
133
134 return((TimeType)d);
135 }
136
137 /* handles integer values with units */
unformat_time_simple(const char * buf,char dim)138 static TimeType unformat_time_simple(const char *buf, char dim)
139 {
140 TimeType rval;
141 const char *pnt;
142 char *offs=NULL, *doffs;
143 char ch;
144 int i, ich, delta;
145
146 rval=atoi_64(buf);
147 if((pnt=GLOBALS->atoi_cont_ptr))
148 {
149 while((ch=*(pnt++)))
150 {
151 if((ch==' ')||(ch=='\t')) continue;
152
153 ich=tolower((int)ch);
154 if(ich=='s') ich=' '; /* as in plain vanilla seconds */
155
156 offs=strchr(time_prefix, ich);
157 break;
158 }
159 }
160
161 if(!offs) return(rval);
162 if((dim=='S')||(dim=='s'))
163 {
164 doffs = time_prefix;
165 }
166 else
167 {
168 doffs=strchr(time_prefix, (int)dim);
169 if(!doffs) return(rval); /* should *never* happen */
170 }
171
172 delta= (doffs-time_prefix) - (offs-time_prefix);
173
174 if(delta<0)
175 {
176 for(i=delta;i<0;i++)
177 {
178 rval=rval/1000;
179 }
180 }
181 else
182 {
183 for(i=0;i<delta;i++)
184 {
185 rval=rval*1000;
186 }
187 }
188
189 return(rval);
190 }
191
unformat_time(const char * s,char dim)192 TimeType unformat_time(const char *s, char dim)
193 {
194 const char *compar = ".+eE";
195 int compar_len = strlen(compar);
196 int i;
197 char *pnt;
198
199 if((*s == 'M')||(*s == 'm'))
200 {
201 if(bijective_marker_id_string_len(s+1))
202 {
203 unsigned int mkv = bijective_marker_id_string_hash(s+1);
204 if(mkv < WAVE_NUM_NAMED_MARKERS)
205 {
206 TimeType mkvt = GLOBALS->named_markers[mkv];
207 if(mkvt != -1)
208 {
209 return(mkvt);
210 }
211 }
212 }
213 }
214
215 for(i=0;i<compar_len;i++)
216 {
217 if((pnt = strchr(s, (int)compar[i])))
218 {
219 if((tolower((int)(unsigned char)pnt[0]) != 'e') && (tolower((int)(unsigned char)pnt[1]) != 'c'))
220 {
221 return(unformat_time_complex(s, dim));
222 }
223 }
224 }
225
226 return(unformat_time_simple(s, dim));
227 }
228
reformat_time_simple(char * buf,TimeType val,char dim)229 void reformat_time_simple(char *buf, TimeType val, char dim)
230 {
231 char *pnt;
232 int i, offset;
233
234 if(val < LLDescriptor(0))
235 {
236 val = -val;
237 buf[0] = '-';
238 buf++;
239 }
240
241 pnt=strchr(time_prefix, (int)dim);
242 if(pnt) { offset=pnt-time_prefix; } else offset=0;
243
244 for(i=offset; i>0; i--)
245 {
246 if(val%1000) break;
247 val=val/1000;
248 }
249
250 if(i)
251 {
252 sprintf(buf, TTFormat" %cs", val, time_prefix[i]);
253 }
254 else
255 {
256 sprintf(buf, TTFormat" sec", val);
257 }
258 }
259
reformat_time(char * buf,TimeType val,char dim)260 void reformat_time(char *buf, TimeType val, char dim)
261 {
262 char *pnt;
263 int i, offset, offsetfix;
264
265 if(val < LLDescriptor(0))
266 {
267 val = -val;
268 buf[0] = '-';
269 buf++;
270 }
271
272 pnt=strchr(time_prefix, (int)dim);
273 if(pnt) { offset=pnt-time_prefix; } else offset=0;
274
275 for(i=offset; i>0; i--)
276 {
277 if(val%1000) break;
278 val=val/1000;
279 }
280
281 if(GLOBALS->scale_to_time_dimension)
282 {
283 if(GLOBALS->scale_to_time_dimension == 's')
284 {
285 pnt = time_prefix;
286 }
287 else
288 {
289 pnt=strchr(time_prefix, (int)GLOBALS->scale_to_time_dimension);
290 }
291 if(pnt)
292 {
293 offsetfix = pnt-time_prefix;
294 if(offsetfix != i)
295 {
296 int j;
297 int deltaexp = (offsetfix - i);
298 gdouble gval = (gdouble)val;
299 gdouble mypow = 1.0;
300
301 if(deltaexp > 0)
302 {
303 for(j=0;j<deltaexp;j++)
304 {
305 mypow *= 1000.0;
306 }
307 }
308 else
309 {
310 for(j=0;j>deltaexp;j--)
311 {
312 mypow /= 1000.0;
313 }
314 }
315
316 gval *= mypow;
317
318 if(GLOBALS->scale_to_time_dimension == 's')
319 {
320 sprintf(buf, "%.9g sec", gval);
321 }
322 else
323 {
324 sprintf(buf, "%.9g %cs", gval, GLOBALS->scale_to_time_dimension);
325 }
326
327 return;
328 }
329 }
330 }
331
332 if((i)&&(time_prefix)) /* scan-build on time_prefix, should not be necessary however */
333 {
334 sprintf(buf, TTFormat" %cs", val, time_prefix[i]);
335 }
336 else
337 {
338 sprintf(buf, TTFormat" sec", val);
339 }
340 }
341
342
reformat_time_as_frequency(char * buf,TimeType val,char dim)343 void reformat_time_as_frequency(char *buf, TimeType val, char dim)
344 {
345 char *pnt;
346 int offset;
347 double k;
348
349 static const double negpow[] = { 1.0, 1.0e-3, 1.0e-6, 1.0e-9, 1.0e-12, 1.0e-15, 1.0e-18, 1.0e-21 };
350
351 pnt=strchr(time_prefix, (int)dim);
352 if(pnt) { offset=pnt-time_prefix; } else offset=0;
353
354 if(val)
355 {
356 k = 1 / ((double)val * negpow[offset]);
357
358 sprintf(buf, "%e Hz", k);
359 }
360 else
361 {
362 strcpy(buf, "-- Hz");
363 }
364
365 }
366
367
reformat_time_blackout(char * buf,TimeType val,char dim)368 void reformat_time_blackout(char *buf, TimeType val, char dim)
369 {
370 char *pnt;
371 int i, offset, offsetfix;
372 struct blackout_region_t *bt = GLOBALS->blackout_regions;
373 char blackout = ' ';
374
375 while(bt)
376 {
377 if((val>=bt->bstart)&&(val<bt->bend))
378 {
379 blackout = '*';
380 break;
381 }
382
383 bt=bt->next;
384 }
385
386 pnt=strchr(time_prefix, (int)dim);
387 if(pnt) { offset=pnt-time_prefix; } else offset=0;
388
389 for(i=offset; i>0; i--)
390 {
391 if(val%1000) break;
392 val=val/1000;
393 }
394
395 if(GLOBALS->scale_to_time_dimension)
396 {
397 if(GLOBALS->scale_to_time_dimension == 's')
398 {
399 pnt = time_prefix;
400 }
401 else
402 {
403 pnt=strchr(time_prefix, (int)GLOBALS->scale_to_time_dimension);
404 }
405 if(pnt)
406 {
407 offsetfix = pnt-time_prefix;
408 if(offsetfix != i)
409 {
410 int j;
411 int deltaexp = (offsetfix - i);
412 gdouble gval = (gdouble)val;
413 gdouble mypow = 1.0;
414
415 if(deltaexp > 0)
416 {
417 for(j=0;j<deltaexp;j++)
418 {
419 mypow *= 1000.0;
420 }
421 }
422 else
423 {
424 for(j=0;j>deltaexp;j--)
425 {
426 mypow /= 1000.0;
427 }
428 }
429
430 gval *= mypow;
431
432 if(GLOBALS->scale_to_time_dimension == 's')
433 {
434 sprintf(buf, "%.9g%csec", gval, blackout);
435 }
436 else
437 {
438 sprintf(buf, "%.9g%c%cs", gval, blackout, GLOBALS->scale_to_time_dimension);
439 }
440
441 return;
442 }
443 }
444 }
445
446 if((i)&&(time_prefix)) /* scan-build on time_prefix, should not be necessary however */
447 {
448 sprintf(buf, TTFormat"%c%cs", val, blackout, time_prefix[i]);
449 }
450 else
451 {
452 sprintf(buf, TTFormat"%csec", val, blackout);
453 }
454 }
455
456
update_markertime(TimeType val)457 void update_markertime(TimeType val)
458 {
459 #if !defined _MSC_VER
460 if(GLOBALS->anno_ctx)
461 {
462 if(val >= 0)
463 {
464 GLOBALS->anno_ctx->marker_set = 0; /* avoid race on update */
465
466 if(!GLOBALS->ae2_time_xlate)
467 {
468 GLOBALS->anno_ctx->marker = val / GLOBALS->time_scale;
469 }
470 else
471 {
472 int rvs_xlate = bsearch_aetinfo_timechain(val);
473 GLOBALS->anno_ctx->marker = ((TimeType)rvs_xlate) + GLOBALS->ae2_start_cyc;
474 }
475
476 reformat_time(GLOBALS->anno_ctx->time_string, val + GLOBALS->global_time_offset, GLOBALS->time_dimension);
477
478 GLOBALS->anno_ctx->marker_set = 1;
479 }
480 else
481 {
482 GLOBALS->anno_ctx->marker_set = 0;
483 }
484 }
485 #endif
486
487 if(!GLOBALS->use_maxtime_display)
488 {
489 if(val>=0)
490 {
491 if(GLOBALS->tims.baseline>=0)
492 {
493 val-=GLOBALS->tims.baseline; /* do delta instead */
494 *GLOBALS->maxtext_currenttime_c_1='B';
495 if(val>=0)
496 {
497 *(GLOBALS->maxtext_currenttime_c_1+1)='+';
498 if(GLOBALS->use_frequency_delta)
499 {
500 reformat_time_as_frequency(GLOBALS->maxtext_currenttime_c_1+2, val, GLOBALS->time_dimension);
501 }
502 else
503 {
504 reformat_time(GLOBALS->maxtext_currenttime_c_1+2, val, GLOBALS->time_dimension);
505 }
506 }
507 else
508 {
509 if(GLOBALS->use_frequency_delta)
510 {
511 reformat_time_as_frequency(GLOBALS->maxtext_currenttime_c_1+1, val, GLOBALS->time_dimension);
512 }
513 else
514 {
515 reformat_time(GLOBALS->maxtext_currenttime_c_1+1, val, GLOBALS->time_dimension);
516 }
517 }
518 }
519 else if(GLOBALS->tims.lmbcache>=0)
520 {
521 val-=GLOBALS->tims.lmbcache; /* do delta instead */
522
523 if(GLOBALS->use_frequency_delta)
524 {
525 reformat_time_as_frequency(GLOBALS->maxtext_currenttime_c_1, val, GLOBALS->time_dimension);
526 }
527 else
528 {
529 if(val>=0)
530 {
531 *GLOBALS->maxtext_currenttime_c_1='+';
532 reformat_time(GLOBALS->maxtext_currenttime_c_1+1, val, GLOBALS->time_dimension);
533 }
534 else
535 {
536 reformat_time(GLOBALS->maxtext_currenttime_c_1, val, GLOBALS->time_dimension);
537 }
538 }
539 }
540 else
541 {
542 reformat_time(GLOBALS->maxtext_currenttime_c_1, val + GLOBALS->global_time_offset, GLOBALS->time_dimension);
543 }
544 }
545 else
546 {
547 sprintf(GLOBALS->maxtext_currenttime_c_1, "--");
548 }
549
550 gtk_label_set(GTK_LABEL(GLOBALS->maxtimewid_currenttime_c_1), GLOBALS->maxtext_currenttime_c_1);
551 }
552
553 if(GLOBALS->named_marker_lock_idx>-1)
554 {
555 if(GLOBALS->tims.marker >= 0)
556 {
557 int ent_idx = GLOBALS->named_marker_lock_idx;
558
559 if(GLOBALS->named_markers[ent_idx] != GLOBALS->tims.marker)
560 {
561 GLOBALS->named_markers[ent_idx] = GLOBALS->tims.marker;
562 wavearea_configure_event(GLOBALS->wavearea, NULL);
563 }
564 }
565 }
566 }
567
568
update_basetime(TimeType val)569 void update_basetime(TimeType val)
570 {
571 if(val>=0)
572 {
573 gtk_label_set(GTK_LABEL(GLOBALS->base_or_curtime_label_currenttime_c_1), (!GLOBALS->use_toolbutton_interface) ? "Base Marker" : "Base");
574 reformat_time(GLOBALS->curtext_currenttime_c_1, val + GLOBALS->global_time_offset, GLOBALS->time_dimension);
575 }
576 else
577 {
578 gtk_label_set(GTK_LABEL(GLOBALS->base_or_curtime_label_currenttime_c_1), (!GLOBALS->use_toolbutton_interface) ? "Current Time" : "Cursor");
579 reformat_time_blackout(GLOBALS->curtext_currenttime_c_1, GLOBALS->cached_currenttimeval_currenttime_c_1 + GLOBALS->global_time_offset, GLOBALS->time_dimension);
580 }
581
582 gtk_label_set(GTK_LABEL(GLOBALS->curtimewid_currenttime_c_1), GLOBALS->curtext_currenttime_c_1);
583 }
584
585
update_maxtime(TimeType val)586 void update_maxtime(TimeType val)
587 {
588 GLOBALS->max_time=val;
589
590 if(GLOBALS->use_maxtime_display)
591 {
592 reformat_time(GLOBALS->maxtext_currenttime_c_1, val + GLOBALS->global_time_offset, GLOBALS->time_dimension);
593 gtk_label_set(GTK_LABEL(GLOBALS->maxtimewid_currenttime_c_1), GLOBALS->maxtext_currenttime_c_1);
594 }
595 }
596
597
update_currenttime(TimeType val)598 void update_currenttime(TimeType val)
599 {
600 GLOBALS->cached_currenttimeval_currenttime_c_1 = val;
601
602 if(GLOBALS->tims.baseline<0)
603 {
604 GLOBALS->currenttime=val;
605 reformat_time_blackout(GLOBALS->curtext_currenttime_c_1, val + GLOBALS->global_time_offset, GLOBALS->time_dimension);
606 gtk_label_set(GTK_LABEL(GLOBALS->curtimewid_currenttime_c_1), GLOBALS->curtext_currenttime_c_1);
607 }
608 }
609
610
611 /* Create an entry box */
612 GtkWidget *
create_time_box(void)613 create_time_box(void)
614 {
615 GtkWidget *mainbox;
616 GtkWidget *eventbox;
617
618 GLOBALS->max_or_marker_label_currenttime_c_1=(GLOBALS->use_maxtime_display)
619 ? gtk_label_new((!GLOBALS->use_toolbutton_interface) ? maxtime_label_text : maxtime_label_text_hpos)
620 : gtk_label_new((!GLOBALS->use_toolbutton_interface) ? marker_label_text : marker_label_text_hpos);
621
622 GLOBALS->maxtext_currenttime_c_1=(char *)malloc_2(40);
623 if(GLOBALS->use_maxtime_display)
624 {
625 reformat_time(GLOBALS->maxtext_currenttime_c_1, GLOBALS->max_time, GLOBALS->time_dimension);
626 }
627 else
628 {
629 sprintf(GLOBALS->maxtext_currenttime_c_1,"--");
630 }
631
632 GLOBALS->maxtimewid_currenttime_c_1=gtk_label_new(GLOBALS->maxtext_currenttime_c_1);
633
634 GLOBALS->curtext_currenttime_c_1=(char *)malloc_2(40);
635 if(GLOBALS->tims.baseline<0)
636 {
637 GLOBALS->base_or_curtime_label_currenttime_c_1=gtk_label_new((!GLOBALS->use_toolbutton_interface) ? "Current Time" : "Cursor");
638 reformat_time(GLOBALS->curtext_currenttime_c_1, (GLOBALS->currenttime=GLOBALS->min_time), GLOBALS->time_dimension);
639 GLOBALS->curtimewid_currenttime_c_1=gtk_label_new(GLOBALS->curtext_currenttime_c_1);
640 }
641 else
642 {
643 GLOBALS->base_or_curtime_label_currenttime_c_1=gtk_label_new((!GLOBALS->use_toolbutton_interface) ? "Base Marker" : "Base");
644 reformat_time(GLOBALS->curtext_currenttime_c_1, GLOBALS->tims.baseline, GLOBALS->time_dimension);
645 GLOBALS->curtimewid_currenttime_c_1=gtk_label_new(GLOBALS->curtext_currenttime_c_1);
646 }
647
648 if(!GLOBALS->use_toolbutton_interface)
649 {
650 mainbox=gtk_vbox_new(FALSE, 0);
651 }
652 else
653 {
654 mainbox=gtk_hbox_new(FALSE, 0);
655 }
656
657 gtk_widget_show(mainbox);
658 eventbox=gtk_event_box_new();
659 gtk_container_add(GTK_CONTAINER(eventbox), mainbox);
660
661 if(!GLOBALS->use_toolbutton_interface)
662 {
663 gtk_box_pack_start(GTK_BOX(mainbox), GLOBALS->max_or_marker_label_currenttime_c_1, TRUE, FALSE, 0);
664 gtk_widget_show(GLOBALS->max_or_marker_label_currenttime_c_1);
665 gtk_box_pack_start(GTK_BOX(mainbox), GLOBALS->maxtimewid_currenttime_c_1, TRUE, FALSE, 0);
666 gtk_widget_show(GLOBALS->maxtimewid_currenttime_c_1);
667
668 gtk_box_pack_start(GTK_BOX(mainbox), GLOBALS->base_or_curtime_label_currenttime_c_1, TRUE, FALSE, 0);
669 gtk_widget_show(GLOBALS->base_or_curtime_label_currenttime_c_1);
670 gtk_box_pack_start(GTK_BOX(mainbox), GLOBALS->curtimewid_currenttime_c_1, TRUE, FALSE, 0);
671 gtk_widget_show(GLOBALS->curtimewid_currenttime_c_1);
672 }
673 else
674 {
675 GtkWidget *dummy;
676
677 gtk_box_pack_start(GTK_BOX(mainbox), GLOBALS->max_or_marker_label_currenttime_c_1, TRUE, FALSE, 0);
678 gtk_widget_show(GLOBALS->max_or_marker_label_currenttime_c_1);
679
680 dummy=gtk_label_new(": ");
681 gtk_widget_show (dummy);
682 gtk_box_pack_start(GTK_BOX(mainbox), dummy, TRUE, FALSE, 0);
683
684 gtk_box_pack_start(GTK_BOX(mainbox), GLOBALS->maxtimewid_currenttime_c_1, TRUE, FALSE, 0);
685 gtk_widget_show(GLOBALS->maxtimewid_currenttime_c_1);
686
687 dummy=gtk_label_new(" | ");
688 gtk_widget_show (dummy);
689 gtk_box_pack_start(GTK_BOX(mainbox), dummy, TRUE, FALSE, 0);
690
691 gtk_box_pack_start(GTK_BOX(mainbox), GLOBALS->base_or_curtime_label_currenttime_c_1, TRUE, FALSE, 0);
692 gtk_widget_show(GLOBALS->base_or_curtime_label_currenttime_c_1);
693
694 dummy=gtk_label_new(": ");
695 gtk_widget_show (dummy);
696 gtk_box_pack_start(GTK_BOX(mainbox), dummy, TRUE, FALSE, 0);
697
698 gtk_box_pack_start(GTK_BOX(mainbox), GLOBALS->curtimewid_currenttime_c_1, TRUE, FALSE, 0);
699 gtk_widget_show(GLOBALS->curtimewid_currenttime_c_1);
700 }
701
702 return(eventbox);
703 }
704
705
706
707
time_trunc(TimeType t)708 TimeType time_trunc(TimeType t)
709 {
710 if(!GLOBALS->use_full_precision)
711 if(GLOBALS->time_trunc_val_currenttime_c_1!=1)
712 {
713 t=t/GLOBALS->time_trunc_val_currenttime_c_1;
714 t=t*GLOBALS->time_trunc_val_currenttime_c_1;
715 if(t<GLOBALS->tims.first) t=GLOBALS->tims.first;
716 }
717
718 return(t);
719 }
720
time_trunc_set(void)721 void time_trunc_set(void)
722 {
723 gdouble gcompar=1e15;
724 TimeType compar=LLDescriptor(1000000000000000);
725
726 for(;compar!=1;compar=compar/10,gcompar=gcompar/((gdouble)10.0))
727 {
728 if(GLOBALS->nspx>=gcompar)
729 {
730 GLOBALS->time_trunc_val_currenttime_c_1=compar;
731 return;
732 }
733 }
734
735 GLOBALS->time_trunc_val_currenttime_c_1=1;
736 }
737
738
739 /*
740 * called by lxt/lxt2/vzt reader inits
741 */
exponent_to_time_scale(signed char scale)742 void exponent_to_time_scale(signed char scale)
743 {
744 switch(scale)
745 {
746 case 2: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 's'; break;
747 case 1: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
748 case 0: GLOBALS->time_dimension = 's'; break;
749
750 case -1: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'm'; break;
751 case -2: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
752 case -3: GLOBALS->time_dimension = 'm'; break;
753
754 case -4: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'u'; break;
755 case -5: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
756 case -6: GLOBALS->time_dimension = 'u'; break;
757
758 case -10: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'p'; break;
759 case -11: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
760 case -12: GLOBALS->time_dimension = 'p'; break;
761
762 case -13: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'f'; break;
763 case -14: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
764 case -15: GLOBALS->time_dimension = 'f'; break;
765
766 case -16: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'a'; break;
767 case -17: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
768 case -18: GLOBALS->time_dimension = 'a'; break;
769
770 case -19: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'z'; break;
771 case -20: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
772 case -21: GLOBALS->time_dimension = 'z'; break;
773
774 case -7: GLOBALS->time_scale = LLDescriptor(100); GLOBALS->time_dimension = 'n'; break;
775 case -8: GLOBALS->time_scale = LLDescriptor(10); /* fallthrough */
776 case -9:
777 default: GLOBALS->time_dimension = 'n'; break;
778 }
779 }
780
781