diff --git a/x26model.cpp b/x26model.cpp index 52016a1..e77a5e0 100644 --- a/x26model.cpp +++ b/x26model.cpp @@ -65,11 +65,19 @@ QVariant X26Model::data(const QModelIndex &index, int role) const } // Error colours from KDE Plasma Breeze (light) theme - if (role == Qt::ForegroundRole && triplet.error() != X26Triplet::NoError && index.column() == m_tripletErrors[triplet.error()].columnHighlight) - return QColor(252, 252, 252); + if (role == Qt::ForegroundRole) { + if (triplet.error() != X26Triplet::NoError && index.column() == m_tripletErrors[triplet.error()].columnHighlight) + return QColor(252, 252, 252); + else if ((index.column() == 2 && triplet.reservedMode()) || (index.column() == 3 && triplet.reservedData())) + return QColor(35, 38, 39); + } - if (role == Qt::BackgroundRole && triplet.error() != X26Triplet::NoError && index.column() == m_tripletErrors[triplet.error()].columnHighlight) - return QColor(218, 68, 63); + if (role == Qt::BackgroundRole) { + if (triplet.error() != X26Triplet::NoError && index.column() == m_tripletErrors[triplet.error()].columnHighlight) + return QColor(218, 68, 63); + else if ((index.column() == 2 && triplet.reservedMode()) || (index.column() == 3 && triplet.reservedData())) + return QColor(246, 116, 0); + } if (role == Qt::ToolTipRole && triplet.error() != X26Triplet::NoError) return m_tripletErrors[triplet.error()].message; diff --git a/x26triplets.cpp b/x26triplets.cpp index 09e9c07..c473ac3 100644 --- a/x26triplets.cpp +++ b/x26triplets.cpp @@ -77,30 +77,45 @@ void X26TripletList::updateInternalData() for (int i=0; i < m_list.size(); i++) { triplet = &m_list[i]; triplet->m_error = X26Triplet::NoError; + triplet->m_reservedMode = false; + triplet->m_reservedData = false; + if (triplet->isRowTriplet()) { switch (triplet->modeExt()) { case 0x00: // Full screen colour if (activePosition.isDeployed()) // TODO more specific error needed triplet->m_error = X26Triplet::ActivePositionMovedUp; + if (triplet->m_data & 0x60) + triplet->m_reservedData = true; break; case 0x01: // Full row colour if (!activePosition.setRow(triplet->addressRow())) triplet->m_error = X26Triplet::ActivePositionMovedUp; + if ((triplet->m_data & 0x60) != 0x00 && (triplet->m_data & 0x60) != 0x60) + triplet->m_reservedData = true; break; case 0x04: // Set Active Position; if (!activePosition.setRow(triplet->addressRow())) triplet->m_error = X26Triplet::ActivePositionMovedUp; - else if (triplet->data() >= 40 || !activePosition.setColumn(triplet->data())) + else if (triplet->data() >= 40) + // FIXME data column highlighted? + triplet->m_reservedData = true; + else if (!activePosition.setColumn(triplet->data())) triplet->m_error = X26Triplet::ActivePositionMovedLeft; break; case 0x07: // Address row 0 - if (activePosition.isDeployed()) + if (triplet->m_address != 63) + // FIXME data column highlighted? + triplet->m_reservedData = true; + else if (activePosition.isDeployed()) triplet->m_error = X26Triplet::ActivePositionMovedUp; else { activePosition.setRow(0); activePosition.setColumn(8); } + if ((triplet->m_data & 0x60) != 0x00 && (triplet->m_data & 0x60) != 0x60) + triplet->m_reservedData = true; break; case 0x10: // Origin Modifier if (i == m_list.size()-1 || @@ -125,11 +140,45 @@ void X26TripletList::updateInternalData() // otherwise the object won't appear triplet->setObjectLocalIndex(i); break; + case 0x18: // DRCS mode + if ((triplet->m_data & 0x30) == 0x00) + triplet->m_reservedData = true; + case 0x1f: // Termination marker + case 0x08 ... 0x0d: // PDC + break; + default: + triplet->m_reservedMode = true; }; - // Column triplet: make sure that PDC and reserved triplets don't affect the Active Position - } else if (triplet->modeExt() != 0x24 && triplet->modeExt() != 0x25 && triplet->modeExt() != 0x26 && triplet->modeExt() != 0x2a) - if (!activePosition.setColumn(triplet->addressColumn())) - triplet->m_error = X26Triplet::ActivePositionMovedLeft; + // Column triplet: all triplets modes except PDC and reserved move the Active Position + } else if (triplet->modeExt() == 0x24 || triplet->modeExt() == 0x25 || triplet->modeExt() == 0x2a) + triplet->m_reservedMode = true; + else if (triplet->modeExt() != 0x26 && !activePosition.setColumn(triplet->addressColumn())) + triplet->m_error = X26Triplet::ActivePositionMovedLeft; + else + switch (triplet->modeExt()) { + case 0x20: // Foreground colour + case 0x23: // Foreground colour + if (triplet->m_data & 0x60) + triplet->m_reservedData = true; + break; + case 0x21: // G1 mosaic character + case 0x22: // G3 mosaic character at level 1.5 + case 0x29: // G0 character + case 0x2b: // G3 mosaic character at level >=2.5 + case 0x2f ... 0x3f: // G2 character or G0 diacritical mark + if (triplet->m_data < 0x20) + triplet->m_reservedData = true; + break; + case 0x27: // Additional flash functions + if (triplet->m_data >= 0x18) + triplet->m_reservedData = true; + break; + case 0x2d: // DRCS character + if (triplet->m_data >= 48) + // Should really be an error + triplet->m_reservedData = true; + } + triplet->m_activePositionRow = activePosition.row(); triplet->m_activePositionColumn = activePosition.column(); } diff --git a/x26triplets.h b/x26triplets.h index 0b0e126..b322929 100644 --- a/x26triplets.h +++ b/x26triplets.h @@ -62,6 +62,8 @@ public: int activePositionRow() const { return m_activePositionRow; } int activePositionColumn() const { return m_activePositionColumn; } X26TripletError error() const { return m_error; } + bool reservedMode() const { return m_reservedMode; } + bool reservedData() const { return m_reservedData; } friend class X26TripletList; @@ -70,6 +72,8 @@ private: int m_activePositionRow = -1; int m_activePositionColumn = -1; X26TripletError m_error = NoError; + bool m_reservedMode = false; + bool m_reservedData = false; }; class X26TripletList