Remove trailing whitespace.
[dockapps.git] / wmglobe / src / wmgutil.c
blob45454329dd780e5f31a19905fa763534fe51278e
1 /* WMGlobe 1.3 - All the Earth on a WMaker Icon
2 * copyright (C) 1998,99,2000,01 Jerome Dumonteil <jerome.dumonteil@linuxfr.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17 ***************************************************************************/
19 * I used many functions of wmgeneral.c ("openXwindow")
20 * for the main function of wmglobe.c
21 * wmgeneral.c was taken from wmaker applet wmtune-1.0 :
22 * Author: Martijn Pieterse (pieterse@xs4all.nl)
24 * wmglobe.c uses functions of : Xglobe, Xearth, wmgeneral, wmaker/wrlib
25 ***************************************************************************/
27 #include "wmglobe.h"
28 #include "zapnum.xpm"
29 #include "zaptxt.xpm"
30 #include "zapnum.h"
31 #include "scrpos.xpm"
32 #include "scrtime.xpm"
33 #include "scrdiv.xpm"
35 static void move_earth(double vla, double vlo);
36 static int flush_expose(Window w);
37 static void mqparam();
38 static double getdegre(char *val);
39 static void screen_1();
40 static void screen_2();
41 static void screen_3();
42 static void screen_4();
43 static void screen_5();
44 static void screen_6();
45 static void screen_7();
46 static void write_icon(char *txt, int x, int y);
47 static void chiffre(int ch, int xx, int yy);
48 static int lettre(char c, int xx, int yy);
49 static void display_pos(double la, double lo);
50 static void display_date(double la, double lo);
51 static void release_but(int ckm);
52 static void press_but(int ckm);
53 static void display_zoom();
54 static void display_light();
55 static void display_accel();
56 static void display_dlat();
57 static void display_type();
58 static void move_delay(int factor);
59 static void move_zoom(int factor);
60 static void move_light(int factor);
61 static void move_dawn(int factor);
62 static void move_accel(int factor);
63 static void move_dlat(int factor);
64 static void move_dlong(int factor);
66 /**************************************************************************
67 * TIME FUNCTIONS
68 *************************************************************************/
70 struct timeval diftimev(struct timeval t1, struct timeval t2)
72 t1.tv_usec -= t2.tv_usec;
73 if (t1.tv_usec < 0) {
74 t1.tv_usec += 1000000;
75 t1.tv_sec--;
77 t1.tv_sec -= t2.tv_sec;
78 return t1;
83 struct timeval addtimev(struct timeval t1, struct timeval t2)
85 t1.tv_usec += t2.tv_usec;
86 if (t1.tv_usec >= 1000000) {
87 t1.tv_usec -= 1000000;
88 t1.tv_sec++;
90 t1.tv_sec += t2.tv_sec;
91 return t1;
96 struct timeval getimev()
98 struct timeval tv;
99 struct timezone tz;
101 gettimeofday(&tv, &tz);
102 return tv;
106 /***************************************************************************
107 * INIT FUNCTIONS
109 * defaults, commandline
110 * init of pixmap for screenpos and numbers displaying
111 ***************************************************************************/
113 void loadxpm(Window draw)
115 XpmCreatePixmapFromData(dpy, draw, scrpos_xpm, &(screenpos.pixmap),
116 &(screenpos.mask), &(screenpos.attributes));
117 XpmCreatePixmapFromData(dpy, draw, scrtime_xpm, &(scrdate.pixmap),
118 &(scrdate.mask), &(scrdate.attributes));
119 XpmCreatePixmapFromData(dpy, draw, zapnum_xpm, &(numpix.pixmap),
120 &(numpix.mask), &(numpix.attributes));
121 XpmCreatePixmapFromData(dpy, draw, zaptxt_xpm, &(txtpix.pixmap),
122 &(txtpix.mask), &(txtpix.attributes));
123 XpmCreatePixmapFromData(dpy, draw, scrdiv_xpm, &(scrdiv.pixmap),
124 &(scrdiv.mask), &(scrdiv.attributes));
125 return;
134 void set_defaults()
136 stable = FALSE;
137 firstTime = TRUE;
138 dayfile = NULL;
139 use_nightmap = TRUE;
140 use_default_nightmap = FALSE;
141 nightfile = NULL;
142 oknimap = DEFAULT_NIGHTMAP;
143 p_type = PTSUN;
144 delay = DEFAULT_DELAY;
145 tini = getimev();
146 tbase = tini;
147 tsunpos = 0;
148 tlast.tv_sec = 0;
149 tlast.tv_usec = 0;
150 do_something = TRUE;
151 time_multi = 1.0;
152 v_lat = DEFAULT_V_LAT / 180. * PI;
153 v_long = DEFAULT_V_LONG / 180. * PI;
154 dv_lat = DEFAULT_V_LAT;
155 dv_long = DEFAULT_V_LONG;
156 old_dvlat = DEFAULT_V_LAT;
157 old_dvlong = DEFAULT_V_LONG;
158 iop = 0;
159 dlat = 0.0;
160 dlong = 0.0;
161 addlat = 0.0;
162 addlong = 0.0;
163 radius = 1000.0;
164 sun_long = 0.0;
165 sun_lat = 0.0;
166 fov = 0.5 * PI / 180.;
167 sens = DEFAULT_SENS;
168 zoom = DEFAULT_ZOOM;
169 ambient_light = DEFAULT_LIGHT;
170 dawn = DEFAULT_DAWN;
171 typecadre = DEFAULT_BORDER;
172 fun = FALSE;
173 funx = 0;
174 funy = 0;
175 dpy_name = NULL;
176 onlyshape = TRUE;
177 option_iw = WithdrawnState;
178 stoprand = FALSE;
179 solution = FALSE;
180 proj_dist = DIAMETRE / tan(fov);
181 noir.red = 0;
182 noir.green = 0;
183 noir.blue = 0;
184 noir.alpha = 255;
185 #if WITH_MARKERS
186 nb_marker = 0;
187 sun_marker = -1;
188 moon_marker = -1;
189 sun_col.red = CR_SUN_R;
190 sun_col.green = CR_SUN_G;
191 sun_col.blue = CR_SUN_B;
192 sun_col.alpha = 255;
193 moon_col.red = CR_MOON_R;
194 moon_col.green = CR_MOON_G;
195 moon_col.blue = CR_MOON_B;
196 moon_col.alpha = 255;
197 #endif
198 md[0] = (MPO *) malloc(sizeof(MPO));
199 md[1] = (MPO *) malloc(sizeof(MPO));
200 md[2] = (MPO *) malloc(sizeof(MPO));
201 md[3] = (MPO *) malloc(sizeof(MPO));
202 mn[0] = (MPO *) malloc(sizeof(MPO));
203 mn[1] = (MPO *) malloc(sizeof(MPO));
204 mn[2] = (MPO *) malloc(sizeof(MPO));
205 mn[3] = (MPO *) malloc(sizeof(MPO));
206 #ifdef DEBUG
207 minhz = 1.;
208 #endif
209 return;
215 static double getdegre(char *val)
217 double d, m, s;
218 if (strchr(val, '°') != NULL || strchr(val, 'd') != NULL
219 || strchr(val, 'D') != NULL || strchr(val, ':') != NULL) {
220 d = m = s = 0;
221 sscanf(val, "%lf%*c%lf%*c%lf", &d, &m, &s);
222 if (d >= 0.)
223 return d + m / 60. + s / 3600.;
224 else
225 return d - m / 60. - s / 3600.;
226 } else {
227 return atof(val);
234 static void mqparam()
236 fprintf(stderr, "error in parameters\n");
237 exit(1);
244 void cmdline(int argc, char *argv[])
246 int i, j;
248 if (argc > 0) {
249 for (i = 1; i < argc; i++) {
250 j = 0;
253 if (strcasecmp(argv[i], "-v") == 0
254 || strcasecmp(argv[i], "-version") == 0) {
255 printf("%s\n", WMGVERSION);
256 exit(0);
259 if (strcasecmp(argv[i], "-w") == 0
260 || strcasecmp(argv[i], "-wmaker") == 0) {
261 option_iw = WithdrawnState;
262 j = 1;
265 if (strcasecmp(argv[i], "-i") == 0
266 || strcasecmp(argv[i], "-iconic") == 0) {
267 option_iw = IconicState;
268 j = 1;
271 if (!j && (strcasecmp(argv[i], "-s") == 0 ||
272 strcasecmp(argv[i], "-shape") == 0)) {
273 onlyshape = TRUE;
274 j = 1;
277 if (!j && (strcasecmp(argv[i], "-d") == 0
278 || strcasecmp(argv[i], "-display") == 0)) {
279 i++;
280 if (i < argc) {
281 j = 1;
282 dpy_name = argv[i];
283 } else {
284 mqparam();
285 i--;
289 if (!j && (strcasecmp(argv[i], "-stable") == 0
290 || strcasecmp(argv[i], "-stab") == 0)) {
291 stable = TRUE;
292 j = 1;
295 if (!j && (strcasecmp(argv[i], "-rand") == 0
296 || strcasecmp(argv[i], "-random") == 0)) {
297 p_type = PTRANDOM;
298 srandom(((int) time(NULL)) + ((int) getpid()));
299 j = 1;
302 if (!j && (strcasecmp(argv[i], "-sun") == 0
303 || strcasecmp(argv[i], "-soleil") == 0)) {
304 p_type = PTSUN;
305 j = 1;
308 #if WITH_MARKERS
309 if (!j && (strcasecmp(argv[i], "-moon") == 0
310 || strcasecmp(argv[i], "-lune") == 0)) {
311 p_type = PTMOON;
312 j = 1;
314 #endif
316 if (!j && (strcasecmp(argv[i], "-oz") == 0
317 || strcasecmp(argv[i], "-austral") == 0)) {
318 sens = -1;
319 j = 1;
322 if (!j && strcasecmp(argv[i], "-map") == 0) {
324 i++;
325 if (i < argc) {
326 j = 1;
327 free(dayfile);
328 if ((dayfile = (char *) malloc(strlen(argv[i]) + 1)) ==
329 NULL) {
330 fprintf(stderr, "erreur memoire options map\n");
331 exit(1);
333 strcpy(dayfile, argv[i]);
334 } else {
335 mqparam();
336 i--;
340 if (!j && (strcasecmp(argv[i], "-nimap") == 0
341 || strcasecmp(argv[i], "-nightmap") == 0
342 || strcasecmp(argv[i], "-night") == 0)) {
343 i++;
344 if (i < argc) {
345 j = 1;
346 free(nightfile);
347 if ((nightfile = (char *) malloc(strlen(argv[i]) + 1))
348 == NULL) {
349 fprintf(stderr, "erreur memoire options nimap\n");
350 exit(1);
352 strcpy(nightfile, argv[i]);
353 use_nightmap = TRUE;
354 } else {
355 mqparam();
356 i--;
360 if (!j && (strcasecmp(argv[i], "-accel") == 0
361 || strcasecmp(argv[i], "-accell") == 0
362 || strcasecmp(argv[i], "-acc") == 0
363 || strcasecmp(argv[i], "-multi") == 0)) {
364 i++;
365 if (i < argc) {
366 j = 1;
367 time_multi = atof(argv[i]);
368 if (time_multi < 1.0)
369 time_multi = 1.0;
370 if (time_multi > MAX_MULTI_COEF)
371 time_multi = MAX_MULTI_COEF;
372 if (time_multi > 24.0)
373 time_multi = floor(time_multi);
374 else
375 time_multi = floor(time_multi * 10.0) / 10.0;
376 } else {
377 mqparam();
378 i--;
382 if (!j && (strcasecmp(argv[i], "-nonimap") == 0
383 || strcasecmp(argv[i], "-nonightmap") == 0
384 || strcasecmp(argv[i], "-nonight") == 0
385 || strcasecmp(argv[i], "-nomap") == 0)) {
386 j = 1;
387 use_nightmap = FALSE;
388 oknimap = FALSE;
391 if (!j && (strcasecmp(argv[i], "-defnimap") == 0
392 || strcasecmp(argv[i], "-defnightmap") == 0
393 || strcasecmp(argv[i], "-defnight") == 0)) {
394 j = 1;
395 use_default_nightmap = TRUE;
398 if (!j && strcasecmp(argv[i], "-zoom") == 0) {
399 i++;
400 if (i < argc) {
401 j = 1;
402 zoom = atof(argv[i]);
403 if (zoom < ZOOM_MIN)
404 zoom = ZOOM_MIN;
405 if (zoom > ZOOM_MAX)
406 zoom = ZOOM_MAX;
407 } else {
408 mqparam();
409 i--;
413 if (!j && strcasecmp(argv[i], "-dawn") == 0) {
414 i++;
415 if (i < argc) {
416 j = 1;
417 dawn = atof(argv[i]);
418 dawn = MAX(0.0, dawn);
419 dawn = MIN(1.0, dawn);
421 dawn = (1.0 - dawn / 2.0);
422 } else {
423 mqparam();
424 i--;
428 if (!j && strcasecmp(argv[i], "-delay") == 0) {
429 i++;
430 if (i < argc) {
431 j = 1;
432 delay = atof(argv[i]);
433 if (delay < 0)
434 delay = 0;
435 if (delay > MAX_DELAY_SEC)
436 delay = MAX_DELAY_SEC;
437 } else {
438 mqparam();
439 i--;
443 if (!j && (strcasecmp(argv[i], "-dlat") == 0
444 || strcasecmp(argv[i], "-lat") == 0
445 || strcasecmp(argv[i], "-dlatitude") == 0)) {
446 i++;
447 if (i < argc) {
448 j = 1;
449 dlat = getdegre(argv[i]);
450 if (dlat < -MAX_DELTA_LONG)
451 dlat = -MAX_DELTA_LONG;
452 if (dlat > MAX_DELTA_LONG)
453 dlat = MAX_DELTA_LONG;
454 p_type = PTFIXED;
455 } else {
456 mqparam();
457 i--;
461 if (!j && (strcasecmp(argv[i], "-dlong") == 0
462 || strcasecmp(argv[i], "-long") == 0
463 || strcasecmp(argv[i], "-dlongitude") == 0)) {
464 i++;
465 if (i < argc) {
466 j = 1;
467 dlong = getdegre(argv[i]);
468 if (dlong < -MAX_DELTA_LONG)
469 dlong = -MAX_DELTA_LONG;
470 if (dlong > MAX_DELTA_LONG)
471 dlong = MAX_DELTA_LONG;
472 p_type = PTFIXED;
473 } else {
474 mqparam();
475 i--;
479 if (!j && strcasecmp(argv[i], "-light") == 0) {
480 i++;
481 if (i < argc) {
482 j = 1;
483 ambient_light = atof(argv[i]);
484 if (ambient_light < 0.)
485 ambient_light = 0.;
486 if (ambient_light > 1.)
487 ambient_light = 1.;
488 } else {
489 mqparam();
490 i--;
494 if (!j && strcasecmp(argv[i], "-time") == 0) {
495 i++;
496 if (i < argc) {
497 j = 1;
498 tbase.tv_sec = atoi(argv[i]);
499 tbase.tv_usec = 0;
500 } else {
501 mqparam();
502 i--;
506 if (!j && (strcasecmp(argv[i], "-bord") == 0
507 || strcasecmp(argv[i], "-border") == 0)) {
508 i++;
509 if (i < argc) {
510 j = 1;
511 typecadre = atoi(argv[i]);
512 if (typecadre < 0)
513 typecadre = 0;
514 if (typecadre > 2)
515 typecadre = 2;
516 } else {
517 mqparam();
518 i--;
522 if (!j && strcasecmp(argv[i], "-fun") == 0) {
523 fun = TRUE;
524 i++;
525 if (i < argc) {
526 funx = atoi(argv[i]);
528 i++;
529 if (i < argc) {
530 j = 1;
531 funy = atoi(argv[i]);
532 } else {
533 mqparam();
534 i--;
536 } else {
537 mqparam();
538 i--;
542 if (!j && (strcasecmp(argv[i], "-pos") == 0
543 || strcasecmp(argv[i], "-position") == 0
544 || strcasecmp(argv[i], "-fixed") == 0)) {
545 p_type = PTFIXED;
546 i++;
547 if (i < argc) {
548 addlat = getdegre(argv[i]);
549 i++;
550 if (i < argc) {
551 j = 1;
552 addlong = getdegre(argv[i]);
553 } else {
554 mqparam();
555 i--;
557 } else {
558 mqparam();
559 i--;
563 #if WITH_MARKERS
564 if (!j && (strcasecmp(argv[i], "-mk") == 0
565 || strcasecmp(argv[i], "-marker") == 0)) {
566 if (nb_marker == MAX_MARKERS) {
567 fprintf(stderr, "Too many markers, max=%d\n",
568 MAX_MARKERS);
569 mqparam();
571 i++;
572 if (i < argc) {
573 j = 1;
574 if (strcasecmp(argv[i], "sun") == 0) {
575 sun_marker = nb_marker;
576 nb_marker++;
577 } else if (strcasecmp(argv[i], "moon") == 0) {
578 moon_marker = nb_marker;
579 nb_marker++;
580 } else {
581 marker[nb_marker][1] = getdegre(argv[i]);
582 i++;
583 if (i < argc) {
584 marker[nb_marker][0] = getdegre(argv[i]);
585 nb_marker++;
586 } else {
587 mqparam();
588 i--;
591 } else {
592 mqparam();
593 i--;
596 #endif
599 if (!j && argv[i][0] == '-') {
600 printf("%s\n", WMGVERSION);
601 printf("\n");
602 printf
603 ("-v : version -h : this help message !\n");
604 printf
605 ("-zoom zoom_value : changing apparent size in icon\n");
606 printf
607 ("-pos latitude long. : fixed initial position (default=follow sun)\n");
608 printf("-sun : follow the sun (default)\n");
609 #if WITH_MARKERS
610 printf("-moon : follow the moon\n");
611 #endif
612 printf
613 ("-rand : random position at every refresh\n");
614 printf
615 ("-map map_file : use this map for rendering\n");
616 printf
617 ("-nimap night_file : and this one for the dark side of earth\n");
618 printf
619 ("-defnimap : use the default night map (with a custom map)\n");
620 printf
621 ("-nonimap : don't use the default night map\n");
622 printf
623 ("-delay seconds : time between refresh of image\n");
624 printf
625 ("-dlat delta_lat : latitude speed of point of view (default=follow sun)\n");
626 printf("-dlong delta_long : the same for longitude\n");
627 printf
628 ("-light light_value : level of light for dark side of earth, [0..1]\n");
629 printf
630 ("-dawn dawn_value : level of continuity for dawn limit\n");
631 printf
632 ("-bord border_num : 0 1 or 2 , type of icon border.\n");
633 printf("-accel time_multi : time accelerator\n");
634 printf
635 ("-time seconds : time to display in seconds since 01-01-1970\n");
636 printf
637 ("-oz : start in \"austral\" mode (for \"down under\" people)\n");
638 printf
639 ("-stable : keep the globe from going over the poles\n");
640 #if WITH_MARKERS
641 printf
642 ("-mk latitude long. : position of a marker (or \"sun\", \"moon\")\n");
643 #endif
644 printf
645 ("-fun dx dy : offset of vision... almost useless\n");
646 printf
647 ("-w -shape : set by default (WMaker dockable application)\n");
648 printf
649 ("-d display : display (WindowMaker not needed on the server side)\n");
650 printf
651 ("left button : change longitude, with shift key, change latitude too\n");
652 printf
653 ("middle button : zoom in, shift + middle button : zoom out\n");
654 printf
655 ("right button : access to a few screens of parameters\n");
656 exit(0);
661 return;
664 /****************************************************************************
665 * X functions, mouse selection
667 ****************************************************************************/
670 static int flush_expose(Window w)
672 XEvent dummy;
673 int i = 0;
675 while (XCheckTypedWindowEvent(dpy, w, Expose, &dummy))
676 i++;
677 return i;
682 void RedrawWindowXYWH(int x, int y, int w, int h)
684 flush_expose(iconwin);
685 XCopyArea(dpy, wmg.pixmap, iconwin, NormalGC, x, y, w, h, x, y);
686 flush_expose(win);
687 XCopyArea(dpy, wmg.pixmap, win, NormalGC, x, y, w, h, x, y);
688 return;
693 void AddMouseRegion(int index, int left, int top, int right, int bottom)
695 if (index < MAX_MOUSE_REGION) {
696 mouse_region[index].enable = 1;
697 mouse_region[index].top = top;
698 mouse_region[index].left = left;
699 mouse_region[index].bottom = bottom;
700 mouse_region[index].right = right;
702 return;
707 int CheckMouseRegion(int x, int y)
709 int i;
710 int found;
712 found = 0;
714 for (i = 0; i < MAX_MOUSE_REGION && !found; i++) {
715 if (mouse_region[i].enable &&
716 x <= mouse_region[i].right &&
717 x >= mouse_region[i].left &&
718 y <= mouse_region[i].bottom && y >= mouse_region[i].top)
719 found = 1;
721 if (!found)
722 return -1;
723 return (i - 1);
728 /****************************************************************************
729 * GRAPHIC : pixmap writing of letters & numbers
731 ****************************************************************************/
733 static void chiffre(int ch, int xx, int yy)
735 XCopyArea(dpy, numpix.pixmap, wmg.pixmap, NormalGC,
736 zapnum[ch][0], zapnum[ch][1], zapnum[ch][2], zapnum[ch][3],
737 xx, yy);
739 return;
743 static int lettre(char c, int xx, int yy)
745 int i;
746 if (c == '°')
747 i = 288;
748 else
749 switch (toupper(c)) {
750 case '0':
751 i = 0;
752 break;
753 case '1':
754 i = 6;
755 break;
756 case '2':
757 i = 12;
758 break;
759 case '3':
760 i = 18;
761 break;
762 case '4':
763 i = 24;
764 break;
765 case '5':
766 i = 30;
767 break;
768 case '6':
769 i = 36;
770 break;
771 case '7':
772 i = 42;
773 break;
774 case '8':
775 i = 48;
776 break;
777 case '9':
778 i = 54;
779 break;
780 case '+':
781 i = 60;
782 break;
783 case 'A':
784 i = 66;
785 break;
786 case 'B':
787 i = 72;
788 break;
789 case 'C':
790 i = 78;
791 break;
792 case 'D':
793 i = 84;
794 break;
795 case 'E':
796 i = 90;
797 break;
798 case 'F':
799 i = 96;
800 break;
801 case 'G':
802 i = 102;
803 break;
804 case 'H':
805 i = 108;
806 break;
807 case 'I':
808 i = 114;
809 break;
810 case 'J':
811 i = 120;
812 break;
813 case 'K':
814 i = 126;
815 break;
816 case 'L':
817 i = 132;
818 break;
819 case 'M':
820 i = 138;
821 break;
822 case 'N':
823 i = 144;
824 break;
825 case 'O':
826 i = 150;
827 break;
828 case 'P':
829 i = 156;
830 break;
831 case 'Q':
832 i = 162;
833 break;
834 case 'R':
835 i = 168;
836 break;
837 case 'S':
838 i = 174;
839 break;
840 case 'T':
841 i = 180;
842 break;
843 case 'U':
844 i = 186;
845 break;
846 case 'V':
847 i = 192;
848 break;
849 case 'W':
850 i = 198;
851 break;
852 case 'X':
853 i = 204;
854 break;
855 case 'Y':
856 i = 210;
857 break;
858 case 'Z':
859 i = 216;
860 break;
861 case ' ':
862 i = 222;
863 break;
864 case ':':
865 i = 228;
866 break;
867 case '/':
868 i = 234;
869 break;
870 case '!':
871 i = 240;
872 break;
873 case '*':
874 i = 246;
875 break;
876 case '-':
877 i = 252;
878 break;
879 case '.':
880 i = 258;
881 break;
882 case '=':
883 i = 264;
884 break;
885 case '#':
886 i = 270;
887 break;
888 case '<':
889 i = 276;
890 break;
891 case '>':
892 i = 282;
893 break;
894 case '"':
895 i = 294;
896 break;
897 case '\'':
898 i = 300;
899 break;
900 case ',':
901 i = 306;
902 break;
903 case '@':
904 i = 312;
905 break;
906 case '(':
907 i = 318;
908 break;
909 case ')':
910 i = 324;
911 break;
912 case '&':
913 i = 330;
914 break;
915 case '~':
916 i = 336;
917 break;
918 case '£':
919 i = 342;
920 break;
921 case 'µ':
922 i = 348;
923 break;
924 case '{':
925 i = 354;
926 break;
927 case '}':
928 i = 360;
929 break;
930 case '[':
931 i = 366;
932 break;
933 case ']':
934 i = 372;
935 break;
936 case '\\':
937 i = 378;
938 break;
939 case '|':
940 i = 384;
941 break;
942 case '?':
943 i = 390;
944 break;
945 case '%':
946 i = 396;
947 break;
948 default:
949 i = 222;
950 break;
953 XCopyArea(dpy, txtpix.pixmap, wmg.pixmap, NormalGC,
954 i, 0, 6, 10, xx, yy);
955 return xx + 6;
960 static void write_icon(char *txt, int x, int y)
962 int p, ok;
963 p = 0;
965 #ifdef DEBUG
966 fprintf(stdout, "%s_\n", txt);
967 #endif
968 ok = TRUE;
969 while (ok) {
970 if (txt[p] == '\0' || x > DIAMETRE - 5) {
971 ok = FALSE;
972 } else {
973 x = lettre(txt[p], x, y);
974 p++;
977 return;
982 static void press_but(int ckm)
984 switch (ckm) {
985 case 5:
986 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
987 0, 38, 20, 9, 2, 52);
988 RedrawWindowXYWH(2, 52, 20, 9);
989 break;
990 case 6:
991 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
992 20, 38, 20, 9, 22, 52);
993 RedrawWindowXYWH(22, 52, 20, 9);
994 break;
995 case 7:
996 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
997 40, 38, 20, 9, 42, 52);
998 RedrawWindowXYWH(42, 52, 20, 9);
999 break;
1000 default:
1001 break;
1003 return;
1008 static void release_but(int ckm)
1010 switch (ckm) {
1011 case 5:
1012 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
1013 0, 28, 20, 9, 2, 52);
1014 RedrawWindowXYWH(2, 52, 20, 9);
1015 break;
1016 case 6:
1017 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
1018 20, 28, 20, 9, 22, 52);
1019 RedrawWindowXYWH(22, 52, 20, 9);
1020 break;
1021 case 7:
1022 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
1023 40, 28, 20, 9, 42, 52);
1024 RedrawWindowXYWH(42, 52, 20, 9);
1025 break;
1026 default:
1027 break;
1029 return;
1035 /***************************************************************************
1036 * MENU SELECTION & ACTIONS
1037 ***************************************************************************/
1040 void screen_back()
1042 AddMouseRegion(0, 0, 0, 0, 0);
1043 if (p_type == PTRANDOM) {
1044 stoprand = STOP_RANDOM_FACTOR;
1045 addlong = dv_long;
1046 addlat = dv_lat;
1048 gotoscr = 1;
1049 while (gotoscr != 0) {
1050 switch (gotoscr) {
1051 case 1:
1052 screen_1();
1053 break;
1054 case 2:
1055 screen_2();
1056 break;
1057 case 3:
1058 screen_3();
1059 break;
1060 case 4:
1061 screen_4();
1062 break;
1063 case 5:
1064 screen_5();
1065 break;
1066 case 6:
1067 screen_6();
1068 break;
1069 case 7:
1070 screen_7();
1071 break;
1072 default:
1073 break;
1075 XFlush(dpy);
1078 * put old environment
1080 XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, pixmask, ShapeSet);
1081 XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, pixmask,
1082 ShapeSet);
1084 AddMouseRegion(0, 5, 5, DIAMETRE - 4, DIAMETRE - 4);
1085 stoprand = FALSE;
1086 do_something = TRUE;
1088 return;
1093 static void display_pos(double la, double lo)
1095 int c, i, j, k, l, neg;
1097 if (la > 0) {
1098 neg = 10;
1099 } else {
1100 neg = 11;
1101 la *= -1;
1103 i = floor(la / 10.0);
1104 la -= 10 * i;
1105 j = floor(la);
1106 la -= j;
1107 la *= 60;
1108 k = floor(la / 10.0);
1109 la -= 10 * k;
1110 l = floor(la);
1112 if (i == 0) {
1113 i = neg;
1114 neg = 10;
1116 chiffre(neg, platd[1][0], platd[1][1]);
1117 chiffre(i, platd[2][0], platd[2][1]);
1118 chiffre(j, platd[3][0], platd[3][1]);
1119 chiffre(k, platm[0][0], platd[0][1]);
1120 chiffre(l, platm[1][0], platd[1][1]);
1122 if (lo > 0) {
1123 neg = 12;
1124 } else {
1125 neg = 11;
1126 lo *= -1;
1128 c = floor(lo / 100.0);
1129 lo -= c * 100;
1130 if (c > 0) {
1131 if (neg == 11)
1132 neg = 13;
1133 } else {
1134 if (neg == 11) {
1135 c = neg;
1136 } else {
1137 c = 10;
1139 neg = 12;
1141 i = floor(lo / 10.0);
1142 lo -= 10 * i;
1143 j = floor(lo);
1144 lo -= j;
1145 lo *= 60;
1146 k = floor(lo / 10.0);
1147 lo -= 10 * k;
1148 l = floor(lo);
1149 if (i == 0 && c > 9) {
1150 i = c;
1151 c = 10;
1153 chiffre(neg, plongd[0][0], plongd[0][1]);
1154 chiffre(c, plongd[1][0], plongd[1][1]);
1155 chiffre(i, plongd[2][0], plongd[2][1]);
1156 chiffre(j, plongd[3][0], plongd[3][1]);
1157 chiffre(k, plongm[0][0], plongm[0][1]);
1158 chiffre(l, plongm[1][0], plongm[1][1]);
1160 RedrawWindowXYWH(0, 0, DIAMETRE, DIAMETRE);
1161 return;
1166 void rotation_terre(int x, int y, int lat_flag)
1169 * earth rotate after (while) a clic
1171 double mx, my;
1172 mx =
1173 (double) ((double) x - DIAMETRE / 2 +
1174 0.5) / zoom * cos(v_lat) * sens;
1175 if (lat_flag) {
1176 my = -(double) ((double) y - DIAMETRE / 2 + 0.5) * sens / zoom;
1177 if (my > 0.0)
1178 my +=
1179 ABS(sin(v_lat) * ((double) x - DIAMETRE / 2 + 0.5) / zoom);
1180 else
1181 my -=
1182 ABS(sin(v_lat) * ((double) x - DIAMETRE / 2 + 0.5) / zoom);
1183 } else {
1184 my = 0;
1186 if (p_type == PTRANDOM) {
1187 stoprand = STOP_RANDOM_FACTOR;
1188 addlong = dv_long;
1189 addlat = dv_lat;
1191 addlong += mx * RATIO_ROTATE;
1192 addlat += my * RATIO_ROTATE;
1194 do_something = TRUE;
1195 return;
1200 static void move_earth(double vla, double vlo)
1202 addlat += vla;
1203 addlong += vlo;
1206 switch (p_type) {
1207 case PTSUN:
1208 setViewPos(sun_lat * 180. / PI + addlat,
1209 sun_long * 180. / PI + addlong);
1210 break;
1211 #if WITH_MARKERS
1212 case PTMOON:
1213 setViewPos(moon_lat * 180. / PI + addlat,
1214 moon_long * 180. / PI + addlong);
1215 break;
1216 #endif
1217 case PTFIXED:
1218 case PTRANDOM:
1219 setViewPos(addlat, addlong);
1220 break;
1221 default:
1222 break;
1224 display_pos(dv_lat, dv_long);
1225 return;
1230 static void screen_1()
1232 int ok, ckm, sensadd, waitrel, not3;
1233 struct timeval tin;
1235 #ifdef DEBUG
1236 fprintf(stdout, "scr 1\n");
1237 #endif
1238 tin = getimev();
1239 waitrel = 0;
1240 ckm = 0;
1241 sensadd = 1;
1242 not3 = TRUE;
1244 XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, screenpos.mask,
1245 ShapeSet);
1246 XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, screenpos.mask,
1247 ShapeSet);
1249 XCopyArea(dpy, screenpos.pixmap, wmg.pixmap, NormalGC, 0, 0, DIAMETRE,
1250 DIAMETRE, 0, 0);
1252 AddMouseRegion(1, platd[0][0], platd[0][1], platd[3][0] + 9,
1253 platd[3][1] + 12);
1254 AddMouseRegion(2, platm[0][0], platm[0][1], platm[1][0] + 9,
1255 platm[1][1] + 12);
1256 AddMouseRegion(3, plongd[0][0], plongd[0][1], plongd[3][0] + 9,
1257 plongd[3][1] + 12);
1258 AddMouseRegion(4, plongm[0][0], plongm[0][1], plongm[1][0] + 9,
1259 plongm[1][1] + 12);
1260 AddMouseRegion(5, 1, 51, 21, 61);
1261 AddMouseRegion(6, 22, 51, 41, 61);
1262 AddMouseRegion(7, 42, 51, 62, 61);
1264 display_pos(dv_lat, dv_long);
1266 ok = TRUE;
1267 while (ok) {
1268 while (XPending(dpy)) {
1269 XNextEvent(dpy, &Event);
1270 switch (Event.type) {
1271 case Expose:
1272 RedrawWindowXYWH(0, 0, DIAMETRE, DIAMETRE);
1273 break;
1274 case DestroyNotify:
1275 XCloseDisplay(dpy);
1276 exit(0);
1277 break;
1278 case ButtonPress:
1279 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
1280 waitrel = 1;
1281 press_but(ckm);
1282 switch (Event.xbutton.button) {
1283 case 1:
1284 not3 = TRUE;
1285 sensadd = 1;
1286 break;
1287 case 2:
1288 not3 = TRUE;
1289 sensadd = -1;
1290 break;
1291 case 3:
1292 not3 = FALSE;
1293 if (ckm < 5)
1294 gotoscr = 0;
1295 default:
1296 break;
1298 break;
1299 case ButtonRelease:
1300 release_but(ckm);
1301 waitrel = ckm;
1302 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
1303 if (waitrel == ckm) {
1304 switch (ckm) {
1305 case 5:
1306 gotoscr--;
1307 if (gotoscr == 0)
1308 gotoscr = NUM_SCREEN;
1309 break;
1310 case 6:
1311 gotoscr++;
1312 if (gotoscr > NUM_SCREEN)
1313 gotoscr = 1;
1314 break;
1315 case 7:
1316 gotoscr = 0;
1317 default:
1318 break;
1321 ckm = 0;
1322 waitrel = 0;
1323 tin = getimev();
1324 break;
1325 default:
1326 break;
1330 usleep(VAL_USLEEP_SHORT);
1331 if (waitrel && not3) {
1332 if (ckm == 1) {
1333 move_earth(sens * sensadd * 1.0, 0.0);
1334 usleep(VAL_USLEEP);
1336 if (ckm == 2) {
1337 move_earth(sens * sensadd * 1.0 / 60.0, 0.0);
1338 usleep(VAL_USLEEP);
1340 if (ckm == 3) {
1341 move_earth(0.0, sens * sensadd * 1.0);
1342 usleep(VAL_USLEEP);
1344 if (ckm == 4) {
1345 move_earth(0.0, sens * sensadd * 1.0 / 60.0);
1346 usleep(VAL_USLEEP);
1349 if (waitrel == 0 && diftimev(getimev(), tin).tv_sec > SCREEN_WAIT
1350 && gotoscr == 1)
1351 gotoscr = 0;
1352 if (gotoscr != 1)
1353 ok = FALSE;
1355 return;
1360 static void display_date(double la, double lo)
1362 char datest[32];
1363 time_t t;
1364 int i, j;
1366 write_icon(" time :", 2, 2);
1367 RedrawWindowXYWH(2, 2, DIAMETRE - 1, DIAMETRE - 1);
1369 write_icon(" GMT+long.", 2, 14);
1370 RedrawWindowXYWH(2, 14, DIAMETRE - 1, DIAMETRE - 1);
1372 t = trend.tv_sec;
1373 t += (int) (floor((lo + 7.5) / 15.0) * 3600);
1374 /*** pb near 2038 ***/
1376 strftime(datest, 30, "%x", gmtime(&t));
1378 i = 10 - strlen(datest);
1379 if (i < 0)
1380 i = 0;
1381 else
1382 i = i / 2;
1384 write_icon(datest, 2 + i * 6, 26);
1385 RedrawWindowXYWH(2, 26, DIAMETRE - 1, DIAMETRE - 1);
1387 strftime(datest, 30, "%X", gmtime(&t));
1389 i = 10 - strlen(datest);
1390 if (i < 0) {
1391 i = 0;
1392 while (datest[i] != '\0') {
1393 if (datest[i] != ' ') {
1394 i++;
1395 } else {
1396 j = i;
1397 do {
1398 datest[j] = datest[j + 1];
1399 j++;
1401 while (datest[j - 1] != '\0');
1404 i = 0;
1405 } else {
1406 i = i / 2;
1409 write_icon(datest, 2 + i * 6, 38);
1410 RedrawWindowXYWH(2, 38, DIAMETRE - 1, DIAMETRE - 1);
1412 return;
1417 static void screen_2()
1419 int ok, ckm, waitrel;
1420 struct timeval tin;
1422 #ifdef DEBUG
1423 fprintf(stdout, "scr 2\n");
1424 #endif
1425 tin = getimev();
1426 waitrel = 0;
1427 ckm = 0;
1429 XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, scrdate.mask,
1430 ShapeSet);
1431 XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, scrdate.mask,
1432 ShapeSet);
1434 XCopyArea(dpy, scrdate.pixmap, wmg.pixmap, NormalGC, 0, 0, DIAMETRE,
1435 DIAMETRE, 0, 0);
1437 display_date(dv_lat, dv_long);
1439 ok = TRUE;
1440 while (ok) {
1441 while (XPending(dpy)) {
1442 XNextEvent(dpy, &Event);
1443 switch (Event.type) {
1444 case Expose:
1445 RedrawWindowXYWH(0, 0, DIAMETRE, DIAMETRE);
1446 break;
1447 case DestroyNotify:
1448 XCloseDisplay(dpy);
1449 exit(0);
1450 break;
1451 case ButtonPress:
1452 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
1453 waitrel = 1;
1454 press_but(ckm);
1455 switch (Event.xbutton.button) {
1456 case 1:
1457 break;
1458 case 2:
1459 break;
1460 case 3:
1461 if (ckm < 5)
1462 gotoscr = 0;
1463 break;
1464 default:
1465 break;
1467 break;
1468 case ButtonRelease:
1469 release_but(ckm);
1470 waitrel = ckm;
1471 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
1472 if (waitrel == ckm) {
1473 switch (ckm) {
1474 case 5:
1475 gotoscr--;
1476 if (gotoscr == 0)
1477 gotoscr = NUM_SCREEN;
1478 break;
1479 case 6:
1480 gotoscr++;
1481 if (gotoscr > NUM_SCREEN)
1482 gotoscr = 1;
1483 break;
1484 case 7:
1485 gotoscr = 0;
1486 default:
1487 break;
1490 ckm = 0;
1491 waitrel = 0;
1492 tin = getimev();
1493 break;
1494 default:
1495 break;
1499 usleep(VAL_USLEEP_SHORT);
1501 if (waitrel == 0 && diftimev(getimev(), tin).tv_sec > SCREEN_WAIT
1502 && gotoscr == 2)
1503 gotoscr = 0;
1504 if (gotoscr != 2)
1505 ok = FALSE;
1507 return;
1512 static void display_zoom()
1514 char datest[32], dstr[32];
1515 int i;
1517 write_icon(" delay :", 2, 2);
1518 RedrawWindowXYWH(2, 2, DIAMETRE - 1, DIAMETRE - 1);
1520 sprintf(dstr, "%f", delay);
1521 dstr[8] = '\0';
1522 i = strlen(dstr) - 1;
1523 while (i > 0) {
1524 if (dstr[i] == '0') {
1525 dstr[i] = '\0';
1526 i--;
1527 } else {
1528 i = 0;
1531 i = strlen(dstr) - 1;
1532 if (dstr[i] == '.')
1533 dstr[i] = '\0';
1534 sprintf(datest, "%s s", dstr);
1536 i = 10 - strlen(datest);
1537 if (i < 0)
1538 i = 0;
1539 else
1540 i = i / 2;
1541 write_icon(datest, 2 + i * 6, 14);
1542 RedrawWindowXYWH(2, 14, DIAMETRE - 1, DIAMETRE - 1);
1544 write_icon(" zoom :", 2, 26);
1545 RedrawWindowXYWH(2, 26, DIAMETRE - 1, DIAMETRE - 1);
1547 sprintf(datest, "%.3f", zoom);
1548 i = 10 - strlen(datest);
1549 if (i < 0)
1550 i = 0;
1551 else
1552 i = i / 2;
1553 write_icon(datest, 2 + i * 6, 38);
1554 RedrawWindowXYWH(2, 38, DIAMETRE - 1, DIAMETRE - 1);
1556 return;
1561 static void move_delay(int factor)
1563 if (factor == 1) {
1564 if (delay < (double) VAL_USLEEP / 1000000)
1565 delay = (double) VAL_USLEEP / 1000000;
1566 else if (delay < 0.1) {
1567 delay += 0.01;
1568 if (delay > 0.1)
1569 delay = 0.2;
1570 } else if (delay < 1.) {
1571 delay += 0.1;
1572 if (delay > 1.0)
1573 delay = 2.;
1574 } else if (delay < 60.)
1575 delay += 1.;
1576 else if (delay < 300.)
1577 delay += 10.;
1578 else if (delay < 3600.)
1579 delay += 60.;
1580 else if (delay < MAX_DELAY_SEC)
1581 delay += 360.;
1583 if (delay > MAX_DELAY_SEC)
1584 delay = MAX_DELAY_SEC;
1585 } else {
1586 if (delay > 3600.)
1587 delay -= 360.;
1588 else if (delay > 300.)
1589 delay -= 60.;
1590 else if (delay > 60.)
1591 delay -= 10.;
1592 else if (delay > 1.)
1593 delay -= 1.;
1594 else if (delay > 0.1)
1595 delay -= 0.1;
1596 else if (delay > (double) VAL_USLEEP / 1000000)
1597 delay -= 0.01;
1598 else
1599 delay = 0.0;
1601 if (delay < (double) VAL_USLEEP / 1000000)
1602 delay = 0.0;
1605 tdelay.tv_sec = (int) floor(delay);
1606 tdelay.tv_usec = (int) ((delay - tdelay.tv_sec) * 1000000);
1608 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
1609 0, 15, 60, 10, 2, 14);
1611 display_zoom();
1612 return;
1617 void zooming(int facto)
1619 if (facto)
1620 zoom /= ZOOM_FACTOR;
1621 else
1622 zoom *= ZOOM_FACTOR;
1623 zoom = MAX(zoom, ZOOM_MIN);
1624 zoom = MIN(zoom, ZOOM_MAX);
1625 if (p_type == PTRANDOM) {
1626 addlong = dv_long;
1627 addlat = dv_lat;
1628 stoprand = STOP_RANDOM_FACTOR;
1630 calcDistance();
1631 do_something = TRUE;
1632 return;
1637 static void move_zoom(int factor)
1639 if (factor == -1)
1640 zooming(1);
1641 else
1642 zooming(0);
1643 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
1644 0, 15, 60, 10, 2, 38);
1645 display_zoom();
1646 return;
1651 static void screen_3()
1653 int ok, ckm, waitrel, sensadd, not3;
1654 struct timeval tin;
1656 #ifdef DEBUG
1657 fprintf(stdout, "scr 3\n");
1658 #endif
1659 tin = getimev();
1660 waitrel = 0;
1661 ckm = 0;
1662 sensadd = 0;
1663 not3 = TRUE;
1664 XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, scrdate.mask,
1665 ShapeSet);
1666 XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, scrdate.mask,
1667 ShapeSet);
1669 XCopyArea(dpy, scrdate.pixmap, wmg.pixmap, NormalGC, 0, 0, DIAMETRE,
1670 DIAMETRE, 0, 0);
1672 AddMouseRegion(1, 2, 14, DIAMETRE - 2, 25);
1673 AddMouseRegion(2, 2, 38, DIAMETRE - 2, 49);
1674 display_zoom();
1676 ok = TRUE;
1677 while (ok) {
1679 while (XPending(dpy)) {
1680 XNextEvent(dpy, &Event);
1681 switch (Event.type) {
1682 case Expose:
1683 RedrawWindowXYWH(0, 0, DIAMETRE, DIAMETRE);
1684 break;
1685 case DestroyNotify:
1686 XCloseDisplay(dpy);
1687 exit(0);
1688 break;
1689 case ButtonPress:
1690 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
1691 waitrel = 1;
1692 press_but(ckm);
1693 switch (Event.xbutton.button) {
1694 case 1:
1695 not3 = TRUE;
1696 sensadd = 1;
1697 break;
1698 case 2:
1699 not3 = TRUE;
1700 sensadd = -1;
1701 break;
1702 case 3:
1703 not3 = FALSE;
1704 if (ckm < 5)
1705 gotoscr = 0;
1706 break;
1707 default:
1708 break;
1710 break;
1711 case ButtonRelease:
1712 release_but(ckm);
1713 waitrel = ckm;
1714 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
1715 if (waitrel == ckm) {
1716 switch (ckm) {
1717 case 5:
1718 gotoscr--;
1719 if (gotoscr == 0)
1720 gotoscr = NUM_SCREEN;
1721 break;
1722 case 6:
1723 gotoscr++;
1724 if (gotoscr > NUM_SCREEN)
1725 gotoscr = 1;
1726 break;
1727 case 7:
1728 gotoscr = 0;
1729 default:
1730 break;
1733 ckm = 0;
1734 waitrel = 0;
1735 tin = getimev();
1736 break;
1737 default:
1738 break;
1742 usleep(VAL_USLEEP_SHORT);
1743 if (waitrel && not3) {
1744 if (ckm == 1) {
1745 move_delay(sensadd);
1746 usleep(2 * VAL_USLEEP);
1748 if (ckm == 2) {
1749 move_zoom(sensadd);
1750 usleep(VAL_USLEEP);
1753 if (waitrel == 0 && diftimev(getimev(), tin).tv_sec > SCREEN_WAIT
1754 && gotoscr == 3)
1755 gotoscr = 0;
1756 if (gotoscr != 3)
1757 ok = FALSE;
1759 return;
1764 static void display_light()
1766 char datest[32];
1767 int i;
1769 write_icon(" light :", 2, 2);
1770 RedrawWindowXYWH(2, 2, DIAMETRE - 1, DIAMETRE - 1);
1772 sprintf(datest, "%.2f", ambient_light);
1773 i = 10 - strlen(datest);
1774 if (i < 0)
1775 i = 0;
1776 else
1777 i = i / 2;
1778 write_icon(datest, 2 + i * 6, 14);
1779 RedrawWindowXYWH(2, 14, DIAMETRE - 1, DIAMETRE - 1);
1781 write_icon(" dawn :", 2, 26);
1782 RedrawWindowXYWH(2, 26, DIAMETRE - 1, DIAMETRE - 1);
1784 dawn = (1.0 - dawn) * 2.0;
1785 sprintf(datest, "%.2f", dawn);
1786 dawn = (1.0 - dawn / 2.0);
1787 i = 10 - strlen(datest);
1788 if (i < 0)
1789 i = 0;
1790 else
1791 i = i / 2;
1792 write_icon(datest, 2 + i * 6, 38);
1793 RedrawWindowXYWH(2, 38, DIAMETRE - 1, DIAMETRE - 1);
1795 return;
1800 static void move_light(int factor)
1802 ambient_light += factor / 20.0;
1803 ambient_light = MAX(0.0, ambient_light);
1804 ambient_light = MIN(1.0, ambient_light);
1805 aml = (int) floor(ambient_light * 256);
1807 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
1808 0, 15, 60, 10, 2, 14);
1810 display_light();
1811 return;
1816 static void move_dawn(int factor)
1818 dawn = (1.0 - dawn) * 2.0;
1819 dawn += factor / 20.0;
1820 dawn = MAX(0.0, dawn);
1821 dawn = MIN(1.0, dawn);
1822 dawn = (1.0 - dawn / 2.0);
1823 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
1824 0, 15, 60, 10, 2, 38);
1826 display_light();
1827 return;
1832 static void screen_4()
1834 int ok, ckm, waitrel, sensadd, not3;
1835 struct timeval tin;
1837 #ifdef DEBUG
1838 fprintf(stdout, "scr 4\n");
1839 #endif
1840 tin = getimev();
1841 waitrel = 0;
1842 ckm = 0;
1843 sensadd = 0;
1844 not3 = TRUE;
1845 XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, scrdate.mask,
1846 ShapeSet);
1847 XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, scrdate.mask,
1848 ShapeSet);
1850 XCopyArea(dpy, scrdate.pixmap, wmg.pixmap, NormalGC, 0, 0, DIAMETRE,
1851 DIAMETRE, 0, 0);
1853 AddMouseRegion(1, 2, 14, DIAMETRE - 2, 25);
1854 AddMouseRegion(2, 2, 38, DIAMETRE - 2, 49);
1855 display_light();
1857 ok = TRUE;
1858 while (ok) {
1860 while (XPending(dpy)) {
1861 XNextEvent(dpy, &Event);
1862 switch (Event.type) {
1863 case Expose:
1864 RedrawWindowXYWH(0, 0, DIAMETRE, DIAMETRE);
1865 break;
1866 case DestroyNotify:
1867 XCloseDisplay(dpy);
1868 exit(0);
1869 break;
1870 case ButtonPress:
1871 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
1872 waitrel = 1;
1873 press_but(ckm);
1874 switch (Event.xbutton.button) {
1875 case 1:
1876 not3 = TRUE;
1877 sensadd = 1;
1878 break;
1879 case 2:
1880 not3 = TRUE;
1881 sensadd = -1;
1882 break;
1883 case 3:
1884 not3 = FALSE;
1885 if (ckm < 5)
1886 gotoscr = 0;
1887 break;
1888 default:
1889 break;
1891 break;
1892 case ButtonRelease:
1893 release_but(ckm);
1894 waitrel = ckm;
1895 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
1896 if (waitrel == ckm) {
1897 switch (ckm) {
1898 case 5:
1899 gotoscr--;
1900 if (gotoscr == 0)
1901 gotoscr = NUM_SCREEN;
1902 break;
1903 case 6:
1904 gotoscr++;
1905 if (gotoscr > NUM_SCREEN)
1906 gotoscr = 1;
1907 break;
1908 case 7:
1909 gotoscr = 0;
1910 default:
1911 break;
1914 ckm = 0;
1915 waitrel = 0;
1916 tin = getimev();
1917 break;
1918 default:
1919 break;
1922 usleep(VAL_USLEEP_SHORT);
1923 if (waitrel && not3) {
1924 if (ckm == 1) {
1925 move_light(sensadd);
1926 usleep(VAL_USLEEP);
1928 if (ckm == 2) {
1929 move_dawn(sensadd);
1930 usleep(VAL_USLEEP);
1933 if (waitrel == 0 && diftimev(getimev(), tin).tv_sec > SCREEN_WAIT
1934 && gotoscr == 4)
1935 gotoscr = 0;
1936 if (gotoscr != 4)
1937 ok = FALSE;
1939 return;
1944 static void display_accel()
1946 char datest[32];
1947 int i;
1949 write_icon(" accel :", 2, 2);
1950 RedrawWindowXYWH(2, 2, DIAMETRE - 1, DIAMETRE - 1);
1952 if (time_multi < 24.0)
1953 sprintf(datest, "%.1f", time_multi);
1954 else
1955 sprintf(datest, "%.0f", time_multi);
1957 i = 10 - strlen(datest);
1958 if (i < 0)
1959 i = 0;
1960 else
1961 i = i / 2;
1962 write_icon(datest, 2 + i * 6, 14);
1963 RedrawWindowXYWH(2, 14, DIAMETRE - 1, DIAMETRE - 1);
1965 write_icon("night map:", 2, 26);
1966 RedrawWindowXYWH(2, 26, DIAMETRE - 1, DIAMETRE - 1);
1968 if (use_nightmap)
1969 write_icon(" yes ", 2, 38);
1970 else
1971 write_icon(" no ", 2, 38);
1973 RedrawWindowXYWH(2, 38, DIAMETRE - 1, DIAMETRE - 1);
1975 return;
1980 static void move_accel(int factor)
1982 if (factor == 1) {
1983 if (time_multi < 1.0)
1984 time_multi = 1.0;
1985 if (time_multi < 24.0)
1986 time_multi += 0.2;
1987 else if (time_multi < 60.0) {
1988 time_multi = floor(time_multi);
1989 time_multi += 1.0;
1990 } else if (time_multi < 120.0) {
1991 time_multi = floor(time_multi);
1992 time_multi += 2.0;
1993 } else if (time_multi < 240.0) {
1994 time_multi = floor(time_multi);
1995 time_multi += 4.0;
1996 } else if (time_multi < 600.0) {
1997 time_multi = floor(time_multi);
1998 time_multi += 10.0;
1999 } else if (time_multi < 1200.0) {
2000 time_multi = floor(time_multi);
2001 time_multi += 20.0;
2002 } else if (time_multi < 2400.0) {
2003 time_multi = floor(time_multi);
2004 time_multi += 40.0;
2005 } else if (time_multi < 6000.0) {
2006 time_multi = floor(time_multi);
2007 time_multi += 100.0;
2008 } else if (time_multi < 12000.0) {
2009 time_multi = floor(time_multi);
2010 time_multi += 200.0;
2011 } else if (time_multi < 24000.0) {
2012 time_multi = floor(time_multi);
2013 time_multi += 400.0;
2014 } else if (time_multi < 60000.0) {
2015 time_multi = floor(time_multi);
2016 time_multi += 1000.0;
2017 } else if (time_multi < 120000.0) {
2018 time_multi = floor(time_multi);
2019 time_multi += 2000.0;
2020 } else if (time_multi < 240000.0) {
2021 time_multi = floor(time_multi);
2022 time_multi += 4000.0;
2023 } else {
2024 time_multi = floor(time_multi);
2025 time_multi += 8000.0;
2027 if (time_multi > MAX_MULTI_COEF)
2028 time_multi = MAX_MULTI_COEF;
2029 } else {
2030 if (time_multi < 24.1)
2031 time_multi -= 0.2;
2032 else if (time_multi < 60.2) {
2033 time_multi = floor(time_multi);
2034 time_multi -= 1.0;
2035 } else if (time_multi < 121.0) {
2036 time_multi = floor(time_multi);
2037 time_multi -= 2.0;
2038 } else if (time_multi < 241.0) {
2039 time_multi = floor(time_multi);
2040 time_multi -= 4.0;
2041 } else if (time_multi < 601.0) {
2042 time_multi = floor(time_multi);
2043 time_multi -= 10.0;
2044 } else if (time_multi < 1201.0) {
2045 time_multi = floor(time_multi);
2046 time_multi -= 20.0;
2047 } else if (time_multi < 2401.0) {
2048 time_multi = floor(time_multi);
2049 time_multi -= 40.0;
2050 } else if (time_multi < 6001.0) {
2051 time_multi = floor(time_multi);
2052 time_multi -= 100.0;
2053 } else if (time_multi < 12001.0) {
2054 time_multi = floor(time_multi);
2055 time_multi -= 200.0;
2056 } else if (time_multi < 24001.0) {
2057 time_multi = floor(time_multi);
2058 time_multi -= 400.0;
2059 } else if (time_multi < 60001.0) {
2060 time_multi = floor(time_multi);
2061 time_multi -= 1000.0;
2062 } else if (time_multi < 120001.0) {
2063 time_multi = floor(time_multi);
2064 time_multi -= 2000.0;
2065 } else if (time_multi < 240001.0) {
2066 time_multi = floor(time_multi);
2067 time_multi -= 4000.0;
2068 } else {
2069 time_multi = floor(time_multi);
2070 time_multi -= 8000.0;
2073 if (time_multi > 24.0)
2074 time_multi = floor(time_multi);
2075 if (time_multi < 1.0)
2076 time_multi = 1.0;
2079 tini = tlast;
2080 tbase = trend;
2082 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
2083 0, 15, 60, 10, 2, 14);
2085 display_accel();
2086 return;
2091 static void screen_5()
2093 int ok, ckm, waitrel, sensadd, not3;
2094 struct timeval tin;
2096 #ifdef DEBUG
2097 fprintf(stdout, "scr 5\n");
2098 #endif
2099 tin = getimev();
2100 waitrel = 0;
2101 ckm = 0;
2102 sensadd = 0;
2103 not3 = TRUE;
2104 XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, scrdate.mask,
2105 ShapeSet);
2106 XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, scrdate.mask,
2107 ShapeSet);
2109 XCopyArea(dpy, scrdate.pixmap, wmg.pixmap, NormalGC, 0, 0, DIAMETRE,
2110 DIAMETRE, 0, 0);
2112 AddMouseRegion(1, 2, 14, DIAMETRE - 2, 25);
2113 AddMouseRegion(2, 2, 38, DIAMETRE - 2, 49);
2114 display_accel();
2116 ok = TRUE;
2117 while (ok) {
2119 while (XPending(dpy)) {
2120 XNextEvent(dpy, &Event);
2121 switch (Event.type) {
2122 case Expose:
2123 RedrawWindowXYWH(0, 0, DIAMETRE, DIAMETRE);
2124 break;
2125 case DestroyNotify:
2126 XCloseDisplay(dpy);
2127 exit(0);
2128 break;
2129 case ButtonPress:
2130 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
2131 waitrel = 1;
2132 press_but(ckm);
2133 switch (Event.xbutton.button) {
2134 case 1:
2135 not3 = TRUE;
2136 sensadd = 1;
2137 break;
2138 case 2:
2139 not3 = TRUE;
2140 sensadd = -1;
2141 break;
2142 case 3:
2143 not3 = FALSE;
2144 if (ckm < 5)
2145 gotoscr = 0;
2146 break;
2147 default:
2148 break;
2150 break;
2151 case ButtonRelease:
2152 release_but(ckm);
2153 waitrel = ckm;
2154 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
2155 if (waitrel == ckm) {
2156 switch (ckm) {
2157 case 5:
2158 gotoscr--;
2159 if (gotoscr == 0)
2160 gotoscr = NUM_SCREEN;
2161 break;
2162 case 6:
2163 gotoscr++;
2164 if (gotoscr > NUM_SCREEN)
2165 gotoscr = 1;
2166 break;
2167 case 7:
2168 gotoscr = 0;
2169 default:
2170 break;
2173 ckm = 0;
2174 waitrel = 0;
2175 tin = getimev();
2176 break;
2177 default:
2178 break;
2182 usleep(VAL_USLEEP_SHORT);
2183 if (waitrel && not3) {
2184 if (ckm == 1) {
2185 move_accel(sensadd);
2186 usleep(VAL_USLEEP);
2188 if (ckm == 2) {
2189 not3 = FALSE;
2190 if (use_nightmap) {
2191 use_nightmap = FALSE;
2192 display_accel();
2193 } else {
2194 if (use_nmap_ini) {
2195 use_nightmap = TRUE;
2196 display_accel();
2199 usleep(VAL_USLEEP);
2202 if (waitrel == 0 && diftimev(getimev(), tin).tv_sec > SCREEN_WAIT
2203 && gotoscr == 5)
2204 gotoscr = 0;
2205 if (gotoscr != 5)
2206 ok = FALSE;
2208 return;
2213 static void display_dlat()
2215 char datest[32];
2216 int i, d, m, nega, nego;
2218 write_icon(" dlat :", 2, 2);
2219 RedrawWindowXYWH(2, 2, DIAMETRE - 1, DIAMETRE - 1);
2220 if (dlat < 0.0) {
2221 nega = TRUE;
2222 dlat *= -1;
2223 } else
2224 nega = FALSE;
2226 m = (int) floor((dlat - floor(dlat)) * 60.0);
2227 d = (int) floor(dlat);
2229 if (nega) {
2230 sprintf(datest, "-%d°%02d'", d, m);
2231 dlat *= -1;
2232 } else
2233 sprintf(datest, "%d°%02d'", d, m);
2235 i = 10 - strlen(datest);
2236 if (i < 0)
2237 i = 0;
2238 else
2239 i = i / 2;
2240 write_icon(datest, 2 + i * 6, 14);
2241 RedrawWindowXYWH(2, 14, DIAMETRE - 1, DIAMETRE - 1);
2243 write_icon(" dlong :", 2, 26);
2244 RedrawWindowXYWH(2, 26, DIAMETRE - 1, DIAMETRE - 1);
2247 if (dlong < 0.0) {
2248 nego = TRUE;
2249 dlong *= -1;
2250 } else
2251 nego = FALSE;
2253 m = (int) floor((dlong - floor(dlong)) * 60.0);
2254 d = (int) floor(dlong);
2256 if (nego) {
2257 sprintf(datest, "-%d°%02d'", d, m);
2258 dlong *= -1;
2259 } else
2260 sprintf(datest, "%d°%02d'", d, m);
2262 i = 10 - strlen(datest);
2263 if (i < 0)
2264 i = 0;
2265 else
2266 i = i / 2;
2267 write_icon(datest, 2 + i * 6, 38);
2268 RedrawWindowXYWH(2, 38, DIAMETRE - 1, DIAMETRE - 1);
2270 return;
2275 static void move_dlat(int factor)
2277 dlat += factor / 4.0;
2278 if (dlat > MAX_DELTA_LONG)
2279 dlat = MAX_DELTA_LONG;
2280 if (dlat < -MAX_DELTA_LONG)
2281 dlat = -MAX_DELTA_LONG;
2282 if (dlat < 0.25 && dlat > -0.25)
2283 dlat = 0;
2284 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
2285 0, 15, 60, 10, 2, 14);
2286 if (dlat != 0.)
2287 p_type = PTFIXED;
2288 display_dlat();
2289 return;
2294 static void move_dlong(int factor)
2296 dlong += factor / 4.0;
2297 if (dlong > MAX_DELTA_LONG)
2298 dlong = MAX_DELTA_LONG;
2299 if (dlong < -MAX_DELTA_LONG)
2300 dlong = -MAX_DELTA_LONG;
2301 if (dlong < 0.25 && dlong > -0.25)
2302 dlong = 0;
2303 XCopyArea(dpy, scrdiv.pixmap, wmg.pixmap, NormalGC,
2304 0, 15, 60, 10, 2, 38);
2305 if (dlong != 0.)
2306 p_type = PTFIXED;
2307 display_dlat();
2308 return;
2313 static void screen_6()
2315 int ok, ckm, waitrel, sensadd, not3;
2316 struct timeval tin;
2318 #ifdef DEBUG
2319 fprintf(stdout, "scr 6\n");
2320 #endif
2321 tin = getimev();
2322 waitrel = 0;
2323 sensadd = 0;
2324 ckm = 0;
2325 not3 = TRUE;
2326 XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, scrdate.mask,
2327 ShapeSet);
2328 XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, scrdate.mask,
2329 ShapeSet);
2331 XCopyArea(dpy, scrdate.pixmap, wmg.pixmap, NormalGC, 0, 0, DIAMETRE,
2332 DIAMETRE, 0, 0);
2333 AddMouseRegion(1, 2, 14, DIAMETRE - 2, 25);
2334 AddMouseRegion(2, 2, 38, DIAMETRE - 2, 49);
2336 display_dlat();
2338 ok = TRUE;
2339 while (ok) {
2341 while (XPending(dpy)) {
2342 XNextEvent(dpy, &Event);
2343 switch (Event.type) {
2344 case Expose:
2345 RedrawWindowXYWH(0, 0, DIAMETRE, DIAMETRE);
2346 break;
2347 case DestroyNotify:
2348 XCloseDisplay(dpy);
2349 exit(0);
2350 break;
2351 case ButtonPress:
2352 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
2353 waitrel = 1;
2354 press_but(ckm);
2355 switch (Event.xbutton.button) {
2356 case 1:
2357 not3 = TRUE;
2358 sensadd = 1;
2359 break;
2360 case 2:
2361 not3 = TRUE;
2362 sensadd = -1;
2363 break;
2364 case 3:
2365 not3 = FALSE;;
2366 if (ckm < 5)
2367 gotoscr = 0;
2368 break;
2369 default:
2370 break;
2372 break;
2373 case ButtonRelease:
2374 release_but(ckm);
2375 waitrel = ckm;
2376 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
2377 if (waitrel == ckm) {
2378 switch (ckm) {
2379 case 5:
2380 gotoscr--;
2381 if (gotoscr == 0)
2382 gotoscr = NUM_SCREEN;
2383 break;
2384 case 6:
2385 gotoscr++;
2386 if (gotoscr > NUM_SCREEN)
2387 gotoscr = 1;
2388 break;
2389 case 7:
2390 gotoscr = 0;
2391 default:
2392 break;
2395 ckm = 0;
2396 waitrel = 0;
2397 tin = getimev();
2398 break;
2399 default:
2400 break;
2404 usleep(VAL_USLEEP_SHORT);
2405 if (waitrel && not3) {
2406 if (ckm == 1 && p_type != PTRANDOM) {
2407 move_dlat(sensadd);
2408 usleep(VAL_USLEEP);
2410 if (ckm == 2 && p_type != PTRANDOM) {
2411 move_dlong(sensadd);
2412 usleep(VAL_USLEEP);
2415 if (waitrel == 0 && diftimev(getimev(), tin).tv_sec > SCREEN_WAIT
2416 && gotoscr == 6)
2417 gotoscr = 0;
2418 if (gotoscr != 6)
2419 ok = FALSE;
2421 return;
2426 static void display_type()
2428 char c, cc, mess[12];
2430 write_icon(" view :", 2, 2);
2431 RedrawWindowXYWH(2, 2, DIAMETRE - 1, DIAMETRE - 1);
2433 if (p_type == PTFIXED) {
2434 c = '>';
2435 cc = '<';
2436 } else {
2437 c = ' ';
2438 cc = ' ';
2440 sprintf(mess, "%c move %c", c, cc);
2441 write_icon(mess, 2, 14);
2442 RedrawWindowXYWH(2, 14, DIAMETRE - 1, DIAMETRE - 1);
2443 if (p_type == PTSUN) {
2444 c = '>';
2445 cc = '<';
2446 } else {
2447 c = ' ';
2448 cc = ' ';
2450 sprintf(mess, "%c sun %c", c, cc);
2451 write_icon(mess, 2, 26);
2452 RedrawWindowXYWH(2, 26, DIAMETRE - 1, DIAMETRE - 1);
2453 #if WITH_MARKERS
2454 if (p_type == PTMOON) {
2455 c = '>';
2456 cc = '<';
2457 } else {
2458 c = ' ';
2459 cc = ' ';
2461 sprintf(mess, "%c moon %c", c, cc);
2462 #else
2463 if (p_type == PTRANDOM) {
2464 c = '>';
2465 cc = '<';
2466 } else {
2467 c = ' ';
2468 cc = ' ';
2470 sprintf(mess, "%c random %c", c, cc);
2471 #endif
2472 write_icon(mess, 2, 38);
2473 RedrawWindowXYWH(2, 38, DIAMETRE - 1, DIAMETRE - 1);
2475 return;
2480 static void screen_7()
2482 int ok, ckm, waitrel, sensadd, not3;
2483 struct timeval tin;
2485 #ifdef DEBUG
2486 fprintf(stdout, "scr 7\n");
2487 #endif
2488 tin = getimev();
2489 waitrel = 0;
2490 sensadd = 0;
2491 ckm = 0;
2492 not3 = TRUE;
2494 XShapeCombineMask(dpy, win, ShapeBounding, 0, 0, scrdate.mask,
2495 ShapeSet);
2496 XShapeCombineMask(dpy, iconwin, ShapeBounding, 0, 0, scrdate.mask,
2497 ShapeSet);
2499 XCopyArea(dpy, scrdate.pixmap, wmg.pixmap, NormalGC, 0, 0, DIAMETRE,
2500 DIAMETRE, 0, 0);
2501 AddMouseRegion(1, 2, 14, DIAMETRE - 2, 25);
2502 AddMouseRegion(2, 2, 26, DIAMETRE - 2, 37);
2503 AddMouseRegion(3, 2, 38, DIAMETRE - 2, 49);
2505 display_type();
2507 ok = TRUE;
2508 while (ok) {
2510 while (XPending(dpy)) {
2511 XNextEvent(dpy, &Event);
2512 switch (Event.type) {
2513 case Expose:
2514 RedrawWindowXYWH(0, 0, DIAMETRE, DIAMETRE);
2515 break;
2516 case DestroyNotify:
2517 XCloseDisplay(dpy);
2518 exit(0);
2519 break;
2520 case ButtonPress:
2521 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
2522 waitrel = 1;
2523 press_but(ckm);
2524 switch (Event.xbutton.button) {
2525 case 1:
2526 not3 = TRUE;
2527 if (ckm < 4 && ckm > 0)
2528 sensadd = ckm;
2529 break;
2530 case 2:
2531 not3 = TRUE;
2532 break;
2533 case 3:
2534 not3 = FALSE;
2535 if (ckm < 5)
2536 gotoscr = 0;
2537 break;
2538 default:
2539 break;
2541 break;
2542 case ButtonRelease:
2543 release_but(ckm);
2544 waitrel = ckm;
2545 ckm = CheckMouseRegion(Event.xbutton.x, Event.xbutton.y);
2546 if (waitrel == ckm) {
2547 switch (ckm) {
2548 case 5:
2549 gotoscr--;
2550 if (gotoscr == 0)
2551 gotoscr = NUM_SCREEN;
2552 break;
2553 case 6:
2554 gotoscr++;
2555 if (gotoscr > NUM_SCREEN)
2556 gotoscr = 1;
2557 break;
2558 case 7:
2559 gotoscr = 0;
2560 default:
2561 break;
2564 ckm = 0;
2565 waitrel = 0;
2566 tin = getimev();
2567 break;
2568 default:
2569 break;
2572 usleep(VAL_USLEEP_SHORT);
2573 if (waitrel && not3 && sensadd) {
2574 if (sensadd == 2) {
2575 if (p_type != PTSUN) {
2576 p_type = PTSUN;
2577 dlat = 0;
2578 dlong = 0;
2579 display_type();
2582 if (sensadd == 1) {
2583 if (p_type != PTFIXED) {
2584 p_type = PTFIXED;
2585 display_type();
2588 if (sensadd == 3) {
2589 #if WITH_MARKERS
2590 if (p_type != PTMOON) {
2591 p_type = PTMOON;
2592 #else
2593 if (p_type != PTRANDOM) {
2594 p_type = PTRANDOM;
2595 #endif
2596 dlat = 0;
2597 dlong = 0;
2598 display_type();
2602 sensadd = 0;
2603 if (waitrel == 0 && diftimev(getimev(), tin).tv_sec > SCREEN_WAIT
2604 && gotoscr == 7)
2605 gotoscr = 0;
2606 if (gotoscr != 7)
2607 ok = FALSE;
2609 return;