Subversion Repositories public

Rev

Rev 104 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
88 andreas 1
/***************************************************************************
2
 *   Copyright (C) 2007 by Andreas Theofilu                             *
3
 *   andreas@theosys.at                                               *
4
 *                                                                         *
5
 *   This program is free software; you can redistribute it and/or modify  *
6
 *   it under the terms of the GNU General Public License as published by  *
7
 *   the Free Software Foundation version 3 of the License.                *
8
 *                                                                         *
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.                          *
13
 *                                                                         *
14
 *   You should have received a copy of the GNU General Public License     *
15
 *   along with this program; if not, write to the                         *
16
 *   Free Software Foundation, Inc.,                                       *
17
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
18
 ***************************************************************************/
19
 
20
#include <time.h>
21
#include <string.h>
22
#include "garmin.h"
23
#include "disassemble.h"
24
 
25
disassemble::disassemble()
26
{
27
	lap_node = 0;
28
	run_node = 0;
29
	point_node = 0;
30
}
31
 
32
disassemble::~disassemble()
33
{
34
	destroy();
35
}
36
 
37
void disassemble::destroy()
38
{
39
LAP_NODE *lakt, *ln;
40
RUN_NODE *rakt, *rn;
41
POINT_NODE *pakt, *pn;
42
 
43
	if (lap_node != NULL)		// free allocated laps
44
	{
45
	   lakt = lap_node;
46
 
47
	   while (lakt)
48
	   {
49
	      ln = lakt;
50
	      delete ln->lap;
51
	      lakt = lakt->next;
52
	      delete ln;
53
	   }
54
	}
55
 
56
	lap_node = NULL;
57
 
58
	if (lap_node != NULL)		// free allocated runs
59
	{
60
	   rakt = run_node;
61
 
62
	   while (rakt)
63
	   {
64
	      rn = rakt;
65
	      delete rn->run;
66
	      rakt = rakt->next;
67
	      delete rn;
68
	   }
69
	}
70
 
71
	run_node = NULL;
72
 
73
	if (point_node != NULL)		// free allocated points
74
	{
75
	   pakt = point_node;
76
 
77
	   while (pakt)
78
	   {
79
	      pn = pakt;
80
	      delete pn->point;
81
	      pakt = pakt->next;
82
	      delete pn;
83
	   }
84
	}
85
 
86
	point_node = NULL;
87
}
88
 
89
LAP_NODE *disassemble::addLap ()
90
{
91
LAP_NODE *akt, *n;
92
 
93
	if (lap_node == 0)		// First lap to add
94
	{
95
	   lap_node = new LAP_NODE;
96
	   lap_node->lap = new LAP;
97
 
98
	   memmove (lap_node->lap, &lap, sizeof(LAP));
99
	   lap_node->next = 0;
100
	   akt = lap_node;
101
	}
102
	else				// additional lap to add
103
	{
104
	   n = lap_node;
105
 
106
	   while (n->next)
107
	      n = n->next;
108
 
109
	   akt = new LAP_NODE;
110
	   akt->lap = new LAP;
111
	   memmove (akt->lap, &lap, sizeof(LAP));
112
	   akt->next = 0;
113
	   n->next = akt;
114
	}
115
 
116
	return akt;
117
}
118
 
119
LAP *disassemble::getLap(int index)
120
{
121
LAP_NODE *akt = lap_node;
122
 
123
	while (akt)
124
	{
125
	   if (akt->lap->index == (uint32)index)
126
	      return akt->lap;
127
 
128
	   akt = akt->next;
129
	}
130
 
131
	return NULL;
132
}
133
 
134
RUN_NODE *disassemble::addRun ()
135
{
136
RUN_NODE *akt, *n;
137
 
138
	if (run_node == 0)		// First run to add
139
	{
140
	   run_node = new RUN_NODE;
141
	   run_node->run = new RUN;
142
 
143
	   memmove (run_node->run, &run, sizeof(RUN));
144
	   run_node->next = 0;
145
	   akt = run_node;
146
	}
147
	else				// additional run to add
148
	{
149
	   n = run_node;
150
 
151
	   while (n != NULL && n->next != NULL)
152
	      n = n->next;
153
 
154
	   akt = new RUN_NODE;
155
	   akt->run = new RUN;
156
	   memmove (akt->run, &run, sizeof(RUN));
157
	   akt->next = 0;
158
	   n->next = akt;
159
	}
160
 
161
	return akt;
162
}
163
 
164
POINT_NODE *disassemble::addPoint ()
165
{
166
POINT_NODE *akt, *n;
167
 
168
	if (point_node == 0)		// First point to add
169
	{
170
	   point_node = new POINT_NODE;
171
	   point_node->point = new POINT;
172
 
173
	   memmove (point_node->point, &point, sizeof(POINT));
174
	   point_node->number = 0;
175
	   point_node->next = 0;
176
	   akt = point_node;
177
	}
178
	else				// additional point to add
179
	{
180
	   n = point_node;
181
 
182
	   while (n != NULL && n->next != NULL)
183
	      n = n->next;
184
 
185
	   akt = new POINT_NODE;
186
	   akt->point = new POINT;
187
	   memmove (akt->point, &point, sizeof(point));
188
	   akt->number = n->number + 1;
189
	   akt->next = 0;
190
	   n->next = akt;
191
	}
192
 
193
	return akt;
194
}
195
 
196
POINT *disassemble::getPoint(int number)
197
{
198
POINT_NODE *akt;
199
 
200
	akt = point_node;
201
 
202
	while (akt)
203
	{
204
	   if (akt->number == number)
205
	      return akt->point;
206
 
207
	   akt = akt->next;
208
	}
209
 
210
	return 0;
211
}
212
 
213
POINT *disassemble::getPoint(uint32 time)
214
{
215
POINT_NODE *akt;
216
 
217
	akt = point_node;
218
 
219
	while (akt)
220
	{
221
	   if (akt->point->time >= time)
222
	      return akt->point;
223
 
224
	   akt = akt->next;
225
	}
226
 
227
	return 0;
228
}
229
 
230
/* 
231
   This file contains functions to get Garmin datatypes.
232
   The functions aim to reproduce the data losslessly, including
233
   floating point data, such that the data can be scanned back from the
234
   output and reconstructed exactly.
235
*/
236
 
237
void disassemble::garmin_print_dlist (garmin_list *l)
238
{
239
garmin_list_node *n;
240
 
241
	for (n = l->head; n != NULL; n = n->next)
242
	{
243
	   garmin_print_data(n->data);
244
	}
245
}
246
 
247
 
248
/* Support function to print a time value in ISO 8601 compliant format */
249
 
250
char *disassemble::garmin_print_dtime (uint32 t)
251
{
252
time_t     tval;
253
struct tm  tmval;
254
char       buf[128], hv0[128];
255
int        len;
256
 
257
	/* 
258
	                                012345678901234567890123
259
	   This will make, for example, 2007-04-20T23:55:01-0700, but that date
260
	   isn't quite ISO 8601 compliant.  We need to stick a ':' in the time
261
	   zone between the hours and the minutes.
262
	*/
263
 
264
	tval = t + TIME_OFFSET;
265
	localtime_r(&tval,&tmval);
266
	strftime(buf,sizeof(buf)-1,"%FT%T%z",&tmval);
267
 
268
	/* 
269
	   If the last character is a 'Z', don't do anything.  Otherwise, we 
270
	   need to move the last two characters out one and stick a colon in 
271
	   the vacated spot.  Let's not forget the trailing '\0' that needs to 
272
	   be moved as well.
273
	*/
274
 
275
	len = strlen(buf);
276
 
277
	if ( len > 0 && buf[len-1] != 'Z' )
278
	{
279
	   memmove(buf+len-1,buf+len-2,3);
280
	   buf[len-2] = ':';
281
	}
282
 
283
	/* OK.  Done. */
284
 
285
	sprintf(hv0,"%s", buf);
286
	return (char *)&hv0[0];
287
}
288
 
289
 
290
/* Support function to print a position type */
291
 
292
void disassemble::garmin_print_dpos (position_type *pos, double *lat, double *lon)
293
{
294
	if ( pos->lat != 0x7fffffff )
295
	   *lat = SEMI2DEG(pos->lat);
296
 
297
	if ( pos->lon != 0x7fffffff )
298
	   *lon = SEMI2DEG(pos->lon);
299
}
300
 
301
 
302
/* 
303
   Print a float32 with enough precision such that it can be reconstructed
304
   exactly from its decimal representation.
305
*/
306
 
307
char *disassemble::garmin_print_float32 (float32 f, char *ret)
308
{
309
	if (!ret)
310
	   return NULL;
311
 
312
	if ( f > 100000000.0 || f < -100000000.0 )
313
	    sprintf(ret, "%.9e",f);
314
	else if ( f > 10000000.0 || f < -10000000.0 )
315
	   sprintf(ret, "%.1f",f);
316
	else if ( f > 1000000.0 || f < -1000000.0 )
317
	   sprintf(ret, "%.2f",f);
318
	else if ( f > 100000.0 || f < -100000.0 )
319
	   sprintf(ret, "%.3f",f);
320
	else if ( f > 10000.0 || f < -10000.0 )
321
	   sprintf(ret, "%.4f",f);
322
	else if ( f > 1000.0 || f < -1000.0 )
323
	   sprintf(ret, "%.5f",f);
324
	else if ( f > 100.0 || f < -100.0 )
325
	   sprintf(ret, "%.6f",f);
326
	else if ( f > 10.0 || f < -10.0 )
327
	   sprintf(ret, "%.7f",f);
328
	else if ( f > 1.0 || f < -1.0 )
329
	   sprintf(ret, "%.8f",f);
330
	else if ( f > 0.1 || f < -0.1 )
331
	   sprintf(ret, "%.9f",f);
332
	else if ( f != 0 )
333
	   sprintf(ret, "%.9e",f);
334
	else
335
	   sprintf(ret, "%.8f",f);
336
 
337
	return ret;
338
}
339
 
340
 
341
/* 
342
   Print a float64 with enough precision such that it can be reconstructed
343
   exactly from its decimal representation.
344
*/
345
 
346
char *disassemble::garmin_print_float64 (float64 f, char *ret)
347
{
348
	if ( f > 10000000000000000.0 || f < -10000000000000000.0 )
349
	   sprintf(ret,"%.17e",f);
350
	else if ( f > 1000000000000000.0 || f < -1000000000000000.0 )
351
	   sprintf(ret,"%.1f",f);
352
	else if ( f > 100000000000000.0 || f < -100000000000000.0 )
353
	   sprintf(ret,"%.2f",f);
354
	else if ( f > 10000000000000.0 || f < -10000000000000.0 )
355
	   sprintf(ret,"%.3f",f);
356
	else if ( f > 1000000000000.0 || f < -1000000000000.0 )
357
	   sprintf(ret,"%.4f",f);
358
	else if ( f > 100000000000.0 || f < -100000000000.0 )
359
	   sprintf(ret,"%.5f",f);
360
	else if ( f > 10000000000.0 || f < -10000000000.0 )
361
	   sprintf(ret,"%.6f",f);
362
	else if ( f > 1000000000.0 || f < -1000000000.0 )
363
	   sprintf(ret,"%.7f",f);
364
	else if ( f > 100000000.0 || f < -100000000.0 )
365
	   sprintf(ret,"%.8f",f);
366
	else if ( f > 10000000.0 || f < -10000000.0 )
367
	   sprintf(ret,"%.9f",f);
368
	else if ( f > 1000000.0 || f < -1000000.0 )
369
	   sprintf(ret,"%.10f",f);
370
	else if ( f > 100000.0 || f < -100000.0 )
371
	   sprintf(ret,"%.11f",f);
372
	else if ( f > 10000.0 || f < -10000.0 )
373
	   sprintf(ret,"%.12f",f);
374
	else if ( f > 1000.0 || f < -1000.0 )
375
	   sprintf(ret,"%.13f",f);
376
	else if ( f > 100.0 || f < -100.0 )
377
	   sprintf(ret,"%.14f",f);
378
	else if ( f > 10.0 || f < -10.0 )
379
	   sprintf(ret,"%.15f",f);
380
	else if ( f > 1.0 || f < -1.0 )
381
	   sprintf(ret,"%.16f",f);
382
	else if ( f > 0.1 || f < -0.1 )
383
	   sprintf(ret,"%.17f",f);
384
	else if ( f != 0 )
385
	   sprintf(ret,"%.17e",f);
386
	else
387
	   sprintf(ret,"%.16f",f);
388
 
389
	return ret;
390
}
391
 
392
 
393
/* 
394
   Print a float32 whose value is invalid (and should not be printed) if 
395
   greater than 1.0e24 
396
*/
397
 
398
char *disassemble::garmin_print_dfloat32 (float32 f, char *ret)
399
{
400
	if (!ret)
401
	   return NULL;
402
 
403
	if ( f < 1.0e24 )
404
	   garmin_print_float32(f, ret);
405
 
406
	return ret;
407
}
408
 
409
 
410
/* Print a duration and distance. */
411
 
412
char *disassemble::garmin_print_ddist (uint32 dur, char *ret)
413
{
414
int  hun;
415
int  sec;
416
int  min;
417
int  hrs;
418
 
419
	if (!ret)
420
	   return NULL;
421
 
422
	hun  = dur % 100;
423
	dur -= hun;
424
	dur /= 100;
425
	sec  = dur % 60;
426
	dur -= sec;
427
	dur /= 60;
428
	min  = dur % 60;
429
	dur -= min;
430
	dur /= 60;
431
	hrs  = dur;
432
 
433
	sprintf(ret,"%d:%02d:%02d.%02d", hrs, min, sec, hun);
434
	return ret;
435
}
436
 
437
 
438
/* --------------------------------------------------------------------------*/
439
/* 7.4.1  D100                                                               */
440
/* --------------------------------------------------------------------------*/
441
 
442
void disassemble::garmin_print_d100 (D100 *x)
443
{
444
	memset (&waypoint, 0, sizeof(WAYPOINT));
445
	waypoint.type = 100;
446
	strncpy (waypoint.ident, x->ident, 5);
447
	waypoint.posn = x->posn;
448
	strncpy(waypoint.cmnt, x->cmnt, 40);
449
}
450
 
451
 
452
/* --------------------------------------------------------------------------*/
453
/* 7.4.2  D101                                                               */
454
/* --------------------------------------------------------------------------*/
455
 
456
void disassemble::garmin_print_d101 (D101 *x)
457
{
458
	memset (&waypoint, 0, sizeof(WAYPOINT));
459
	waypoint.type = 101;
460
	strncpy (waypoint.ident, x->ident, sizeof(waypoint.ident)-1);
461
	waypoint.posn = x->posn;
462
	strncpy (waypoint.cmnt, x->cmnt, sizeof(waypoint.cmnt)-1);
463
	waypoint.dst = x->dst;
464
	waypoint.smbl = x->smbl;
465
}
466
 
467
 
468
/* --------------------------------------------------------------------------*/
469
/* 7.4.3  D102                                                               */
470
/* --------------------------------------------------------------------------*/
471
 
472
void disassemble::garmin_print_d102 (D102 *x)
473
{
474
	garmin_print_d101 ((D101 *)x);
475
	waypoint.type = 102;
476
}
477
 
478
 
479
/* --------------------------------------------------------------------------*/
480
/* 7.4.4  D103                                                               */
481
/* --------------------------------------------------------------------------*/
482
 
483
 
484
void disassemble::garmin_print_d103 (D103 *x)
485
{
486
	garmin_print_d101((D101 *)x);
487
	waypoint.type = 103;
488
//	GARMIN_TAGSTR(1,"symbol",garmin_d103_smbl(x->smbl));
489
//	GARMIN_TAGSTR(1,"display",garmin_d103_dspl(x->dspl));
490
}
491
 
492
 
493
/* --------------------------------------------------------------------------*/
494
/* 7.4.5  D104                                                               */
495
/* --------------------------------------------------------------------------*/
496
 
497
void disassemble::garmin_print_d104 (D104 *x)
498
{
499
	garmin_print_d101((D101 *)x);
500
	waypoint.dspl = x->dspl;
501
	waypoint.type = 104;
502
//	GARMIN_TAGF32(1,"proximity_distance",x->dst);
503
//	GARMIN_TAGSTR(1,"display",garmin_d104_dspl(x->dspl));
504
}
505
 
506
 
507
/* --------------------------------------------------------------------------*/
508
/* 7.4.6  D105                                                               */
509
/* --------------------------------------------------------------------------*/
510
 
511
void disassemble::garmin_print_d105 (D105 *x)
512
{
513
	memset (&waypoint, 0, sizeof(WAYPOINT));
514
	waypoint.type = 105;
515
	waypoint.wpt_ident = x->wpt_ident;
516
	waypoint.posn = x->posn;
517
	waypoint.smbl = x->smbl;
518
}
519
 
520
 
521
/* --------------------------------------------------------------------------*/
522
/* 7.4.7  D106                                                               */
523
/* --------------------------------------------------------------------------*/
524
 
525
void disassemble::garmin_print_d106 (D106 *x)
526
{
527
	memset (&waypoint, 0, sizeof(WAYPOINT));
528
	waypoint.type = 106;
529
	waypoint.wpt_class = x->wpt_class;
530
	waypoint.subclass[0] = 0;
531
 
532
	if ( x->wpt_class != 0 )
533
	{
534
	   strncpy ((char *)waypoint.subclass, (char *)x->subclass, 13);
535
	   waypoint.subclass[13] = 0;
536
	}
537
 
538
	waypoint.wpt_ident = x->wpt_ident;
539
	waypoint.posn = x->posn;
540
	waypoint.smbl = x->smbl;
541
	waypoint.lnk_ident = x->lnk_ident;
542
}
543
 
544
 
545
/* --------------------------------------------------------------------------*/
546
/* 7.4.8  D107                                                               */
547
/* --------------------------------------------------------------------------*/
548
 
549
void disassemble::garmin_print_d107 (D107 *x)
550
{
551
	memset (&waypoint, 0, sizeof(WAYPOINT));
552
	waypoint.type = 107;
553
	strncpy(waypoint.ident, x->ident, sizeof(waypoint.ident)-1);
554
	waypoint.posn = x->posn;
555
	strncpy(waypoint.cmnt, x->cmnt, sizeof(waypoint.cmnt)-1);
556
	waypoint.dst = x->dst;
557
	waypoint.smbl = x->smbl;
558
	waypoint.dspl = x->dspl;
559
	waypoint.color = x->color;
560
}
561
 
562
 
563
/* --------------------------------------------------------------------------*/
564
/* 7.4.9  D108                                                               */
565
/* --------------------------------------------------------------------------*/
566
 
567
void disassemble::garmin_print_d108 (D108 *x)
568
{
569
	memset(&waypoint, 0, sizeof(WAYPOINT));
570
	waypoint.type = 108;
571
	waypoint.identity = x->ident;
572
	waypoint.posn = x->posn;
573
	waypoint.comment = x->comment;
574
	waypoint.smbl = x->smbl;
575
	waypoint.dspl = x->dspl;
576
	waypoint.wpt_class = x->wpt_class;
577
	strncpy((char *)waypoint.subclass, (char *)x->subclass, 18);
578
	waypoint.attr = x->attr;
579
	waypoint.color = x->color;
580
	waypoint.alt = x->alt;
581
	waypoint.dpth = x->dpth;
582
	waypoint.dst = x->dist;
583
	waypoint.facility = x->facility;
584
	waypoint.city = x->city;
585
	waypoint.addr = x->addr;
586
	waypoint.cross_road = x->cross_road;
587
}
588
 
589
 
590
/* --------------------------------------------------------------------------*/
591
/* 7.4.10  D109                                                              */
592
/* --------------------------------------------------------------------------*/
593
 
594
void disassemble::garmin_print_d109 (D109 *x)
595
{
596
uint8 color = x->dspl_color & 0x1f;
597
 
598
	if (color == 0x1f)
599
	   color = D108_default_color;
600
 
601
	memset(&waypoint, 0, sizeof(WAYPOINT));
602
	waypoint.type = 109;
603
	waypoint.identity = x->ident;
604
	waypoint.posn = x->posn;
605
	waypoint.comment = x->comment;
606
	waypoint.smbl = x->smbl;
607
	waypoint.wpt_class = x->wpt_class;
608
	strncpy((char *)waypoint.subclass, (char *)x->subclass, 18);
609
	waypoint.attr = x->attr;
610
	waypoint.color = color;
611
	waypoint.alt = x->alt;
612
	waypoint.dtyp = x->dtyp;
613
	waypoint.ete = x->ete;
614
	waypoint.dpth = x->dpth;
615
	waypoint.dst = x->dist;
616
	waypoint.facility = x->facility;
617
	waypoint.city = x->city;
618
	waypoint.addr = x->addr;
619
	waypoint.cross_road = x->cross_road;
620
}
621
 
622
 
623
/* --------------------------------------------------------------------------*/
624
/* 7.4.11  D110                                                              */
625
/* --------------------------------------------------------------------------*/
626
 
627
void disassemble::garmin_print_d110 (D110 *x)
628
{
629
	memset(&waypoint, 0, sizeof(WAYPOINT));
630
	waypoint.type = 110;
631
	waypoint.identity = x->ident;
632
	waypoint.posn = x->posn;
633
	waypoint.comment = x->comment;
634
	waypoint.smbl = x->smbl;
635
	waypoint.wpt_class = x->wpt_class;
636
	strncpy((char *)waypoint.subclass, (char *)x->subclass, 18);
637
	waypoint.attr = x->attr;
638
	waypoint.alt = x->alt;
639
	waypoint.dtyp = x->dtyp;
640
	waypoint.ete = x->ete;
641
	waypoint.dpth = x->dpth;
642
	waypoint.dst = x->dist;
643
	waypoint.facility = x->facility;
644
	waypoint.city = x->city;
645
	waypoint.addr = x->addr;
646
	waypoint.cross_road = x->cross_road;
647
 
648
/*  GARMIN_TAGSTR(1,"wpt_class",garmin_d110_wpt_class(x->wpt_class));
649
  GARMIN_TAGSTR(1,"color",garmin_d110_color((x->dspl_color) & 0x1f));
650
  GARMIN_TAGSTR(1,"display",garmin_d110_dspl((x->dspl_color >> 5) & 0x03));
651
  GARMIN_TAGSYM(1,"symbol",x->smbl);
652
  if ( x->temp < 1.0e24 ) GARMIN_TAGF32(1,"temperature",x->temp);
653
  GARMIN_TAGSTR(1,"state",x->state);
654
  GARMIN_TAGSTR(1,"country_code",x->cc);
655
  if ( x->time != 0xffffffff ) GARMIN_TAGU32(1,"time",x->time);
656
  GARMIN_TAGHEX(1,"category",x->wpt_cat); */
657
}
658
 
659
 
660
/* --------------------------------------------------------------------------*/
661
/* 7.4.12  D120                                                              */
662
/* --------------------------------------------------------------------------*/
663
 
664
void disassemble::garmin_print_d120 (D120 *x)
665
{
666
	memset(&wpcategory, 0, sizeof(WPCATEGORY));
667
	strncpy(wpcategory.name, x->name, 17);
668
}
669
 
670
 
671
/* --------------------------------------------------------------------------*/
672
/* 7.4.13  D150                                                              */
673
/* --------------------------------------------------------------------------*/
674
 
675
void disassemble::garmin_print_d150 (D150 *x)
676
{
677
	memset(&waypoint, 0, sizeof(WAYPOINT));
678
	waypoint.type = 150;
679
	strncpy(waypoint.ident, x->ident, sizeof(waypoint.ident)-1);
680
	waypoint.wpt_class = x->wpt_class;
681
	waypoint.posn = x->posn;
682
	strncpy(waypoint.cmnt, x->cmnt, sizeof(waypoint.cmnt)-1);
683
 
684
	if (x->wpt_class != D150_usr_wpt_class)
685
	{
686
	   waypoint.city = x->city;
687
	   strncpy(waypoint.state, x->state, 2);
688
	   waypoint.facility = x->name;
689
	   strncpy(waypoint.cc, x->cc, 2);
690
	}
691
 
692
	if (x->wpt_class == D150_apt_wpt_class)
693
	   waypoint.alt = x->alt;
694
}
695
 
696
 
697
/* --------------------------------------------------------------------------*/
698
/* 7.4.14  D151                                                              */
699
/* --------------------------------------------------------------------------*/
700
 
701
void disassemble::garmin_print_d151 (D151 *x)
702
{
703
	memset(&waypoint, 0, sizeof(WAYPOINT));
704
	waypoint.type = 151;
705
	strncpy(waypoint.ident, x->ident, sizeof(waypoint.ident)-1);
706
	waypoint.wpt_class = x->wpt_class;
707
	waypoint.posn = x->posn;
708
	strncpy(waypoint.cmnt, x->cmnt, sizeof(waypoint.cmnt)-1);
709
	waypoint.dst = x->dst;
710
 
711
	if (x->wpt_class != D150_usr_wpt_class)
712
	{
713
	   waypoint.city = x->city;
714
	   strncpy(waypoint.state, x->state, 2);
715
	   waypoint.facility = x->name;
716
	   strncpy(waypoint.cc, x->cc, 2);
717
	}
718
 
719
	if (x->wpt_class == D150_apt_wpt_class)
720
	   waypoint.alt = x->alt;
721
}
722
 
723
 
724
/* --------------------------------------------------------------------------*/
725
/* 7.4.15  D152                                                              */
726
/* --------------------------------------------------------------------------*/
727
 
728
void disassemble::garmin_print_d152 (D152 *x)
729
{
730
	memset(&waypoint, 0, sizeof(WAYPOINT));
731
	waypoint.type = 152;
732
	strncpy(waypoint.ident, x->ident, sizeof(waypoint.ident)-1);
733
	waypoint.wpt_class = x->wpt_class;
734
	waypoint.posn = x->posn;
735
	strncpy(waypoint.cmnt, x->cmnt, sizeof(waypoint.cmnt)-1);
736
	waypoint.dst = x->dst;
737
 
738
	if (x->wpt_class != D152_usr_wpt_class)
739
	{
740
	   waypoint.city = x->city;
741
	   strncpy(waypoint.state, x->state, 2);
742
	   waypoint.facility = x->name;
743
	   strncpy(waypoint.cc, x->cc, 2);
744
	}
745
 
746
	if (x->wpt_class == D152_apt_wpt_class)
747
	   waypoint.alt = x->alt;
748
}
749
 
750
 
751
/* --------------------------------------------------------------------------*/
752
/* 7.4.16  D154                                                              */
753
/* --------------------------------------------------------------------------*/
754
 
755
void disassemble::garmin_print_d154 (D154 *x)
756
{
757
	memset(&waypoint, 0, sizeof(WAYPOINT));
758
	waypoint.type = 154;
759
	strncpy(waypoint.ident, x->ident, sizeof(waypoint.ident)-1);
760
	waypoint.wpt_class = x->wpt_class;
761
	waypoint.posn = x->posn;
762
	strncpy(waypoint.cmnt, x->cmnt, sizeof(waypoint.cmnt)-1);
763
	waypoint.dst = x->dst;
764
 
765
	if (x->wpt_class != D154_usr_wpt_class)
766
	{
767
	   waypoint.city = x->city;
768
	   strncpy(waypoint.state, x->state, 2);
769
	   waypoint.facility = x->name;
770
	   strncpy(waypoint.cc, x->cc, 2);
771
	}
772
 
773
	if (x->wpt_class == D154_apt_wpt_class)
774
	   waypoint.alt = x->alt;
775
 
776
	waypoint.smbl = x->smbl;
777
}
778
 
779
 
780
/* --------------------------------------------------------------------------*/
781
/* 7.4.17  D155                                                              */
782
/* --------------------------------------------------------------------------*/
783
 
784
void disassemble::garmin_print_d155 (D155 *x)
785
{
786
	memset(&waypoint, 0, sizeof(WAYPOINT));
787
	waypoint.type = 155;
788
	strncpy(waypoint.ident, x->ident, sizeof(waypoint.ident)-1);
789
	waypoint.wpt_class = x->wpt_class;
790
	waypoint.posn = x->posn;
791
	strncpy(waypoint.cmnt, x->cmnt, sizeof(waypoint.cmnt)-1);
792
	waypoint.dst = x->dst;
793
 
794
	if (x->wpt_class != D155_usr_wpt_class)
795
	{
796
	   waypoint.city = x->city;
797
	   strncpy(waypoint.state, x->state, 2);
798
	   waypoint.facility = x->name;
799
	   strncpy(waypoint.cc, x->cc, 2);
800
	}
801
 
802
	if (x->wpt_class == D155_apt_wpt_class)
803
	   waypoint.alt = x->alt;
804
 
805
	waypoint.smbl = x->smbl;
806
	waypoint.dspl = x->dspl;
807
}
808
 
809
 
810
/* --------------------------------------------------------------------------*/
811
/* 7.4.18  D200                                                              */
812
/* --------------------------------------------------------------------------*/
813
 
814
void disassemble::garmin_print_d200 (D200 *x)
815
{
816
	route_header = *x;
817
}
818
 
819
 
820
/* --------------------------------------------------------------------------*/
821
/* 7.4.19  D201                                                              */
822
/* --------------------------------------------------------------------------*/
823
 
824
void disassemble::garmin_print_d201 (D201 *x)
825
{
826
	memset(&route, 0, sizeof(ROUTE));
827
	route.type = 201;
828
	route.nmbr = x->nmbr;
829
	strncpy(route.cmnt, x->cmnt, 20);
830
}
831
 
832
 
833
/* --------------------------------------------------------------------------*/
834
/* 7.4.20  D202                                                              */
835
/* --------------------------------------------------------------------------*/
836
 
837
void disassemble::garmin_print_d202 (D202 *x)
838
{
839
	memset(&route, 0, sizeof(ROUTE));
840
	route.type = 202;
841
	route.rte_ident = x->rte_ident;
842
}
843
 
844
 
845
/* --------------------------------------------------------------------------*/
846
/* 7.4.21  D210                                                              */
847
/* --------------------------------------------------------------------------*/
848
 
849
void disassemble::garmin_print_d210 (D210 *x)
850
{
851
	memset(&route_link, 0, sizeof(ROUTE_LINK));
852
	route_link.type = 210;
853
	route_link.klasse = x->klasse;
854
	route_link.ident = x->ident;
855
	strncpy((char *)route_link.subclass, (char *)x->subclass, 18);
856
}
857
 
858
 
859
/* --------------------------------------------------------------------------*/
860
/* 7.4.22  D300                                                              */
861
/* --------------------------------------------------------------------------*/
862
 
863
void disassemble::garmin_print_d300 (D300 *p)
864
{
865
	memset(&point, 0, sizeof(POINT));
866
	point.type = 300;
867
	point.time = p->time;
868
	point.posn = p->posn;
869
	point.new_trk = p->new_trk;
870
	addPoint();
871
}
872
 
873
 
874
/* --------------------------------------------------------------------------*/
875
/* 7.4.23  D301                                                              */
876
/* --------------------------------------------------------------------------*/
877
 
878
void disassemble::garmin_print_d301 (D301 *p)
879
{
880
	memset(&point, 0, sizeof(POINT));
881
	point.type = 301;
882
	point.time = p->time;
883
	point.posn = p->posn;
884
	point.new_trk = p->new_trk;
885
	point.alt = p->alt;
886
	point.dpth = p->dpth;
887
	addPoint();
888
}
889
 
890
 
891
/* --------------------------------------------------------------------------*/
892
/* 7.4.24  D302                                                              */
893
/* --------------------------------------------------------------------------*/
894
 
895
void disassemble::garmin_print_d302 (D302 *p)
896
{
897
	memset(&point, 0, sizeof(POINT));
898
	point.type = 302;
899
	point.time = p->time;
900
	point.posn = p->posn;
901
	point.new_trk = p->new_trk;
902
	point.alt = p->alt;
903
	point.dpth = p->dpth;
904
	point.temp = p->temp;
905
	addPoint();
906
}
907
 
908
 
909
/* --------------------------------------------------------------------------*/
910
/* 7.4.25  D303                                                              */
911
/* --------------------------------------------------------------------------*/
912
 
913
void disassemble::garmin_print_d303 (D303 *p)
914
{
915
	memset(&point, 0, sizeof(POINT));
916
	point.type = 303;
917
	point.time = p->time;
918
	point.posn = p->posn;
919
	point.alt = p->alt;
920
	point.heart_rate = p->heart_rate;
921
	addPoint();
922
}
923
 
924
 
925
/* --------------------------------------------------------------------------*/
926
/* 7.4.26  D304                                                              */
927
/* --------------------------------------------------------------------------*/
928
 
929
void disassemble::garmin_print_d304 (D304 *p)
930
{
931
	memset(&point, 0, sizeof(POINT));
932
	point.type = 304;
933
	point.time = p->time;
934
	point.posn = p->posn;
935
	point.alt = p->alt;
936
	point.heart_rate = p->heart_rate;
937
	point.distance = p->distance;
938
	point.cadence = p->cadence;
939
	point.sensor = p->sensor;
940
	addPoint();
941
}
942
 
943
 
944
/* --------------------------------------------------------------------------*/
945
/* 7.4.27  D310                                                              */
946
/* --------------------------------------------------------------------------*/
947
 
948
void disassemble::garmin_print_d310 (D310 *x)
949
{
950
	memset(&track, 0, sizeof(TRACK));
951
	track.type = 310;
952
	track.trk_ident = x->trk_ident;
953
	track.color = x->color;
954
	track.dspl = x->dspl;
955
}
956
 
957
 
958
/* --------------------------------------------------------------------------*/
959
/* 7.4.28  D311                                                              */
960
/* --------------------------------------------------------------------------*/
961
 
962
void disassemble::garmin_print_d311 (D311 *h)
963
{
964
	memset(&track, 0, sizeof(TRACK));
965
	track.type = 311;
966
	track.index = h->index;
967
}
968
 
969
 
970
/* --------------------------------------------------------------------------*/
971
/* 7.4.29  D312                                                              */
972
/* --------------------------------------------------------------------------*/
973
 
974
void disassemble::garmin_print_d312 (D312 *h)
975
{
976
	memset(&track, 0, sizeof(TRACK));
977
	track.type = 312;
978
	track.trk_ident = h->trk_ident;
979
	track.color = h->color;
980
	track.dspl = h->dspl;
981
}
982
 
983
 
984
/* --------------------------------------------------------------------------*/
985
/* 7.4.30  D400                                                              */
986
/* --------------------------------------------------------------------------*/
987
 
988
void disassemble::garmin_print_d400 (D400 *x)
989
{
990
	garmin_print_d400((D400 *)&x->wpt);
991
	waypoint.type = 400;
992
	waypoint.dst = x->dst;
993
}
994
 
995
 
996
/* --------------------------------------------------------------------------*/
997
/* 7.4.31  D403                                                              */
998
/* --------------------------------------------------------------------------*/
999
 
1000
void disassemble::garmin_print_d403 (D403 *x)
1001
{
1002
	garmin_print_d103(&x->wpt);
1003
	waypoint.type = 403;
1004
	waypoint.dst = x->dst;
1005
}
1006
 
1007
 
1008
/* --------------------------------------------------------------------------*/
1009
/* 7.4.32  D450                                                              */
1010
/* --------------------------------------------------------------------------*/
1011
 
1012
void disassemble::garmin_print_d450 (D450 *x)
1013
{
1014
	garmin_print_d150(&x->wpt);
1015
	waypoint.type = 450;
1016
	waypoint.dst = x->dst;
1017
	waypoint.idx = x->idx;
1018
}
1019
 
1020
 
1021
/* --------------------------------------------------------------------------*/
1022
/* 7.4.33  D500                                                              */
1023
/* --------------------------------------------------------------------------*/
1024
 
1025
void disassemble::garmin_print_d500 (D500 *x)
1026
{
1027
	memset(&almanac, 0, sizeof(ALMANAC));
1028
	almanac.type = 500;
1029
	almanac.wn = x->wn;
1030
	almanac.toa = x->toa;
1031
	almanac.af0 = x->af0;
1032
	almanac.af1 = x->af1;
1033
	almanac.e = x->e;
1034
	almanac.sqrta = x->sqrta;
1035
	almanac.m0 = x->m0;
1036
	almanac.w = x->w;
1037
	almanac.omg0 = x->omg0;
1038
	almanac.odot = x->odot;
1039
	almanac.i = x->i;
1040
}
1041
 
1042
 
1043
/* --------------------------------------------------------------------------*/
1044
/* 7.4.34  D501                                                              */
1045
/* --------------------------------------------------------------------------*/
1046
 
1047
void disassemble::garmin_print_d501 (D501 *x)
1048
{
1049
	memset(&almanac, 0, sizeof(ALMANAC));
1050
	almanac.type = 501;
1051
	almanac.wn = x->wn;
1052
	almanac.toa = x->toa;
1053
	almanac.af0 = x->af0;
1054
	almanac.af1 = x->af1;
1055
	almanac.e = x->e;
1056
	almanac.sqrta = x->sqrta;
1057
	almanac.m0 = x->m0;
1058
	almanac.w = x->w;
1059
	almanac.omg0 = x->omg0;
1060
	almanac.odot = x->odot;
1061
	almanac.i = x->i;
1062
	almanac.hlth = x->hlth;
1063
}
1064
 
1065
 
1066
/* --------------------------------------------------------------------------*/
1067
/* 7.4.35  D550                                                              */
1068
/* --------------------------------------------------------------------------*/
1069
 
1070
void disassemble::garmin_print_d550 (D550 *x)
1071
{
1072
	memset(&almanac, 0, sizeof(ALMANAC));
1073
	almanac.type = 550;
1074
	almanac.wn = x->wn;
1075
	almanac.toa = x->toa;
1076
	almanac.af0 = x->af0;
1077
	almanac.af1 = x->af1;
1078
	almanac.e = x->e;
1079
	almanac.sqrta = x->sqrta;
1080
	almanac.m0 = x->m0;
1081
	almanac.w = x->w;
1082
	almanac.omg0 = x->omg0;
1083
	almanac.odot = x->odot;
1084
	almanac.i = x->i;
1085
	almanac.svid = x->svid;
1086
}
1087
 
1088
 
1089
/* --------------------------------------------------------------------------*/
1090
/* 7.4.36  D551                                                              */
1091
/* --------------------------------------------------------------------------*/
1092
 
1093
void disassemble::garmin_print_d551 (D551 *x)
1094
{
1095
	memset(&almanac, 0, sizeof(ALMANAC));
1096
	almanac.type = 551;
1097
	almanac.wn = x->wn;
1098
	almanac.toa = x->toa;
1099
	almanac.af0 = x->af0;
1100
	almanac.af1 = x->af1;
1101
	almanac.e = x->e;
1102
	almanac.sqrta = x->sqrta;
1103
	almanac.m0 = x->m0;
1104
	almanac.w = x->w;
1105
	almanac.omg0 = x->omg0;
1106
	almanac.odot = x->odot;
1107
	almanac.i = x->i;
1108
	almanac.svid = x->svid;
1109
	almanac.hlth = x->hlth;
1110
}
1111
 
1112
 
1113
/* --------------------------------------------------------------------------*/
1114
/* 7.4.37  D600                                                              */
1115
/* --------------------------------------------------------------------------*/
1116
 
1117
void disassemble::garmin_print_d600 (D600 *x)
1118
{
1119
	datetime.year = x->year;
1120
	datetime.month = x->month;
1121
	datetime.day = x->day;
1122
	datetime.hour = x->hour;
1123
	datetime.minute = x->minute;
1124
	datetime.second = x->second;
1125
}
1126
 
1127
 
1128
/* --------------------------------------------------------------------------*/
1129
/* 7.4.38  D650                                                              */
1130
/* --------------------------------------------------------------------------*/
1131
 
1132
void disassemble::garmin_print_d650 (D650 *x)
1133
{
1134
	memset(&flightbook, 0, sizeof(FLIGHTBOOK));
1135
	flightbook.type = 650;
1136
	flightbook.takeoff_time = x->takeoff_time;
1137
	flightbook.landing_time = x->landing_time;
1138
	flightbook.takeoff_posn = x->takeoff_posn;
1139
	flightbook.landing_posn = x->landing_posn;
1140
	flightbook.night_time = x->night_time;
1141
	flightbook.num_landings = x->num_landings;
1142
	flightbook.max_speed = x->max_speed;
1143
	flightbook.max_alt = x->max_alt;
1144
	flightbook.distance = x->distance;
1145
	flightbook.cross_country_flag = x->cross_country_flag;
1146
	flightbook.departure_name = x->departure_name;
1147
	flightbook.departure_ident = x->departure_ident;
1148
	flightbook.arrival_name = x->arrival_name;
1149
	flightbook.arrival_ident = x->arrival_ident;
1150
	flightbook.ac_id = x->ac_id;
1151
}
1152
 
1153
 
1154
/* ------------------------------------------------------------------------- */
1155
/* 7.4.39  D700                                                              */
1156
/* ------------------------------------------------------------------------- */
1157
 
1158
void disassemble::garmin_print_d700 (D700 *x)
1159
{
1160
	rpt.lat = x->lat;
1161
	rpt.lon = x->lon;
1162
}
1163
 
1164
 
1165
/* --------------------------------------------------------------------------*/
1166
/* 7.4.40  D800                                                              */
1167
/* --------------------------------------------------------------------------*/
1168
 
1169
void disassemble::garmin_print_d800 (D800 *x)
1170
{
1171
	memset(&pvt, 0, sizeof(PVT));
1172
	pvt.alt = x->alt;
1173
	pvt.epe = x->epe;
1174
	pvt.eph = x->eph;
1175
	pvt.epv = x->epv;
1176
	pvt.fix = x->fix;
1177
	pvt.posn.lat = x->posn.lat;
1178
	pvt.posn.lon = x->posn.lon;
1179
	pvt.east = x->east;
1180
	pvt.north = x->north;
1181
	pvt.up = x->up;
1182
	pvt.msl_hght = x->msl_hght;
1183
	pvt.leap_scnds = x->leap_scnds;
1184
	pvt.wn_days = x->wn_days;
1185
	pvt.tow = x->tow;
1186
}
1187
 
1188
 
1189
/* --------------------------------------------------------------------------*/
1190
/* 7.4.41  D906                                                              */
1191
/* --------------------------------------------------------------------------*/
1192
 
1193
void disassemble::garmin_print_d906 (D906 *x)
1194
{
1195
	memset (&lap, 0, sizeof(LAP));
1196
	lap.type = 906;
1197
	lap.start_time = x->start_time;
1198
	lap.total_time = x->total_time;
1199
	lap.total_distance = x->total_distance;
1200
	lap.begin.lat = x->begin.lat;
1201
	lap.begin.lon = x->begin.lon;
1202
	lap.end.lat = x->end.lat;
1203
	lap.end.lon = x->end.lon;
1204
	lap.calories = x->calories;
1205
	lap.track_index = x->track_index;
1206
	addLap();
1207
}
1208
 
1209
 
1210
/* --------------------------------------------------------------------------*/
1211
/* 7.4.42  D1000                                                             */
1212
/* --------------------------------------------------------------------------*/
1213
 
1214
 
1215
void disassemble::garmin_print_d1000 (D1000 *x)
1216
{
1217
	memset(&run, 0, sizeof(RUN));
1218
	garmin_print_d1002((D1002 *)&x->workout);
1219
	run.type = 1000;
1220
	run.track_index = x->track_index;
1221
	run.sport_type = x->sport_type;
1222
	run.first_lap_index = x->first_lap_index;
1223
	run.last_lap_index = x->last_lap_index;
1224
	run.program_type = x->program_type;
1225
	run.virtual_partner.time = x->virtual_partner.time;
1226
	run.virtual_partner.distance = x->virtual_partner.distance;
1227
	addRun();
1228
}
1229
 
1230
 
1231
/* --------------------------------------------------------------------------*/
1232
/* 7.4.43  D1001                                                             */
1233
/* --------------------------------------------------------------------------*/
1234
 
1235
 
1236
void disassemble::garmin_print_d1001 (D1001 *x)
1237
{
1238
	memset(&lap, 0, sizeof(LAP));
1239
	lap.type = 1001;
1240
	lap.start_time = x->start_time;
1241
	lap.total_time = x->total_time;
1242
	lap.total_distance = x->total_dist;
1243
	lap.begin.lat = x->begin.lat;
1244
	lap.begin.lon = x->begin.lon;
1245
	lap.end.lat = x->end.lat;
1246
	lap.end.lon = x->end.lon;
1247
	lap.calories = x->calories;
1248
	lap.index = x->index;
1249
	lap.max_speed = x->max_speed;
1250
	lap.avg_heart_rate = x->avg_heart_rate;
1251
	lap.max_heart_rate = x->max_heart_rate;
1252
	lap.intensity = x->intensity;
1253
	addLap();
1254
}
1255
 
1256
 
1257
/* --------------------------------------------------------------------------*/
1258
/* 7.4.44  D1002                                                             */
1259
/* --------------------------------------------------------------------------*/
1260
 
1261
 
1262
void disassemble::garmin_print_d1002 (D1002 *x)
1263
{
1264
int i;
1265
 
1266
	memset (&workout, 0, sizeof(WORKOUT));
1267
	workout.type = 1002;
1268
	strncpy (workout.name, x->name, 16);
1269
	workout.num_valid_steps = x->num_valid_steps;
1270
 
1271
	if (x->num_valid_steps > 0)
1272
	{
1273
	   for (i = 0; i < x->num_valid_steps; i++)
1274
	   {
1275
	      if (i >= 20)
1276
		 break;
1277
 
1278
	      strncpy (workout.steps[i].custom_name, x->steps[i].custom_name, 16);
1279
	      workout.steps[i].intensity = x->steps[i].intensity;
1280
	      workout.steps[i].duration_type = x->steps[i].duration_type;
1281
	      workout.steps[i].duration_value = x->steps[i].duration_value;
1282
	      workout.steps[i].target_type = x->steps[i].target_type;
1283
	      workout.steps[i].target_value = x->steps[i].target_value;
1284
	      workout.steps[i].target_custom_zone_low = x->steps[i].target_custom_zone_low;
1285
	      workout.steps[i].target_custom_zone_high = x->steps[i].target_custom_zone_high;
1286
	   }
1287
	}
1288
}
1289
 
1290
 
1291
/* --------------------------------------------------------------------------*/
1292
/* 7.4.45  D1003                                                             */
1293
/* --------------------------------------------------------------------------*/
1294
 
1295
void disassemble::garmin_print_d1003 (D1003 *x)
1296
{
1297
	memset (&workout, 0, sizeof(WORKOUT));
1298
	workout.type = 1003;
1299
	strncpy (workout.workout_name, x->workout_name, 16);
1300
	workout.day = x->day;
1301
}
1302
 
1303
 
1304
/* --------------------------------------------------------------------------*/
1305
/* 7.4.46  D1004                                                             */
1306
/* --------------------------------------------------------------------------*/
1307
 
1308
void disassemble::garmin_print_d1004 (D1004 *d)
1309
{
1310
int i;
1311
int j;
1312
 
1313
	memset (&fitness, 0, sizeof(FITNESS));
1314
	fitness.type = 1004;
1315
	fitness.weight = d->weight;
1316
	fitness.birth_year = d->birth_year;
1317
	fitness.birth_month = d->birth_month;
1318
	fitness.birth_day = d->birth_day;
1319
	fitness.gender = d->gender;
1320
 
1321
	for (i = 0; i < 3; i++)
1322
	{
1323
	   fitness.activities[i].gear_weight = d->activities[i].gear_weight;
1324
	   fitness.activities[i].max_heart_rate = d->activities[i].max_heart_rate;
1325
 
1326
	   for (j = 0; j < 5; j++)
1327
	   {
1328
	      fitness.activities[i].heart_rate_zones[j].low_heart_rate = d->activities[i].heart_rate_zones[j].low_heart_rate;
1329
	      fitness.activities[i].heart_rate_zones[j].high_heart_rate = d->activities[i].heart_rate_zones[j].high_heart_rate;
1330
	   }
1331
 
1332
	   for (j = 0; j < 10; j++)
1333
	   {
1334
	      fitness.activities[i].speed_zones[j].low_speed = d->activities[i].speed_zones[j].low_speed;
1335
	      fitness.activities[i].speed_zones[j].high_speed = d->activities[i].speed_zones[j].high_speed;
1336
	      strncpy (fitness.activities[i].speed_zones[j].name, d->activities[i].speed_zones[j].name, 16);
1337
	   }
1338
	}
1339
}
1340
 
1341
 
1342
/* --------------------------------------------------------------------------*/
1343
/* 7.4.47  D1005                                                             */
1344
/* --------------------------------------------------------------------------*/
1345
 
1346
void disassemble::garmin_print_d1005 (D1005 *limits)
1347
{
1348
	memset (&workout, 0, sizeof(WORKOUT));
1349
	workout.type = 1005;
1350
	workout.max_workouts = limits->max_workouts;
1351
	workout.max_unscheduled_workouts = limits->max_unscheduled_workouts;
1352
	workout.max_occurrences = limits->max_occurrences;
1353
}
1354
 
1355
 
1356
/* --------------------------------------------------------------------------*/
1357
/* 7.4.48  D1006                                                             */
1358
/* --------------------------------------------------------------------------*/
1359
 
1360
void disassemble::garmin_print_d1006 (D1006 *x)
1361
{
1362
	memset (&course, 0, sizeof(COURSE));
1363
	course.type = 1006;
1364
	course.index = x->index;
1365
	strncpy(course.course_name, x->course_name, 16);
1366
	course.track_index = x->track_index;
1367
}
1368
 
1369
 
1370
/* --------------------------------------------------------------------------*/
1371
/* 7.4.49  D1007                                                             */
1372
/* --------------------------------------------------------------------------*/
1373
 
1374
void disassemble::garmin_print_d1007 (D1007 *x)
1375
{
1376
	memset (&course, 0, sizeof(COURSE));
1377
	course.type = 1007;
1378
	course.course_index = x->course_index;
1379
	course.lap_index = x->lap_index;
1380
	course.total_time = x->total_time;
1381
	course.total_dist = x->total_dist;
1382
	course.begin.lat = x->begin.lat;
1383
	course.begin.lon = x->begin.lon;
1384
	course.end.lat = x->end.lat;
1385
	course.end.lon = x->end.lon;
1386
	course.avg_heart_rate = x->avg_heart_rate;
1387
	course.max_heart_rate = x->max_heart_rate;
1388
	course.avg_cadence = x->avg_cadence;
1389
	course.intensity = x->intensity;
1390
}
1391
 
1392
 
1393
/* --------------------------------------------------------------------------*/
1394
/* 7.4.50  D1008                                                             */
1395
/* --------------------------------------------------------------------------*/
1396
 
1397
 
1398
void disassemble::garmin_print_d1008 (D1008 *w)
1399
{
1400
	/* For some reason, D1008 is identical to D1002. */
1401
	garmin_print_d1002((D1002 *)w);
1402
	workout.type = 1008;
1403
}
1404
 
1405
 
1406
/* --------------------------------------------------------------------------*/
1407
/* 7.4.51  D1009                                                             */
1408
/* --------------------------------------------------------------------------*/
1409
 
1410
 
1411
void disassemble::garmin_print_d1009 (D1009 *x)
1412
{
1413
	memset(&run, 0, sizeof(RUN));
1414
	garmin_print_d1002((D1002 *)&x->workout);
1415
	run.type = 1009;
1416
	run.track_index = x->track_index;
1417
	run.sport_type = x->sport_type;
1418
	run.first_lap_index = x->first_lap_index;
1419
	run.last_lap_index = x->last_lap_index;
1420
	run.program_type = x->program_type;
1421
	run.virtual_partner.time = x->quick_workout.time;
1422
	run.virtual_partner.distance = x->quick_workout.distance;
1423
	run.multisport = x->multisport;
1424
	addRun();
1425
}
1426
 
1427
 
1428
/* --------------------------------------------------------------------------*/
1429
/* 7.4.52  D1010                                                             */
1430
/* --------------------------------------------------------------------------*/
1431
 
1432
 
1433
void disassemble::garmin_print_d1010 (D1010 *x)
1434
{
1435
	memset(&run, 0, sizeof(RUN));
1436
	garmin_print_d1002((D1002 *)&x->workout);
1437
	run.type = 1010;
1438
	run.track_index = x->track_index;
1439
	run.sport_type = x->sport_type;
1440
	run.first_lap_index = x->first_lap_index;
1441
	run.last_lap_index = x->last_lap_index;
1442
	run.program_type = x->program_type;
1443
	run.virtual_partner.time = x->virtual_partner.time;
1444
	run.virtual_partner.distance = x->virtual_partner.distance;
1445
	run.multisport = x->multisport;
1446
	addRun();
1447
}
1448
 
1449
 
1450
/* --------------------------------------------------------------------------*/
1451
/* 7.4.53  D1011                                                             */
1452
/* --------------------------------------------------------------------------*/
1453
 
1454
 
1455
void disassemble::garmin_print_d1011 (D1011 *x)
1456
{
1457
	memset(&lap, 0, sizeof(LAP));
1458
	lap.type = 1011;
1459
	lap.start_time = x->start_time;
1460
	lap.total_time = x->total_time;
1461
	lap.total_distance = x->total_dist;
1462
	lap.begin.lat = x->begin.lat;
1463
	lap.begin.lon = x->begin.lon;
1464
	lap.end.lat = x->end.lat;
1465
	lap.end.lon = x->end.lon;
1466
	lap.calories = x->calories;
1467
	lap.index = x->index;
1468
	lap.max_speed = x->max_speed;
1469
	lap.avg_heart_rate = x->avg_heart_rate;
1470
	lap.max_heart_rate = x->max_heart_rate;
1471
	lap.intensity = x->intensity;
1472
	lap.avg_cadence = x->avg_cadence;
1473
	lap.trigger_method = x->trigger_method;
1474
	addLap();
1475
}
1476
 
1477
 
1478
/* --------------------------------------------------------------------------*/
1479
/* 7.4.54  D1012                                                             */
1480
/* --------------------------------------------------------------------------*/
1481
 
1482
void disassemble::garmin_print_d1012 (D1012 *x)
1483
{
1484
	memset (&course, 0, sizeof(COURSE));
1485
	course.type = 1012;
1486
	course.course_index = x->course_index;
1487
	strncpy (course.course_name, x->name, 11);
1488
	course.track_point_time = x->track_point_time;
1489
	course.point_type = x->point_type;
1490
}
1491
 
1492
 
1493
/* --------------------------------------------------------------------------*/
1494
/* 7.4.55  D1013                                                             */
1495
/* --------------------------------------------------------------------------*/
1496
 
1497
void disassemble::garmin_print_d1013 (D1013 *x)
1498
{
1499
	memset (&course, 0, sizeof(COURSE));
1500
	course.type = 1012;
1501
	course.max_courses = x->max_courses;
1502
	course.max_course_laps = x->max_course_laps;
1503
	course.max_course_pnt = x->max_course_pnt;
1504
	course.max_course_trk_pnt = x->max_course_trk_pnt;
1505
}
1506
 
1507
 
1508
/* --------------------------------------------------------------------------*/
1509
/* 7.4.XX  D1015 (Undocumented)                                              */
1510
/* --------------------------------------------------------------------------*/
1511
 
1512
void disassemble::garmin_print_d1015 (D1015 *x)
1513
{
1514
	memset(&lap, 0, sizeof(LAP));
1515
	lap.type = 1011;
1516
	lap.start_time = x->start_time;
1517
	lap.total_time = x->total_time;
1518
	lap.total_distance = x->total_dist;
1519
	lap.begin.lat = x->begin.lat;
1520
	lap.begin.lon = x->begin.lon;
1521
	lap.end.lat = x->end.lat;
1522
	lap.end.lon = x->end.lon;
1523
	lap.calories = x->calories;
1524
	lap.index = x->index;
1525
	lap.max_speed = x->max_speed;
1526
	lap.avg_heart_rate = x->avg_heart_rate;
1527
	lap.max_heart_rate = x->max_heart_rate;
1528
	lap.intensity = x->intensity;
1529
	lap.avg_cadence = x->avg_cadence;
1530
	lap.trigger_method = x->trigger_method;
1531
	addLap();
1532
}
1533
 
1534
 
1535
/* ========================================================================= */
1536
/* garmin_print_data                                                         */
1537
/* ========================================================================= */
1538
 
1539
void disassemble::garmin_print_data (garmin_data *d)
1540
{
1541
#define CASE_PRINT(x) \
1542
  case data_D##x: garmin_print_d##x((D##x *)d->data); break
1543
 
1544
	switch (d->type)
1545
	{
1546
	   case data_Dlist:
1547
	      garmin_print_dlist ((garmin_list *)d->data);
1548
	   break;
1549
 
1550
	   CASE_PRINT(100);
1551
	   CASE_PRINT(101);
1552
	   CASE_PRINT(102);
1553
	   CASE_PRINT(103);
1554
	   CASE_PRINT(104);
1555
	   CASE_PRINT(105);
1556
	   CASE_PRINT(106);
1557
	   CASE_PRINT(107);
1558
	   CASE_PRINT(108);
1559
	   CASE_PRINT(109);
1560
	   CASE_PRINT(110);
1561
	   CASE_PRINT(120);
1562
	   CASE_PRINT(150);
1563
	   CASE_PRINT(151);
1564
	   CASE_PRINT(152);
1565
	   CASE_PRINT(154);
1566
	   CASE_PRINT(155);
1567
	   CASE_PRINT(200);
1568
	   CASE_PRINT(201);
1569
	   CASE_PRINT(202);
1570
	   CASE_PRINT(210);
1571
	   CASE_PRINT(300);
1572
	   CASE_PRINT(301);
1573
	   CASE_PRINT(302);
1574
	   CASE_PRINT(303);
1575
	   CASE_PRINT(304);
1576
	   CASE_PRINT(310);
1577
	   CASE_PRINT(311);
1578
	   CASE_PRINT(312);
1579
	   CASE_PRINT(400);
1580
	   CASE_PRINT(403);
1581
	   CASE_PRINT(450);
1582
	   CASE_PRINT(500);
1583
	   CASE_PRINT(501);
1584
	   CASE_PRINT(550);
1585
	   CASE_PRINT(551);
1586
	   CASE_PRINT(600);
1587
	   CASE_PRINT(650);
1588
	   CASE_PRINT(700);
1589
	   CASE_PRINT(800);
1590
	   CASE_PRINT(906);
1591
	   CASE_PRINT(1000);
1592
	   CASE_PRINT(1001);
1593
	   CASE_PRINT(1002);
1594
	   CASE_PRINT(1003);
1595
	   CASE_PRINT(1004);
1596
	   CASE_PRINT(1005);
1597
	   CASE_PRINT(1006);
1598
	   CASE_PRINT(1007);
1599
	   CASE_PRINT(1008);
1600
	   CASE_PRINT(1009);
1601
	   CASE_PRINT(1010);
1602
	   CASE_PRINT(1011);
1603
	   CASE_PRINT(1012);
1604
	   CASE_PRINT(1013);
1605
	   CASE_PRINT(1015);
1606
	}
1607
 
1608
#undef CASE_PRINT
1609
}
1610