Show Object related errors in X/26 triplet list

This commit is contained in:
G.K.MacGregor
2022-04-05 22:11:01 +01:00
parent e16bb15310
commit 661a85066b
3 changed files with 31 additions and 16 deletions

View File

@@ -140,10 +140,14 @@ private:
int columnHighlight; int columnHighlight;
}; };
const tripletErrorShow m_tripletErrors[3] { // Needs to be in the same order as enum X26TripletError in x26triplets.h
const tripletErrorShow m_tripletErrors[6] {
{ "", 0 }, // No error { "", 0 }, // No error
{ "Active Position can't move up", 0 }, { "Active Position can't move up", 0 },
{ "Active Position can't move left within row", 1 } { "Active Position can't move left within row", 1 },
{ "Invocation not pointing to Object Definition", 3 },
{ "Invoked and Defined Object types don't match", 2 },
{ "Origin Modifier not followed by Object Invocation", 2 }
}; };
}; };

View File

@@ -69,21 +69,16 @@ void X26Triplet::setObjectLocalIndex(int i)
} }
void X26TripletList::updateInternalData(int r) void X26TripletList::updateInternalData()
{ {
ActivePosition activePosition; ActivePosition activePosition;
X26Triplet *triplet; X26Triplet *triplet;
if (r != 0) { for (int i=0; i < m_list.size(); i++) {
activePosition.setRow(m_list[r-1].m_activePositionRow);
activePosition.setColumn(m_list[r-1].m_activePositionColumn);
}
for (int i=r; i < m_list.size(); i++) {
triplet = &m_list[i]; triplet = &m_list[i];
triplet->m_error = X26Triplet::NoError; triplet->m_error = X26Triplet::NoError;
if (triplet->isRowTriplet()) { if (triplet->isRowTriplet()) {
switch (m_list.at(i).modeExt()) { switch (triplet->modeExt()) {
case 0x00: // Full screen colour case 0x00: // Full screen colour
if (activePosition.isDeployed()) if (activePosition.isDeployed())
// TODO more specific error needed // TODO more specific error needed
@@ -107,6 +102,21 @@ void X26TripletList::updateInternalData(int r)
activePosition.setColumn(8); activePosition.setColumn(8);
} }
break; break;
case 0x10: // Origin Modifier
if (i == m_list.size()-1 ||
m_list.at(i+1).modeExt() < 0x11 ||
m_list.at(i+1).modeExt() > 0x13)
triplet->m_error = X26Triplet::OriginModifierAlone;
break;
case 0x11 ... 0x13: // Invoke Object
if (triplet->objectLocalTripletNumber() > 12 ||
triplet->objectLocalIndex() > (m_list.size()-1) ||
m_list.at(triplet->objectLocalIndex()).modeExt() < 0x15 ||
m_list.at(triplet->objectLocalIndex()).modeExt() > 0x17)
triplet->m_error = X26Triplet::InvokePointerInvalid;
else if ((triplet->modeExt() | 0x04) != m_list.at(triplet->objectLocalIndex()).modeExt())
triplet->m_error = X26Triplet::InvokeTypeMismatch;
break;
case 0x15 ... 0x17: // Define Object case 0x15 ... 0x17: // Define Object
activePosition.reset(); activePosition.reset();
// Make sure data field holds correct place of triplet // Make sure data field holds correct place of triplet
@@ -126,26 +136,26 @@ void X26TripletList::updateInternalData(int r)
void X26TripletList::append(const X26Triplet &value) void X26TripletList::append(const X26Triplet &value)
{ {
m_list.append(value); m_list.append(value);
updateInternalData(m_list.size()-1); updateInternalData();
} }
void X26TripletList::insert(int i, const X26Triplet &value) void X26TripletList::insert(int i, const X26Triplet &value)
{ {
m_list.insert(i, value); m_list.insert(i, value);
updateInternalData(i); updateInternalData();
} }
void X26TripletList::removeAt(int i) void X26TripletList::removeAt(int i)
{ {
m_list.removeAt(i); m_list.removeAt(i);
if (m_list.size() != 0 && i < m_list.size()) if (m_list.size() != 0 && i < m_list.size())
updateInternalData(i); updateInternalData();
} }
void X26TripletList::replace(int i, const X26Triplet &value) void X26TripletList::replace(int i, const X26Triplet &value)
{ {
m_list.replace(i, value); m_list.replace(i, value);
updateInternalData(i); updateInternalData();
} }

View File

@@ -25,7 +25,8 @@
class X26Triplet class X26Triplet
{ {
public: public:
enum X26TripletError { NoError, ActivePositionMovedUp, ActivePositionMovedLeft }; // x26model.h has the Plain English descriptions of these errors
enum X26TripletError { NoError, ActivePositionMovedUp, ActivePositionMovedLeft, InvokePointerInvalid, InvokeTypeMismatch, OriginModifierAlone };
X26Triplet() {} X26Triplet() {}
// X26Triplet(const X26Triplet &other); // X26Triplet(const X26Triplet &other);
@@ -84,7 +85,7 @@ public:
int size() const { return m_list.size(); } int size() const { return m_list.size(); }
private: private:
void updateInternalData(int); void updateInternalData();
QList<X26Triplet> m_list; QList<X26Triplet> m_list;