From 801efa570c77f383142115a38780ff5ae077bbf4 Mon Sep 17 00:00:00 2001 From: "G.K.MacGregor" Date: Tue, 2 May 2023 18:45:39 +0100 Subject: [PATCH] Also track Active Position of Level 1.5 decoding This is needed for the upcoming decoder write as decode.cpp will track the Active Position from the internal data of x26triplets. If decode.cpp is rewritten again to track the Active Position independently of x26triplets this commit may be reverted, but then again tracking how the Active Position moves on both levels 1.5 and 2.5+ may be useful in terms of warning the user of differing results on different decoder levels. --- x26triplets.cpp | 29 +++++++++++++++++++++++++++++ x26triplets.h | 6 ++++++ 2 files changed, 35 insertions(+) diff --git a/x26triplets.cpp b/x26triplets.cpp index 765a86e..959398f 100644 --- a/x26triplets.cpp +++ b/x26triplets.cpp @@ -74,6 +74,7 @@ void X26TripletList::updateInternalData() ActivePosition activePosition; X26Triplet *triplet; + // Check for errors, and fill in where the Active Position goes for Level 2.5 and above for (int i=0; i < m_list.size(); i++) { triplet = &m_list[i]; triplet->m_error = X26Triplet::NoError; @@ -182,6 +183,34 @@ void X26TripletList::updateInternalData() triplet->m_activePositionRow = activePosition.row(); triplet->m_activePositionColumn = activePosition.column(); } + + // Now work out where the Active Position goes on a Level 1.5 decoder + activePosition.reset(); + + for (int i=0; i < m_list.size(); i++) { + triplet = &m_list[i]; + + if (triplet->modeExt() == 0x1f) // Termination marker + break; + + switch (triplet->modeExt()) { + case 0x04: // Set Active Position; + activePosition.setRow(triplet->addressRow()); + break; + case 0x07: // Address row 0 + if (triplet->m_address == 63 && activePosition.setRow(0)) + activePosition.setColumn(8); + break; + case 0x22: // G3 mosaic character at level 1.5 + case 0x2f ... 0x3f: // G2 character or G0 diacritical mark + activePosition.setColumn(triplet->addressColumn()); + break; + } + + triplet->m_activePositionRow1p5 = activePosition.row(); + triplet->m_activePositionColumn1p5 = activePosition.column(); + } + } void X26TripletList::append(const X26Triplet &value) diff --git a/x26triplets.h b/x26triplets.h index 6fcb803..e810014 100644 --- a/x26triplets.h +++ b/x26triplets.h @@ -61,6 +61,8 @@ public: int activePositionRow() const { return m_activePositionRow; } int activePositionColumn() const { return m_activePositionColumn; } + int activePositionRow1p5() const { return m_activePositionRow1p5; } + int activePositionColumn1p5() const { return m_activePositionColumn1p5; } X26TripletError error() const { return m_error; } bool reservedMode() const { return m_reservedMode; } bool reservedData() const { return m_reservedData; } @@ -68,9 +70,13 @@ public: friend class X26TripletList; private: + // Only these variables are manipulated by the X26Triplet class int m_address, m_mode, m_data; + // and the following are filled in by X26TripletList::updateInternalData() int m_activePositionRow = -1; int m_activePositionColumn = -1; + int m_activePositionRow1p5 = -1; + int m_activePositionColumn1p5 = -1; X26TripletError m_error = NoError; bool m_reservedMode = false; bool m_reservedData = false;