Store text in packets instead of array
This removes the character array from the LevelOnePage class and stores the characters in packets 0 to 24 natively, adding a packet when a character is first added to a row and removing a packet when a row becomes space characters.
This commit is contained in:
@@ -36,9 +36,6 @@ LevelOnePage::LevelOnePage()
|
||||
// So far we only call clearPage() once, within the constructor
|
||||
void LevelOnePage::clearPage()
|
||||
{
|
||||
for (int r=0; r<25; r++)
|
||||
for (int c=0; c<40; c++)
|
||||
m_level1Page[r][c] = 0x20;
|
||||
for (int b=C4ErasePage; b<=C14NOS; b++)
|
||||
setControlBit(b, false);
|
||||
for (int i=0; i<8; i++)
|
||||
@@ -74,26 +71,12 @@ bool LevelOnePage::isEmpty() const
|
||||
return false;
|
||||
|
||||
for (int r=0; r<25; r++)
|
||||
for (int c=0; c<40; c++)
|
||||
if (m_level1Page[r][c] != 0x20)
|
||||
if (!PageX26Base::packet(r).isEmpty())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
QByteArray LevelOnePage::packet(int y) const
|
||||
{
|
||||
QByteArray result(40, 0x00);
|
||||
|
||||
if (y <= 24) {
|
||||
for (int c=0; c<40; c++)
|
||||
result[c] = m_level1Page[y][c];
|
||||
return result;
|
||||
}
|
||||
|
||||
return PageX26Base::packet(y);
|
||||
}
|
||||
|
||||
QByteArray LevelOnePage::packet(int y, int d) const
|
||||
{
|
||||
QByteArray result(40, 0x00);
|
||||
@@ -160,17 +143,15 @@ QByteArray LevelOnePage::packet(int y, int d) const
|
||||
return PageX26Base::packet(y, d);
|
||||
}
|
||||
|
||||
/*
|
||||
bool LevelOnePage::setPacket(int y, QByteArray pkt)
|
||||
{
|
||||
if (y <= 24) {
|
||||
for (int c=0; c<40; c++)
|
||||
m_level1Page[y][c] = pkt.at(c);
|
||||
return true;
|
||||
}
|
||||
if (y == 25)
|
||||
qDebug("LevelOnePage unhandled setPacket X/25");
|
||||
|
||||
qDebug("LevelOnePage unhandled setPacket X/%d", y);
|
||||
return PageX26Base::setPacket(y, pkt);
|
||||
}
|
||||
*/
|
||||
|
||||
bool LevelOnePage::setPacket(int y, int d, QByteArray pkt)
|
||||
{
|
||||
@@ -239,18 +220,6 @@ bool LevelOnePage::setPacket(int y, int d, QByteArray pkt)
|
||||
return PageX26Base::setPacket(y, d, pkt);
|
||||
}
|
||||
|
||||
bool LevelOnePage::packetExists(int y) const
|
||||
{
|
||||
if (y <= 24) {
|
||||
for (int c=0; c<40; c++)
|
||||
if (m_level1Page[y][c] != 0x20)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return PageX26Base::packetExists(y);
|
||||
}
|
||||
|
||||
bool LevelOnePage::packetExists(int y, int d) const
|
||||
{
|
||||
if (y == 26)
|
||||
@@ -341,7 +310,27 @@ void LevelOnePage::setSecondCharSet(int newSecondCharSet)
|
||||
}
|
||||
|
||||
void LevelOnePage::setSecondNOS(int newSecondNOS) { m_secondNOS = newSecondNOS; }
|
||||
void LevelOnePage::setCharacter(int row, int column, unsigned char newCharacter) { m_level1Page[row][column] = newCharacter; }
|
||||
|
||||
void LevelOnePage::setCharacter(int r, int c, unsigned char newCharacter)
|
||||
{
|
||||
QByteArray pkt;
|
||||
|
||||
if (!packetExists(r)) {
|
||||
if (newCharacter == 0x20)
|
||||
return;
|
||||
pkt = QByteArray(40, 0x20);
|
||||
pkt[c] = newCharacter;
|
||||
setPacket(r, pkt);
|
||||
} else {
|
||||
pkt = packet(r);
|
||||
pkt[c] = newCharacter;
|
||||
if (pkt == QByteArray(40, 0x20))
|
||||
clearPacket(r);
|
||||
else
|
||||
setPacket(r, pkt);
|
||||
}
|
||||
}
|
||||
|
||||
void LevelOnePage::setDefaultScreenColour(int newDefaultScreenColour) { m_defaultScreenColour = newDefaultScreenColour; }
|
||||
void LevelOnePage::setDefaultRowColour(int newDefaultRowColour) { m_defaultRowColour = newDefaultRowColour; }
|
||||
void LevelOnePage::setColourTableRemap(int newColourTableRemap) { m_colourTableRemap = newColourTableRemap; }
|
||||
|
||||
@@ -33,18 +33,19 @@ class LevelOnePage : public PageX26Base //: public QObject
|
||||
//Q_OBJECT
|
||||
|
||||
public:
|
||||
using PageX26Base::packet;
|
||||
using PageX26Base::setPacket;
|
||||
using PageX26Base::packetExists;
|
||||
|
||||
enum CycleTypeEnum { CTcycles, CTseconds };
|
||||
|
||||
LevelOnePage();
|
||||
|
||||
bool isEmpty() const override;
|
||||
|
||||
QByteArray packet(int y) const override;
|
||||
QByteArray packet(int y, int d) const override;
|
||||
bool packetExists(int y) const override;
|
||||
bool packetExists(int y, int d) const override;
|
||||
bool setPacket(int y, QByteArray pkt) override;
|
||||
bool setPacket(int y, int d, QByteArray pkt) override;
|
||||
bool packetExists(int y, int d) const override;
|
||||
|
||||
bool controlBit(int b) const override;
|
||||
bool setControlBit(int b, bool active) override;
|
||||
@@ -66,8 +67,8 @@ public:
|
||||
void setSecondCharSet(int newSecondCharSet);
|
||||
int secondNOS() const { return m_secondNOS; }
|
||||
void setSecondNOS(int newSecondNOS);
|
||||
unsigned char character(int row, int column) const { return m_level1Page[row][column]; }
|
||||
void setCharacter(int row, int column, unsigned char newCharacter);
|
||||
unsigned char character(int r, int c) const { return PageX26Base::packetExists(r) ? PageX26Base::packet(r).at(c) : 0x20; }
|
||||
void setCharacter(int r, int c, unsigned char newChar);
|
||||
int defaultScreenColour() const { return m_defaultScreenColour; }
|
||||
void setDefaultScreenColour(int newDefaultScreenColour);
|
||||
int defaultRowColour() const { return m_defaultRowColour; }
|
||||
@@ -104,7 +105,6 @@ public:
|
||||
void setComposeLinkSubPageCodes(int linkNumber, int newSubPageCodes);
|
||||
|
||||
private:
|
||||
unsigned char m_level1Page[25][40];
|
||||
/* int m_subPageNumber; */
|
||||
int m_cycleValue;
|
||||
CycleTypeEnum m_cycleType;
|
||||
|
||||
Reference in New Issue
Block a user