2022-04-02 22:38:38 +01:00
|
|
|
/*
|
2024-12-31 10:51:06 +00:00
|
|
|
* Copyright (C) 2020-2025 Gavin MacGregor
|
2022-04-02 22:38:38 +01:00
|
|
|
*
|
|
|
|
|
* This file is part of QTeletextMaker.
|
|
|
|
|
*
|
|
|
|
|
* QTeletextMaker is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* QTeletextMaker is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with QTeletextMaker. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#ifndef DECODE_H
|
|
|
|
|
#define DECODE_H
|
|
|
|
|
|
2023-05-07 19:25:06 +01:00
|
|
|
#include <QList>
|
2022-04-02 22:38:38 +01:00
|
|
|
#include <QMap>
|
|
|
|
|
#include <QMultiMap>
|
|
|
|
|
|
|
|
|
|
#include "levelonepage.h"
|
|
|
|
|
|
|
|
|
|
class TeletextPageDecode : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
enum CharacterFragment { NormalSize, DoubleHeightTopHalf, DoubleHeightBottomHalf, DoubleWidthLeftHalf, DoubleWidthRightHalf, DoubleSizeTopLeftQuarter, DoubleSizeTopRightQuarter, DoubleSizeBottomLeftQuarter, DoubleSizeBottomRightQuarter };
|
2023-05-07 19:25:06 +01:00
|
|
|
enum RowHeight { NormalHeight, TopHalf, BottomHalf };
|
2022-04-02 22:38:38 +01:00
|
|
|
|
|
|
|
|
TeletextPageDecode();
|
|
|
|
|
~TeletextPageDecode();
|
|
|
|
|
bool refresh(int r, int c) const { return m_refresh[r][c]; }
|
2023-08-27 14:25:16 +01:00
|
|
|
void setRefresh(int r, int c, bool refresh);
|
2025-05-27 18:39:19 +01:00
|
|
|
int level() const { return m_level; }
|
2022-04-02 22:38:38 +01:00
|
|
|
void decodePage();
|
|
|
|
|
LevelOnePage *teletextPage() const { return m_levelOnePage; };
|
2023-08-27 14:25:16 +01:00
|
|
|
void setTeletextPage(LevelOnePage *newCurrentPage);
|
2022-04-02 22:38:38 +01:00
|
|
|
void updateSidePanels();
|
|
|
|
|
|
2023-05-07 19:25:06 +01:00
|
|
|
unsigned char cellCharacterCode(int r, int c) const { return m_cell[r][c].character.code; };
|
|
|
|
|
int cellCharacterSet(int r, int c) const { return m_cell[r][c].character.set; };
|
|
|
|
|
int cellCharacterDiacritical(int r, int c) const { return m_cell[r][c].character.diacritical; };
|
2023-08-15 18:11:40 +01:00
|
|
|
int cellG0CharacterSet(int r, int c) const { return m_cell[r][c].g0Set; };
|
|
|
|
|
int cellG2CharacterSet(int r, int c) const { return m_cell[r][c].g2Set; };
|
2023-05-07 19:25:06 +01:00
|
|
|
int cellForegroundCLUT(int r, int c) const { return m_cell[r][c].attribute.foregroundCLUT; };
|
|
|
|
|
int cellBackgroundCLUT(int r, int c) const { return m_cell[r][c].attribute.backgroundCLUT; };
|
2023-08-27 14:25:16 +01:00
|
|
|
QColor cellForegroundQColor(int r, int c);
|
|
|
|
|
QColor cellBackgroundQColor(int r, int c);
|
|
|
|
|
QColor cellFlashForegroundQColor(int r, int c);
|
2023-05-07 19:25:06 +01:00
|
|
|
int cellFlashMode(int r, int c) const { return m_cell[r][c].attribute.flash.mode; };
|
|
|
|
|
int cellFlashRatePhase(int r, int c) const { return m_cell[r][c].attribute.flash.ratePhase; };
|
|
|
|
|
int cellFlash2HzPhaseNumber(int r, int c) const { return m_cell[r][c].attribute.flash.phase2HzShown; };
|
|
|
|
|
CharacterFragment cellCharacterFragment(int r, int c) const { return m_cell[r][c].fragment; };
|
|
|
|
|
bool cellBoxed(int r, int c) const { return m_cell[r][c].attribute.display.boxingWindow; };
|
|
|
|
|
bool cellConceal(int r, int c) const { return m_cell[r][c].attribute.display.conceal; };
|
|
|
|
|
bool cellUnderlined(int r, int c) const { return cellCharacterSet(r, c) < 24 ? m_cell[r][c].attribute.display.underlineSeparated : false; };
|
2023-05-21 15:33:21 +01:00
|
|
|
bool cellBold(int r, int c) const { return m_cell[r][c].attribute.style.bold; };
|
|
|
|
|
bool cellItalic(int r, int c) const { return m_cell[r][c].attribute.style.italic; };
|
|
|
|
|
bool cellProportional(int r, int c) const { return m_cell[r][c].attribute.style.proportional; };
|
2023-05-07 19:25:06 +01:00
|
|
|
|
2024-07-07 19:41:39 +01:00
|
|
|
bool level1MosaicAttr(int r, int c) const { return m_cellLevel1MosaicAttr[r][c]; };
|
|
|
|
|
bool level1MosaicChar(int r, int c) const { return m_cellLevel1MosaicChar[r][c]; };
|
2023-05-07 19:25:06 +01:00
|
|
|
int level1CharSet(int r, int c) const { return m_cellLevel1CharSet[r][c]; };
|
2022-04-02 22:38:38 +01:00
|
|
|
|
2023-05-07 19:25:06 +01:00
|
|
|
RowHeight rowHeight(int r) const { return m_rowHeight[r]; };
|
2022-04-02 22:38:38 +01:00
|
|
|
|
|
|
|
|
QColor fullScreenQColor() const { return m_finalFullScreenQColor; };
|
|
|
|
|
QColor fullRowQColor(int r) const { return m_fullRowQColor[r]; };
|
|
|
|
|
int leftSidePanelColumns() const { return m_leftSidePanelColumns; };
|
|
|
|
|
int rightSidePanelColumns() const { return m_rightSidePanelColumns; };
|
|
|
|
|
|
|
|
|
|
public slots:
|
2023-08-27 14:25:16 +01:00
|
|
|
void setLevel(int level);
|
2022-04-02 22:38:38 +01:00
|
|
|
|
|
|
|
|
signals:
|
2023-08-27 14:25:16 +01:00
|
|
|
void fullScreenColourChanged(QColor newColour);
|
|
|
|
|
void fullRowColourChanged(int r, QColor newColour);
|
2022-04-02 22:38:38 +01:00
|
|
|
void sidePanelsChanged();
|
|
|
|
|
|
|
|
|
|
protected:
|
2023-08-27 14:25:16 +01:00
|
|
|
inline void setFullScreenColour(int newColour);
|
|
|
|
|
inline void setFullRowColour(int row, int newColour);
|
2022-04-02 22:38:38 +01:00
|
|
|
|
2022-05-02 22:24:04 +01:00
|
|
|
int m_finalFullScreenColour, m_level;
|
2022-04-02 22:38:38 +01:00
|
|
|
QColor m_finalFullScreenQColor;
|
|
|
|
|
int m_leftSidePanelColumns, m_rightSidePanelColumns;
|
|
|
|
|
const int m_foregroundRemap[8] = { 0, 0, 0, 8, 8, 16, 16, 16 };
|
|
|
|
|
const int m_backgroundRemap[8] = { 0, 8, 16, 8, 16, 8, 16, 24 };
|
|
|
|
|
|
|
|
|
|
private:
|
2023-05-07 19:25:06 +01:00
|
|
|
class Invocation;
|
|
|
|
|
|
2022-04-02 22:38:38 +01:00
|
|
|
enum ColourPart { Foreground, Background, FlashForeground };
|
|
|
|
|
|
2023-05-07 19:25:06 +01:00
|
|
|
struct textCharacter {
|
|
|
|
|
unsigned char code=0x20;
|
|
|
|
|
int set=0;
|
|
|
|
|
int diacritical=0;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
friend inline bool operator!=(const textCharacter &lhs, const textCharacter &rhs)
|
|
|
|
|
{
|
|
|
|
|
return lhs.code != rhs.code ||
|
|
|
|
|
lhs.set != rhs.set ||
|
|
|
|
|
lhs.diacritical != rhs.diacritical;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct flashFunctions {
|
|
|
|
|
int mode=0;
|
|
|
|
|
int ratePhase=0;
|
|
|
|
|
int phase2HzShown=0;
|
2023-05-21 15:33:21 +01:00
|
|
|
};
|
2023-05-07 19:25:06 +01:00
|
|
|
|
|
|
|
|
struct displayAttributes {
|
|
|
|
|
bool doubleHeight=false;
|
|
|
|
|
bool doubleWidth=false;
|
|
|
|
|
bool boxingWindow=false;
|
|
|
|
|
bool conceal=false;
|
|
|
|
|
bool invert=false;
|
|
|
|
|
bool underlineSeparated=false;
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-21 15:33:21 +01:00
|
|
|
struct fontStyle {
|
|
|
|
|
bool proportional=false;
|
|
|
|
|
bool bold=false;
|
|
|
|
|
bool italic=false;
|
|
|
|
|
};
|
|
|
|
|
|
2023-05-07 19:25:06 +01:00
|
|
|
friend inline bool operator!=(const displayAttributes &lhs, const displayAttributes &rhs)
|
|
|
|
|
{
|
|
|
|
|
return lhs.doubleHeight != rhs.doubleHeight ||
|
|
|
|
|
lhs.doubleWidth != rhs.doubleWidth ||
|
|
|
|
|
lhs.boxingWindow != rhs.boxingWindow ||
|
|
|
|
|
lhs.conceal != rhs.conceal ||
|
|
|
|
|
lhs.invert != rhs.invert ||
|
|
|
|
|
lhs.underlineSeparated != rhs.underlineSeparated;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct textAttributes {
|
|
|
|
|
int foregroundCLUT=7;
|
|
|
|
|
int backgroundCLUT=0;
|
|
|
|
|
flashFunctions flash;
|
|
|
|
|
displayAttributes display;
|
2023-05-21 15:33:21 +01:00
|
|
|
fontStyle style;
|
2023-05-07 19:25:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
friend inline bool operator!=(const textAttributes &lhs, const textAttributes &rhs)
|
|
|
|
|
{
|
|
|
|
|
return lhs.foregroundCLUT != rhs.foregroundCLUT ||
|
|
|
|
|
lhs.backgroundCLUT != rhs.backgroundCLUT ||
|
|
|
|
|
lhs.flash.mode != rhs.flash.mode ||
|
|
|
|
|
lhs.flash.ratePhase != rhs.flash.ratePhase ||
|
|
|
|
|
lhs.flash.phase2HzShown != rhs.flash.phase2HzShown ||
|
2023-05-21 15:33:21 +01:00
|
|
|
lhs.display != rhs.display ||
|
|
|
|
|
lhs.style.proportional != rhs.style.proportional ||
|
|
|
|
|
lhs.style.bold != rhs.style.bold ||
|
|
|
|
|
lhs.style.italic != rhs.style.italic;
|
2023-05-07 19:25:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct textCell {
|
|
|
|
|
textCharacter character;
|
|
|
|
|
textAttributes attribute;
|
|
|
|
|
CharacterFragment fragment=NormalSize;
|
2023-08-15 18:11:40 +01:00
|
|
|
int g0Set=0;
|
|
|
|
|
int g2Set=7;
|
2023-05-07 19:25:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
friend inline bool operator!=(const textCell &lhs, const textCell &rhs)
|
|
|
|
|
{
|
|
|
|
|
return lhs.character != rhs.character ||
|
|
|
|
|
lhs.attribute != rhs.attribute ||
|
|
|
|
|
lhs.fragment != rhs.fragment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct textPainter {
|
|
|
|
|
textAttributes attribute;
|
|
|
|
|
textCell result;
|
|
|
|
|
textCell rightHalfCell;
|
|
|
|
|
textCell bottomHalfCell[72];
|
2023-05-21 15:33:21 +01:00
|
|
|
|
|
|
|
|
int styleSpreadRows=0;
|
|
|
|
|
int setProportionalRows[72], clearProportionalRows[72];
|
|
|
|
|
int setBoldRows[72], clearBoldRows[72];
|
|
|
|
|
int setItalicRows[72], clearItalicRows[72];
|
2023-05-07 19:25:06 +01:00
|
|
|
};
|
|
|
|
|
|
2023-06-12 16:37:50 +01:00
|
|
|
const QMap<int, int> m_level1CharacterMap {
|
2023-05-07 19:25:06 +01:00
|
|
|
{ 0x00, 12 }, { 0x01, 15 }, { 0x02, 22 }, { 0x03, 16 }, { 0x04, 14 }, { 0x05, 19 }, { 0x06, 11 },
|
|
|
|
|
{ 0x08, 18 }, { 0x09, 15 }, { 0x0a, 22 }, { 0x0b, 16 }, { 0x0c, 14 }, { 0x0e, 11 },
|
|
|
|
|
{ 0x10, 12 }, { 0x11, 15 }, { 0x12, 22 }, { 0x13, 16 }, { 0x14, 14 }, { 0x15, 19 }, { 0x16, 23 },
|
|
|
|
|
{ 0x1d, 21 }, { 0x1f, 20 },
|
|
|
|
|
{ 0x20, 1 }, { 0x21, 15 }, { 0x22, 13 }, { 0x23, 17 }, { 0x24, 2 }, { 0x25, 3 }, { 0x26, 11 },
|
|
|
|
|
{ 0x36, 23 }, { 0x37, 4 },
|
|
|
|
|
{ 0x40, 12 }, { 0x44, 14 }, { 0x47, 5 },
|
|
|
|
|
{ 0x55, 6 }, { 0x57, 5 }
|
|
|
|
|
};
|
2023-06-12 16:37:50 +01:00
|
|
|
const QMap<int, int> m_g0CharacterMap {
|
|
|
|
|
{ 0x20, 1 }, { 0x24, 2 }, { 0x25, 3 },
|
|
|
|
|
{ 0x37, 4 },
|
|
|
|
|
{ 0x47, 5 },
|
|
|
|
|
{ 0x55, 6 }, { 0x57, 5 }
|
|
|
|
|
};
|
|
|
|
|
const QMap<int, int> m_g2CharacterMap {
|
|
|
|
|
{ 0x20, 8 }, { 0x24, 8 }, { 0x25, 8 },
|
|
|
|
|
{ 0x37, 9 },
|
|
|
|
|
{ 0x40, 10 }, { 0x44, 10 }, { 0x47, 10 },
|
|
|
|
|
{ 0x55, 10 }, { 0x57, 10 }
|
|
|
|
|
};
|
2023-05-07 19:25:06 +01:00
|
|
|
|
|
|
|
|
class Invocation
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
Invocation();
|
|
|
|
|
|
|
|
|
|
X26TripletList *tripletList() const { return m_tripletList; };
|
2023-05-09 23:35:29 +01:00
|
|
|
void clear();
|
2023-08-27 14:25:16 +01:00
|
|
|
void setTripletList(X26TripletList *tripletList);
|
2023-05-07 19:25:06 +01:00
|
|
|
int startTripletNumber() const { return m_startTripletNumber; };
|
2023-08-27 14:25:16 +01:00
|
|
|
void setStartTripletNumber(int n);
|
2023-05-07 19:25:06 +01:00
|
|
|
int endTripletNumber() const { return m_endTripletNumber; };
|
2023-08-27 14:25:16 +01:00
|
|
|
void setEndTripletNumber(int n);
|
2023-05-07 19:25:06 +01:00
|
|
|
int originRow() const { return m_originRow; };
|
|
|
|
|
int originColumn() const { return m_originColumn; };
|
2023-08-27 14:25:16 +01:00
|
|
|
void setOrigin(int row, int column);
|
|
|
|
|
void buildMap(int level);
|
2023-05-07 19:25:06 +01:00
|
|
|
|
|
|
|
|
QList<QPair<int, int>> charPositions() const { return m_characterMap.uniqueKeys(); };
|
|
|
|
|
QList<QPair<int, int>> attrPositions() const { return m_attributeMap.uniqueKeys(); };
|
|
|
|
|
QList<X26Triplet> charactersMappedAt(int r, int c) const { return m_characterMap.values(qMakePair(r, c)); };
|
|
|
|
|
QList<X26Triplet> attributesMappedAt(int r, int c) const { return m_attributeMap.values(qMakePair(r, c)); };
|
|
|
|
|
int rightMostColumn(int r) const { return m_rightMostColumn.value(r, -1); };
|
|
|
|
|
int fullScreenColour() const { return m_fullScreenCLUT; };
|
|
|
|
|
QList<X26Triplet> fullRowColoursMappedAt(int r) const { return m_fullRowCLUTMap.values(r); };
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
X26TripletList *m_tripletList;
|
|
|
|
|
int m_startTripletNumber, m_endTripletNumber;
|
|
|
|
|
int m_originRow, m_originColumn;
|
|
|
|
|
// QPair is row and column
|
|
|
|
|
QMultiMap<QPair<int, int>, X26Triplet> m_characterMap;
|
|
|
|
|
QMultiMap<QPair<int, int>, X26Triplet> m_attributeMap;
|
|
|
|
|
QMap<int, int> m_rightMostColumn;
|
|
|
|
|
int m_fullScreenCLUT;
|
|
|
|
|
QMultiMap<int, X26Triplet> m_fullRowCLUTMap;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static int s_instances;
|
|
|
|
|
static textPainter s_blankPainter;
|
|
|
|
|
|
|
|
|
|
void decodeRow(int r);
|
2023-08-27 14:25:16 +01:00
|
|
|
QColor cellQColor(int r, int c, ColourPart colourPart);
|
|
|
|
|
textCell& cellAtCharacterOrigin(int r, int c);
|
|
|
|
|
void buildInvocationList(Invocation &invocation, int objectType);
|
|
|
|
|
textCharacter characterFromTriplets(const QList<X26Triplet> triplets);
|
|
|
|
|
inline void rotateFlashMovement(flashFunctions &flash);
|
2022-04-02 22:38:38 +01:00
|
|
|
|
|
|
|
|
bool m_refresh[25][72];
|
2023-05-07 19:25:06 +01:00
|
|
|
textCell m_cell[25][72];
|
2024-07-07 19:41:39 +01:00
|
|
|
bool m_cellLevel1MosaicAttr[25][40];
|
|
|
|
|
bool m_cellLevel1MosaicChar[25][40];
|
2023-05-07 19:25:06 +01:00
|
|
|
int m_cellLevel1CharSet[25][40];
|
2022-04-02 22:38:38 +01:00
|
|
|
LevelOnePage* m_levelOnePage;
|
|
|
|
|
int m_fullRowColour[25];
|
|
|
|
|
QColor m_fullRowQColor[25];
|
2023-05-07 19:25:06 +01:00
|
|
|
QList<Invocation> m_invocations[3];
|
|
|
|
|
Invocation m_localEnhancements;
|
|
|
|
|
textPainter m_level1ActivePainter;
|
|
|
|
|
QList<textPainter> m_adapPassPainter[2];
|
|
|
|
|
int m_level1DefaultCharSet, m_level1SecondCharSet;
|
2023-06-12 16:37:50 +01:00
|
|
|
int m_defaultG0andG2, m_secondG0andG2;
|
2022-04-02 22:38:38 +01:00
|
|
|
|
2023-05-07 19:25:06 +01:00
|
|
|
RowHeight m_rowHeight[25];
|
2022-04-02 22:38:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|