-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathposition.cpp
763 lines (646 loc) · 22.8 KB
/
position.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
/////////////////////////////////////////////////////////////////////////////
// Name: position.cpp
// Purpose: Stores and renders a position (a group of notes, or a rest)
// Author: Brad Larsen
// Modified by:
// Created: Dec 17, 2004
// RCS-ID:
// Copyright: (c) Brad Larsen
// License: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#include "stdwx.h"
#include "position.h"
#include "powertabfileheader.h" // Needed for file version constants
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// Constants
// Default Constants
const wxByte Position::DEFAULT_POSITION = 0;
const wxByte Position::DEFAULT_BEAMING = 0;
const wxUint32 Position::DEFAULT_DATA = (wxUint32)(DEFAULT_DURATION_TYPE << 24);
const wxByte Position::DEFAULT_DURATION_TYPE = 8;
// Position Constants
const wxUint32 Position::MIN_POSITION = 0;
const wxUint32 Position::MAX_POSITION = 255;
// Irregular Grouping Constants
const wxByte Position::MIN_IRREGULAR_GROUPING_NOTES_PLAYED = 2;
const wxByte Position::MAX_IRREGULAR_GROUPING_NOTES_PLAYED = 16;
const wxByte Position::MIN_IRREGULAR_GROUPING_NOTES_PLAYED_OVER = 2;
const wxByte Position::MAX_IRREGULAR_GROUPING_NOTES_PLAYED_OVER = 8;
const wxByte Position::MAX_VOLUME_SWELL_DURATION = 8;
const wxByte Position::MAX_TREMOLO_BAR_DURATION = 8;
const wxByte Position::MAX_TREMOLO_BAR_PITCH = 28;
// Multibar Rest Constants
const wxByte Position::MIN_MULTIBAR_REST_MEASURE_COUNT = 2;
const wxByte Position::MAX_MULTIBAR_REST_MEASURE_COUNT = 255;
/// Default Constructor
Position::Position() :
m_position(DEFAULT_POSITION), m_beaming(DEFAULT_BEAMING),
m_data(DEFAULT_DATA)
{
//------Last Checked------//
// - Jan 18, 2005
ClearComplexSymbolArrayContents();
}
/// Primary Constructor
/// @param position Zero-based index within the system where the position is
/// anchored
/// @param durationType Duration type to set (1 = whole, 2 = half, 4 = quarter,
/// 8 = 8th, 16 = 16th, 32 = 32nd, 64 = 64th)
/// @param dotCount Number of duration dots to set
Position::Position(wxUint32 position, wxByte durationType, wxByte dotCount) :
m_position(position), m_beaming(DEFAULT_BEAMING), m_data(DEFAULT_DATA)
{
//------Last Checked------//
// - Jan 18, 2005
wxASSERT(IsValidPosition(position));
wxASSERT(IsValidDurationType(durationType));
SetDurationType(durationType);
if (dotCount == 1)
SetDotted();
else if (dotCount == 2)
SetDoubleDotted();
ClearComplexSymbolArrayContents();
}
/// Copy Constructor
Position::Position(const Position& position) :
m_position(DEFAULT_POSITION), m_beaming(DEFAULT_BEAMING),
m_data(DEFAULT_DATA)
{
//------Last Checked------//
// - Dec 17, 2004
*this = position;
}
/// Destructor
Position::~Position()
{
//------Last Checked------//
// - Jan 18, 2005
ClearComplexSymbolArrayContents();
m_noteArray.DeleteContents();
}
/// Assignment Operator
const Position& Position::operator=(const Position& position)
{
//------Last Checked------//
// - Jan 18, 2005
// Check for assignment to self
if (this != &position)
{
m_position = position.m_position;
m_beaming = position.m_beaming;
m_data = position.m_data;
size_t i = 0;
for (; i < MAX_POSITION_COMPLEX_SYMBOLS; i++)
m_complexSymbolArray[i] = position.m_complexSymbolArray[i];
m_noteArray.Copy(position.m_noteArray);
}
return (*this);
}
/// Equality Operator
bool Position::operator==(const Position& position) const
{
//------Last Checked------//
// - Jan 19, 2005
wxArrayInt thisComplexSymbolArray;
wxArrayInt thatComplexSymbolArray;
wxUint32 i = 0;
for (; i < MAX_POSITION_COMPLEX_SYMBOLS; i++)
{
thisComplexSymbolArray.Add(m_complexSymbolArray[i]);
thatComplexSymbolArray.Add(position.m_complexSymbolArray[i]);
}
thisComplexSymbolArray.Sort(wxCompareIntegers);
thatComplexSymbolArray.Sort(wxCompareIntegers);
i = 0;
for (; i < MAX_POSITION_COMPLEX_SYMBOLS; i++)
{
if (thisComplexSymbolArray[i] != thatComplexSymbolArray[i])
return (false);
}
return (
(m_position == position.m_position) &&
(m_beaming == position.m_beaming) &&
(m_data == position.m_data) &&
(m_noteArray.Equals(position.m_noteArray))
);
}
/// Inequality Operator
bool Position::operator!=(const Position& position) const
{
//------Last Checked------//
// - Dec 17, 2004
return (!operator==(position));
}
// Serialization Functions
/// Performs serialization for the class
/// @param stream Power Tab output stream to serialize to
/// @return True if the object was serialized, false if not
bool Position::DoSerialize(PowerTabOutputStream& stream)
{
//------Last Checked------//
// - Jan 17, 2005
stream << m_position << m_beaming << m_data;
wxCHECK(stream.CheckState(), false);
wxByte complexCount = GetComplexSymbolCount();
stream << complexCount;
wxCHECK(stream.CheckState(), false);
size_t i = 0;
for (; i < complexCount; i++)
{
stream << m_complexSymbolArray[i];
wxCHECK(stream.CheckState(), false);
}
m_noteArray.Serialize(stream);
wxCHECK(stream.CheckState(), false);
return (stream.CheckState());
}
/// Performs deserialization for the class
/// @param stream Power Tab input stream to load from
/// @param version File version
/// @return True if the object was deserialized, false if not
bool Position::DoDeserialize(PowerTabInputStream& stream, wxWord version)
{
//------Last Checked------//
// - Jan 17, 2005
// Version 1.0/1.0.2 beaming updated
if (version == PowerTabFileHeader::FILEVERSION_1_0 ||
version == PowerTabFileHeader::FILEVERSION_1_0_2)
{
stream >> m_position >> m_beaming >> m_data;
wxCHECK(stream.CheckState(), false);
// All we have to do is move the irregular flags to the duration
// variable, the document will be rebeamed in the CDocument::Serialize()
if ((m_beaming & 0x2000) == 0x2000)
m_data |= irregularGroupingStart;
if ((m_beaming & 0x4000) == 0x4000)
m_data |= irregularGroupingMiddle;
if ((m_beaming & 0x8000) == 0x8000)
m_data |= irregularGroupingEnd;
wxByte complexCount;
stream >> complexCount;
wxCHECK(stream.CheckState(), false);
// Read the symbols
size_t i = 0;
for (; i < complexCount; i++)
{
stream >> m_complexSymbolArray[i];
wxCHECK(stream.CheckState(), false);
}
m_noteArray.Deserialize(stream, version);
wxCHECK(stream.CheckState(), false);
}
// Version 1.5 and up
else
{
stream >> m_position >> m_beaming >> m_data;
wxCHECK(stream.CheckState(), false);
wxByte complexCount;
stream >> complexCount;
wxCHECK(stream.CheckState(), false);
// Read the symbols
size_t i = 0;
for (; i < complexCount; i++)
{
stream >> m_complexSymbolArray[i];
wxCHECK(stream.CheckState(), false);
}
m_noteArray.Deserialize(stream, version);
wxCHECK(stream.CheckState(), false);
}
return (stream.CheckState());
}
// Duration Type Functions
/// Sets the duration type
/// @param durationType Duration type to set (1 = whole, 2 = half, 4 = quarter,
/// 8 = 8th, 16 = 16th, 32 = 32nd, 64 = 64th)
/// @return True if the duration type was set, false if not
bool Position::SetDurationType(wxByte durationType)
{
//------Last Checked------//
// - Jan 18, 2005
wxCHECK(IsValidDurationType(durationType), false);
// Duration type is stored in power of two format
m_data &= ~durationTypeMask;
m_data |= (wxUint32)(durationType << 24);
return (true);
}
/// Gets the duration type (1 = whole, 2 = half, 4 = quarter, 8 = 8th,
/// 16 = 16th)
/// @return The duration type
wxByte Position::GetDurationType() const
{
//------Last Checked------//
// - Jan 18, 2005
return ((wxByte)((m_data & durationTypeMask) >> 24));
}
// Irregular Grouping Functions
/// Sets the irregular grouping timing
/// @param notesPlayed Number of notes played
/// @param notesPlayedOver Number of notes played over
/// @return True if the irregular grouping timing was set, false if not
bool Position::SetIrregularGroupingTiming(wxByte notesPlayed,
wxByte notesPlayedOver)
{
//------Last Checked------//
// - Jan 18, 2005
wxCHECK(IsValidIrregularGroupingTiming(notesPlayed, notesPlayedOver),
false);
// Values are stored as 1-15 and 1-7
notesPlayed--;
notesPlayedOver--;
m_beaming &= ~irregularGroupingTimingMask;
m_beaming |= (wxWord)(notesPlayed << 3);
m_beaming |= (wxWord)notesPlayedOver;
return (true);
}
/// Gets the irregular grouping timing
/// @param notesPlayed Top value for the irregular grouping timing
/// @param notesPlayedOver Bottom value for the irregular grouping timing
/// @return True if the irregular grouping was set, false if not
void Position::GetIrregularGroupingTiming(wxByte& notesPlayed,
wxByte& notesPlayedOver) const
{
//------Last Checked------//
// - Jan 18, 2005
// Values are stored as 1-15 and 1-7, but there is no 1 value
notesPlayed =
(wxByte)(((m_beaming & irregularGroupingNotesPlayedMask) >> 3) + 1);
notesPlayedOver =
(wxByte)((m_beaming & irregularGroupingNotesPlayedOverMask) + 1);
}
/// Determines if the position has an irregular grouping timing
/// @return True if the position has an irregular grouping timing, false if not
bool Position::HasIrregularGroupingTiming() const
{
//------Last Checked------//
// - Jan 20, 2005
wxByte notesPlayed = 0;
wxByte notesPlayedOver = 0;
GetIrregularGroupingTiming(notesPlayed, notesPlayedOver);
return (!((notesPlayed == 1) && (notesPlayedOver == 1)));
}
/// Clears the irregular grouping timing
/// @return True if the irregular grouping was cleared, false if not
bool Position::ClearIrregularGroupingTiming()
{
//------Last Checked------//
// - Jan 20, 2005
m_beaming &= ~irregularGroupingTimingMask;
return (true);
}
// Previous Beam Duration Functions
/// Sets the duration type of the previous rhythm slash in the beam group (cache
/// only)
/// @param durationType Duration type to set (0 = not beamed, 8 = 8th,
/// 16 = 16th, 32 = 32nd, 64 = 64th)
/// @return True if the duration type was set, false if not
bool Position::SetPreviousBeamDurationType(wxByte durationType)
{
//------Last Checked------//
// - Jan 18, 2005
wxCHECK(IsValidPreviousBeamDurationType(durationType), false);
// Clear the current duration type
m_beaming &= ~previousBeamDurationTypeMask;
wxWord flag = 0;
if (durationType == 8)
flag = previousBeamDuration8th;
else if (durationType == 16)
flag = previousBeamDuration16th;
else if (durationType == 32)
flag = previousBeamDuration32nd;
else if (durationType == 64)
flag = previousBeamDuration64th;
m_beaming |= (wxWord)(flag << 7);
return (true);
}
/// Gets the duration type of the previous rhythm slash in the beam group
/// @return The duration type of the previous rhythm slash in the beam group
/// (0 = not beamed, 8 = 8th, 16 = 16th)
wxByte Position::GetPreviousBeamDurationType() const
{
//------Last Checked------//
// - Jan 18, 2005
wxByte flag = (wxByte)((m_beaming & previousBeamDurationTypeMask) >> 7);
if (flag == previousBeamDuration8th)
return (8);
else if (flag == previousBeamDuration16th)
return (16);
else if (flag == previousBeamDuration32nd)
return (32);
else if (flag == previousBeamDuration64th)
return (64);
return (0);
}
// Beaming Functions
/// Sets a beaming flag
/// @param flag Flag to set
/// @return True if teh beaming flag was set, false if not
bool Position::SetBeamingFlag(wxWord flag)
{
//------Last Checked------//
// - Jan 7, 2005
wxCHECK(IsValidBeamingFlag(flag), false);
// Mutually exclusive operations
if ((flag & beamStart) == beamStart)
{
ClearBeamingFlag(beamEnd);
flag &= ~beamEnd;
}
else if ((flag & beamEnd) == beamEnd)
ClearBeamingFlag(beamStart);
m_beaming |= flag;
return (true);
}
// Data Flag Functions
/// Sets a data flag
/// @param flag Flag to set
/// @return True if the flag was set, false if not
bool Position::SetDataFlag(wxUint32 flag)
{
//------Last Checked------//
// - Jan 7, 2005
wxCHECK(IsValidDataFlag(flag), false);
// Mutually exclusive operations
if ((flag & dottedMask) != 0)
ClearDataFlag(dottedMask);
if ((flag & vibratoMask) != 0)
ClearDataFlag(vibratoMask);
if ((flag & arpeggioMask) != 0)
ClearDataFlag(arpeggioMask);
if ((flag & pickStrokeMask) != 0)
ClearDataFlag(pickStrokeMask);
if ((flag & accentMask) != 0)
ClearDataFlag(accentMask);
if ((flag & tripletFeelMask) != 0)
ClearDataFlag(tripletFeelMask);
m_data |= flag;
return (true);
}
// Volume Swell Functions
/// Sets (adds or updates) a volume swell
/// @param startVolume Starting volume of the swell
/// @param endVolume Ending volume of the swell
/// @param duration Duration of the swell (0 = occurs over position, 1 and up
/// = occurs over next n positions)
/// @return True if the volume swell was added or updated
bool Position::SetVolumeSwell(wxByte startVolume, wxByte endVolume,
wxByte duration)
{
//------Last Checked------//
// - Jan 19, 2005
wxCHECK(IsValidVolumeSwell(startVolume, endVolume, duration), false);
// Construct the symbol data, then add it to the array
wxUint32 symbolData = MAKELONG(MAKEWORD(endVolume, startVolume),
MAKEWORD(duration, volumeSwell));
return (AddComplexSymbol(symbolData));
}
/// Gets the volume swell data (if any)
/// @param startVolume Holds the start volume return value
/// @param endVolume Holds the end volume return value
/// @param duration Holds the duration return value
/// @return True if the data was returned, false if not
bool Position::GetVolumeSwell(wxByte& startVolume, wxByte& endVolume,
wxByte& duration) const
{
//------Last Checked------//
// - Jan 19, 2005
startVolume = 0;
endVolume = 0;
duration = 0;
// Get the index of the volume swell
wxUint32 index = FindComplexSymbol(volumeSwell);
if (index == (wxUint32)-1)
return (false);
// Get the individual pieces that make up the volume swell
wxUint32 symbolData = m_complexSymbolArray[index];
startVolume = HIBYTE(LOWORD(symbolData));
endVolume = LOBYTE(LOWORD(symbolData));
duration = LOBYTE(HIWORD(symbolData));
return (true);
}
/// Determines if the position has a volume swell
/// @return True if the position has a volume swell, false if not
bool Position::HasVolumeSwell() const
{
//------Last Checked------//
// - Jan 19, 2005
return (FindComplexSymbol(volumeSwell) != (wxUint32)-1);
}
/// Removes a volume swell from the position
/// @return True if the volume swell was removed, false if not
bool Position::ClearVolumeSwell()
{
//------Last Checked------//
// - Jan 19, 2005
return (RemoveComplexSymbol(volumeSwell));
}
// Tremolo Bar Functions
/// Sets (adds or updates) a tremolo bar
/// @param type Type of tremolo bar (see tremoloBarTypes enum for values)
/// @param duration Duration of the tremolo bar (0 = occurs over position, 1
/// and up = occurs over next n positions)
/// @param pitch Pitch of the tremolo bar
/// @return True if the tremolo bar was added or updated
bool Position::SetTremoloBar(wxByte type, wxByte duration, wxByte pitch)
{
//------Last Checked------//
// - Jan 19, 2005
wxCHECK(IsValidTremoloBar(type, duration, pitch), false);
// Construct the symbol data, then add it to the array
wxUint32 symbolData = MAKELONG(MAKEWORD(pitch, duration),
MAKEWORD(type, tremoloBar));
return (AddComplexSymbol(symbolData));
}
/// Gets the tremolo bar data (if any)
/// @param type Holds the type return value
/// @param duration Holds the duration return value
/// @param pitch Holds the pitch return value
/// @return True if the data was returned, false if not
bool Position::GetTremoloBar(wxByte& type, wxByte& duration,
wxByte& pitch) const
{
//------Last Checked------//
// - Jan 19, 2005
type = 0;
duration = 0;
pitch = 0;
// Get the index of the tremolo bar
wxUint32 index = FindComplexSymbol(tremoloBar);
if (index == (wxUint32)-1)
return (false);
// Get the individual pieces that make up the tremolo bar
wxUint32 symbolData = m_complexSymbolArray[index];
type = LOBYTE(HIWORD(symbolData));
duration = HIBYTE(LOWORD(symbolData));
pitch = LOBYTE(LOWORD(symbolData));
return (true);
}
/// Determines if the position has a tremolo bar
/// @return True if the position has a tremolo bar, false if not
bool Position::HasTremoloBar() const
{
//------Last Checked------//
// - Jan 19, 2005
return (FindComplexSymbol(tremoloBar) != (wxUint32)-1);
}
/// Removes a tremolo bar from the position
/// @return True if the tremolo bar was removed, false if not
bool Position::ClearTremoloBar()
{
//------Last Checked------//
// - Jan 19, 2005
return (RemoveComplexSymbol(tremoloBar));
}
// Multibar Rest Functions
/// Sets (adds or updates) a multibar rest
/// @param measureCount Number of measures to rest for
/// @return True if the multibar rest was added or updated
bool Position::SetMultibarRest(wxByte measureCount)
{
//------Last Checked------//
// - Jan 19, 2005
wxCHECK(IsValidMultibarRest(measureCount), false);
// Construct the symbol data, then add it to the array
wxUint32 symbolData = MAKELONG(MAKEWORD(measureCount, 0),
MAKEWORD(0, multibarRest));
return (AddComplexSymbol(symbolData));
}
/// Gets the multibar rest data (if any)
/// @param measureCount Holds the measure count return value
/// @return True if the data was returned, false if not
bool Position::GetMultibarRest(wxByte& measureCount) const
{
//------Last Checked------//
// - Jan 19, 2005
measureCount = 0;
// Get the index of the multibar rest
wxUint32 index = FindComplexSymbol(multibarRest);
if (index == (wxUint32)-1)
return (false);
// Get the individual pieces that make up the multibar rest
wxUint32 symbolData = m_complexSymbolArray[index];
measureCount = LOBYTE(LOWORD(symbolData));
return (true);
}
/// Determines if the position has a multibar rest
/// @return True if the position has a multibar rest, false if not
bool Position::HasMultibarRest() const
{
//------Last Checked------//
// - Jan 19, 2005
return (FindComplexSymbol(multibarRest) != (wxUint32)-1);
}
/// Removes a multibar rest from the position
/// @return True if the multibar rest was removed, false if not
bool Position::ClearMultibarRest()
{
//------Last Checked------//
// - Jan 19, 2005
return (RemoveComplexSymbol(multibarRest));
}
// Complex Symbol Array Functions
/// Adds a complex symbol to the complex symbol array
/// @param symbolData Data that makes up the symbol
/// @return True if the symbol was added or updated, false if not
bool Position::AddComplexSymbol(wxUint32 symbolData)
{
//------Last Checked------//
// - Jan 19, 2005
// Get and validate the symbol type
wxByte type = HIBYTE(HIWORD(symbolData));
wxCHECK(IsValidComplexSymbolType(type), false);
bool returnValue = false;
// Get the index in the complex array where the symbol is stored
wxUint32 index = FindComplexSymbol(type);
// Found symbol in the array, update the symbol data
if (index != (wxUint32)-1)
{
m_complexSymbolArray[index] = symbolData;
returnValue = true;
}
// Symbol was not found in the array, find the first free array slot and
// insert there
else
{
wxUint32 i = 0;
for (; i < MAX_POSITION_COMPLEX_SYMBOLS; i++)
{
if (m_complexSymbolArray[i] == notUsed)
{
m_complexSymbolArray[i] = symbolData;
returnValue = true;
break;
}
}
}
return (returnValue);
}
/// Gets the number of complex symbols used by the position
/// @return The number of complex symbols used by the position
size_t Position::GetComplexSymbolCount() const
{
//------Last Checked------//
// - Jan 19, 2005
size_t returnValue = 0;
size_t i = 0;
for (; i < MAX_POSITION_COMPLEX_SYMBOLS; i++)
{
// Slot is not used; break out
if (m_complexSymbolArray[i] == notUsed)
break;
returnValue++;
}
return (returnValue);
}
/// Gets the index of a given complex symbol type in the complex symbol array
/// @param type Type of symbol to find
/// @return Index within the array where the symbol was found, or -1 if not
/// found
wxUint32 Position::FindComplexSymbol(wxByte type) const
{
//------Last Checked------//
// - Jan 19, 2005
wxUint32 returnValue = (wxUint32)-1;
wxUint32 i = 0;
for (; i < MAX_POSITION_COMPLEX_SYMBOLS; i++)
{
// Found the symbol type; break out
if (HIBYTE(HIWORD(m_complexSymbolArray[i])) == type)
{
returnValue = i;
break;
}
}
return (returnValue);
}
/// Removes a complex symbol from the complex symbol array
/// @param type Type of symbol to remove
/// @return True if the symbol was removed, false if not
bool Position::RemoveComplexSymbol(wxByte type)
{
//------Last Checked------//
// - Jan 19, 2005
bool returnValue = false;
wxUint32 i = 0;
for (; i < MAX_POSITION_COMPLEX_SYMBOLS; i++)
{
if (HIBYTE(HIWORD(m_complexSymbolArray[i])) == type)
{
m_complexSymbolArray[i] = notUsed;
returnValue = true;
break;
}
}
return (returnValue);
}
/// Clears the contents of the symbol array (sets all elements to "not used")
void Position::ClearComplexSymbolArrayContents()
{
//------Last Checked------//
// - Jan 19, 2005
wxUint32 i = 0;
for (; i < MAX_POSITION_COMPLEX_SYMBOLS; i++)
m_complexSymbolArray[i] = notUsed;
}