From 339dca8b18e2ce25dbd144b2e95bb922eb3b434f Mon Sep 17 00:00:00 2001 From: ZXGuesser Date: Thu, 28 Sep 2017 22:21:03 +0100 Subject: [PATCH] only load packet 29 from pages mFF --- packetmag.cpp | 67 +++++++++++++++++++++++++++------------------------ ttxpage.cpp | 2 +- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/packetmag.cpp b/packetmag.cpp index e974766..7be8a77 100644 --- a/packetmag.cpp +++ b/packetmag.cpp @@ -235,36 +235,45 @@ Packet* PacketMag::GetPacket(Packet* p) } } - tempLine = _page->GetTxRow(29); - while (tempLine != nullptr) + // Assemble the header. (we can simplify this code or leave it for the optimiser) + thisPageNum=_page->GetPageNumber(); + thisPageNum=(thisPageNum/0x100) % 0x100; // Remove this line for Continuous Random Acquisition of Pages. + + if ((thisPageNum & 0xFF) == 0xFF) { - // TODO: we don't want to do this every time the page is encountered. We should do it once then check to see if it has changed - // Other issues include: multiple pages with packets 29 will overwrite each other, and when the page is deleted the packets will remain. - //std::cerr << "page includes packet 29" << std::endl; - switch (tempLine->GetCharAt(0)) + // only read packet 29 from page mFF + //std::cerr << "updating packet 29" << std::endl; + // TODO: we needn't do this every time round the carousel + tempLine = _page->GetTxRow(29); + while (tempLine != nullptr) { - case '@': - Packet29Index = 0; - break; - case 'A': - Packet29Index = 1; - break; - case 'D': - Packet29Index = 2; - break; - default: - Packet29Index = -1; - } - if (Packet29Index > -1) - { - if (_packet29[Packet29Index]==nullptr) - _packet29[Packet29Index]=new TTXLine(tempLine->GetLine(),true); // Didn't exist before - else - _packet29[Packet29Index]->Setm_textline(tempLine->GetLine(), true); + // TODO: when the page is deleted the packets will remain. + //std::cerr << "page includes packet 29" << std::endl; + switch (tempLine->GetCharAt(0)) + { + case '@': + Packet29Index = 0; + break; + case 'A': + Packet29Index = 1; + break; + case 'D': + Packet29Index = 2; + break; + default: + Packet29Index = -1; + } + if (Packet29Index > -1) + { + if (_packet29[Packet29Index]==nullptr) + _packet29[Packet29Index]=new TTXLine(tempLine->GetLine(),true); // Didn't exist before + else + _packet29[Packet29Index]->Setm_textline(tempLine->GetLine(), true); + } + + tempLine = tempLine->GetNextLine(); + // loop until every row 29 is copied } - - tempLine = tempLine->GetNextLine(); - // loop until every row 29 is copied } if (!(thisStatus & 0x8000)) @@ -273,10 +282,6 @@ Packet* PacketMag::GetPacket(Packet* p) return nullptr; } - // Assemble the header. (we can simplify this code or leave it for the optimiser) - thisPageNum=_page->GetPageNumber(); - thisPageNum=(thisPageNum/0x100) % 0x100; // Remove this line for Continuous Random Acquisition of Pages. - // p=new Packet(); p->Header(_magNumber,thisPageNum,thisSubcode,thisStatus);// loads of stuff to do here! diff --git a/ttxpage.cpp b/ttxpage.cpp index e7d801f..26ae0f3 100644 --- a/ttxpage.cpp +++ b/ttxpage.cpp @@ -917,7 +917,7 @@ int TTXPage::GetLanguage() void TTXPage::SetPageNumber(int page) { - if ((page<0x10000) || (page>0x8ff99) || (page&0xFF00) == 0xFF00) + if ((page<0x10000) || (page>0x8ff99)) { std::cerr << "[TTXPage::SetPageNumber] Page number is out of range: " << std::hex << page << std::endl; }