Skip to content

Commit

Permalink
Trying to solve buggy enhancement pages by implementing half-finished…
Browse files Browse the repository at this point in the history
… subcode generation.

Also shut up compiler warnings about intentional switch fallthrough in GetPacket
  • Loading branch information
ZXGuesser committed May 16, 2018
1 parent f86eb4a commit ea9fb60
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
9 changes: 6 additions & 3 deletions packetmag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,18 @@ Packet* PacketMag::GetPacket(Packet* p)
_status = _page->GetCarouselPage()->GetPageStatus() & 0x8000; // get transmit flag
_region = _page->GetCarouselPage()->GetRegion();
thisSubcode=_page->GetCarouselPage()->GetSubCode() & 0x000F; // will break if carousel has more than 16 subpages but that would be out of spec anyway.
thisSubcode |= _page->GetCarouselPage()->GetLastPacket() << 8;
}
else
{
_status = _page->GetPageStatus() & 0x8000; // get transmit flag
_region = _page->GetRegion();
thisSubcode = 0; // no subpages
thisSubcode = _page->GetLastPacket() << 8; // S3 and S4
}

/* rules for the control bits are complicated. There are rules to allow the page to be sent as fragments. Since we aren't doing that, all the flags are left clear except for C9 (interrupted sequence) to keep special pages out of rolling headers */
_status |= 0x0010;
/* rules for the subcode are really complicated. The S1 nibble should be the sub page number, S2 is a counter that increments when the page is updated, S3 and S4 hold the last row number that will be transmitted for this page which needs calculating somehow. */
thisSubcode|=0x2900; // Set the last X/26 row as the final packet for now but this is WRONG
/* rules for the subcode are really complicated. The S1 nibble should be the sub page number, S2 is a counter that increments when the page is updated, S3 and S4 hold the last row number */
} else {
// got to the end of the special pages
ClearEvent(EVENT_SPECIAL_PAGES);
Expand Down Expand Up @@ -262,6 +262,7 @@ Packet* PacketMag::GetPacket(Packet* p)
}
_lastTxt=_page->GetTxRow(28); // Get _lastTxt ready for packet 28 processing
_state=PACKETSTATE_PACKET28; // // Intentional fall through to PACKETSTATE_PACKET28
__attribute__ ((fallthrough));
case PACKETSTATE_PACKET28:
//std::cerr << "TRACE-28 " << std::endl;

Expand Down Expand Up @@ -302,6 +303,7 @@ Packet* PacketMag::GetPacket(Packet* p)
_state=PACKETSTATE_TEXTROW;
return nullptr;
}
__attribute__ ((fallthrough));
case PACKETSTATE_PACKET26:
if (_lastTxt)
{
Expand All @@ -319,6 +321,7 @@ Packet* PacketMag::GetPacket(Packet* p)
_thisRow=0;
return nullptr;
}
__attribute__ ((fallthrough));
case PACKETSTATE_TEXTROW:
// std::cerr << "TRACE-T " << std::endl;

Expand Down
19 changes: 18 additions & 1 deletion ttxpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void TTXPage::m_Init()
m_cycletimeseconds=8;
m_cycletimetype='T';
m_pagestatus=0x8000;
m_lastpacket=0;
m_pagecoding=CODING_7BIT_TEXT;
m_pagefunction=LOP;
instance=instanceCount++;
Expand Down Expand Up @@ -625,6 +626,7 @@ TTXPage::TTXPage(const TTXPage& other)
m_cycletimeseconds=other.m_cycletimeseconds;
m_subcode=other.m_subcode; // SC
m_pagestatus=other.m_pagestatus; // PS
m_lastpacket=other.m_lastpacket;
m_region=other.m_region; // RE
m_pagecoding=other.m_pagecoding;
m_pagefunction=other.m_pagefunction;
Expand Down Expand Up @@ -672,11 +674,13 @@ TTXLine* TTXPage::GetRow(unsigned int row)

void TTXPage::SetRow(unsigned int rownumber, std::string line)
{
unsigned int dc;

// assert(rownumber<=MAXROW);
if (rownumber>MAXROW) return;

if (rownumber == 28){
int dc = line.at(0) & 0x0F;
dc = line.at(0) & 0x0F;
if (dc == 0 || dc == 2 || dc == 3 || dc == 4){
// packet is X/28/0, X/28/2, X/28/3, or X/28/4
int triplet = line.at(1) & 0x3F;
Expand All @@ -687,6 +691,18 @@ void TTXPage::SetRow(unsigned int rownumber, std::string line)
SetPageFunctionInt(triplet & 0x0F);
}
}

if (rownumber == 26)
{
dc = line.at(0) & 0x0F;
if ((dc + 26) > m_lastpacket)
m_lastpacket = dc + 26;
}
else if (rownumber < 26)
{
if (rownumber > m_lastpacket)
m_lastpacket = rownumber;
}

if (m_pLine[rownumber]==nullptr)
m_pLine[rownumber]=new TTXLine(line,rownumber<MAXROW); // Didn't exist before
Expand Down Expand Up @@ -893,6 +909,7 @@ void TTXPage::CopyMetaData(TTXPage* page)
m_cycletimetype=page->m_cycletimetype; // CT
m_subcode=page->m_subcode; // SC
m_pagestatus=page->m_pagestatus; // PS
m_lastpacket=page->m_lastpacket;
m_region=page->m_region; // RE
}

Expand Down
5 changes: 4 additions & 1 deletion ttxpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ class TTXPage
void DebugDump() const;

inline bool Loaded() const {return m_Loaded;};


unsigned int GetLastPacket() {return m_lastpacket;};

// get the function or coding of a page as the enum
PageCoding GetPageCoding() {return m_pagecoding;}
PageFunction GetPageFunction() {return m_pagefunction;}
Expand Down Expand Up @@ -251,6 +253,7 @@ class TTXPage
unsigned int m_subcode; // SC
int m_pagestatus; // PS
int m_region; // RE
unsigned int m_lastpacket;
PageCoding m_pagecoding;
PageFunction m_pagefunction;
// Private functions
Expand Down

0 comments on commit ea9fb60

Please sign in to comment.