mirror of
https://github.com/markdavidlong/AppleSAWS.git
synced 2024-12-21 07:29:23 +00:00
Updates to CharacterSetExplorer in CharSetViewer
This commit is contained in:
parent
581ac6fa5e
commit
2f8c2cfd59
@ -7,6 +7,7 @@
|
|||||||
CharSetViewer::CharSetViewer(QWidget *parent) : FileViewerInterface(parent)
|
CharSetViewer::CharSetViewer(QWidget *parent) : FileViewerInterface(parent)
|
||||||
{
|
{
|
||||||
m_file = Q_NULLPTR;
|
m_file = Q_NULLPTR;
|
||||||
|
m_cse = Q_NULLPTR;
|
||||||
|
|
||||||
QGridLayout *qgl = new QGridLayout(this);
|
QGridLayout *qgl = new QGridLayout(this);
|
||||||
setLayout(qgl);
|
setLayout(qgl);
|
||||||
@ -14,6 +15,10 @@ CharSetViewer::CharSetViewer(QWidget *parent) : FileViewerInterface(parent)
|
|||||||
setWindowTitle(title);
|
setWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CharSetViewer::~CharSetViewer()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void CharSetViewer::setFile(GenericFile *file)
|
void CharSetViewer::setFile(GenericFile *file)
|
||||||
{
|
{
|
||||||
if (dynamic_cast<BinaryFile*>(file))
|
if (dynamic_cast<BinaryFile*>(file))
|
||||||
@ -73,9 +78,30 @@ bool CharSetViewer::optionsMenuItems(QMenu *menu)
|
|||||||
connect(action, SIGNAL(toggled(bool)),SLOT(enableBitShift(bool)));
|
connect(action, SIGNAL(toggled(bool)),SLOT(enableBitShift(bool)));
|
||||||
menu->addAction(action);
|
menu->addAction(action);
|
||||||
|
|
||||||
|
menu->addSeparator();
|
||||||
|
|
||||||
|
action = new QAction("&Character Set Explorer...");
|
||||||
|
connect(action, SIGNAL(triggered(bool)), SLOT(showExplorer()));
|
||||||
|
menu->addAction(action);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharSetViewer::showExplorer()
|
||||||
|
{
|
||||||
|
if (!m_cse) {
|
||||||
|
m_cse = new CharacterSetExplorer(this);
|
||||||
|
connect(m_cse, SIGNAL(destroyed(QObject*)), SLOT(cleanupExplorer()));
|
||||||
|
m_cse->setCharSet(m_charset);
|
||||||
|
}
|
||||||
|
m_cse->show();
|
||||||
|
m_cse->raise();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CharSetViewer::cleanupExplorer()
|
||||||
|
{
|
||||||
|
m_cse = Q_NULLPTR;
|
||||||
|
}
|
||||||
|
|
||||||
QList<CharacterWidget *> CharSetViewer::getChildren()
|
QList<CharacterWidget *> CharSetViewer::getChildren()
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "binaryfile.h"
|
#include "binaryfile.h"
|
||||||
#include "characterwidget.h"
|
#include "characterwidget.h"
|
||||||
#include "fileviewerinterface.h"
|
#include "fileviewerinterface.h"
|
||||||
|
#include "CharacterSetExplorer.h"
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
@ -12,6 +13,7 @@ class CharSetViewer : public FileViewerInterface
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CharSetViewer(QWidget *parent = 0);
|
explicit CharSetViewer(QWidget *parent = 0);
|
||||||
|
virtual ~CharSetViewer();
|
||||||
|
|
||||||
void setFile(GenericFile *file);
|
void setFile(GenericFile *file);
|
||||||
void setFile(BinaryFile *file);
|
void setFile(BinaryFile *file);
|
||||||
@ -26,12 +28,16 @@ public slots:
|
|||||||
void showGrid(bool show);
|
void showGrid(bool show);
|
||||||
void enableBitShift(bool enable);
|
void enableBitShift(bool enable);
|
||||||
|
|
||||||
|
void showExplorer();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QList<CharacterWidget*> getChildren();
|
QList<CharacterWidget*> getChildren();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void cleanupExplorer();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BinaryFile *m_file;
|
BinaryFile *m_file;
|
||||||
|
|
||||||
@ -39,6 +45,7 @@ private:
|
|||||||
|
|
||||||
CharacterSet m_charset;
|
CharacterSet m_charset;
|
||||||
|
|
||||||
|
CharacterSetExplorer *m_cse;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHARSETVIEWER_H
|
#endif // CHARSETVIEWER_H
|
||||||
|
@ -5,10 +5,82 @@ CharacterSetExplorer::CharacterSetExplorer(QWidget *parent) :
|
|||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::CharacterSetExplorer)
|
ui(new Ui::CharacterSetExplorer)
|
||||||
{
|
{
|
||||||
|
m_unpackedScreen.fill(0,8192);
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
connect(ui->drawButton, SIGNAL(clicked(bool)), SLOT(handleDrawButton()));
|
||||||
|
connect(ui->insertChar, SIGNAL(clicked(bool)), SLOT(handleInsertCharButton()));
|
||||||
|
connect(ui->inputText, SIGNAL(textChanged(QString)), SLOT(handleTextChanged(QString)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CharacterSetExplorer::setCharSet(CharacterSet &charset)
|
||||||
|
{
|
||||||
|
m_charset = charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
CharacterSetExplorer::~CharacterSetExplorer()
|
CharacterSetExplorer::~CharacterSetExplorer()
|
||||||
{
|
{
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharacterSetExplorer::handleDrawButton()
|
||||||
|
{
|
||||||
|
handleTextChanged(ui->inputText->text());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CharacterSetExplorer::handleInsertCharButton()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CharacterSetExplorer::handleTextChanged(QString string)
|
||||||
|
{
|
||||||
|
int currCursorX = 0;
|
||||||
|
int currCursorY = 0;
|
||||||
|
m_unpackedScreen.fill(0x00,8192);
|
||||||
|
|
||||||
|
foreach (QChar character, string)
|
||||||
|
{
|
||||||
|
if (character.unicode() < 128)
|
||||||
|
{
|
||||||
|
if (character.unicode() < 32)
|
||||||
|
{
|
||||||
|
// Handle control character
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Handle ASCII value
|
||||||
|
if (m_charset.contains(character.unicode()))
|
||||||
|
{
|
||||||
|
QByteArray chardata = m_charset[character.unicode()].data();
|
||||||
|
|
||||||
|
for (int idx = 0; idx < 8; idx++)
|
||||||
|
{
|
||||||
|
int baseY = (currCursorY * 8 + idx) * 40;
|
||||||
|
quint8 chr = chardata[idx];
|
||||||
|
m_unpackedScreen[baseY + currCursorX] = chr;
|
||||||
|
}
|
||||||
|
currCursorX++;
|
||||||
|
|
||||||
|
if (currCursorX >= 40) {
|
||||||
|
currCursorY++;
|
||||||
|
currCursorX = 0;
|
||||||
|
}
|
||||||
|
if (currCursorY >= 24)
|
||||||
|
{
|
||||||
|
currCursorX = 0;
|
||||||
|
currCursorY = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "Character" << character.unicode() << "not defined in char set";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "Unhandled character: " << character.unicode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ui->drawWidget->setUnpackedData(m_unpackedScreen);
|
||||||
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "charset.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class CharacterSetExplorer;
|
class CharacterSetExplorer;
|
||||||
}
|
}
|
||||||
@ -15,8 +17,19 @@ public:
|
|||||||
explicit CharacterSetExplorer(QWidget *parent = 0);
|
explicit CharacterSetExplorer(QWidget *parent = 0);
|
||||||
~CharacterSetExplorer();
|
~CharacterSetExplorer();
|
||||||
|
|
||||||
|
void setCharSet(CharacterSet &charset);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void handleDrawButton();
|
||||||
|
void handleInsertCharButton();
|
||||||
|
void handleTextChanged(QString string);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::CharacterSetExplorer *ui;
|
Ui::CharacterSetExplorer *ui;
|
||||||
|
|
||||||
|
QByteArray m_unpackedScreen;
|
||||||
|
|
||||||
|
CharacterSet m_charset;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHARACTERSETEXPLORER_H
|
#endif // CHARACTERSETEXPLORER_H
|
||||||
|
@ -10,12 +10,31 @@
|
|||||||
<height>352</height>
|
<height>352</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Dialog</string>
|
<string>Dialog</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout" rowstretch="1,999999">
|
<layout class="QGridLayout" name="gridLayout" rowstretch="1,999999">
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QWidget" name="drawWidget" native="true"/>
|
<widget class="HiresScreenWidget" name="drawWidget" native="true">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>561</width>
|
||||||
|
<height>384</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
@ -29,6 +48,13 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLineEdit" name="inputText"/>
|
<widget class="QLineEdit" name="inputText"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="insertChar">
|
||||||
|
<property name="text">
|
||||||
|
<string>Insert Char...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="drawButton">
|
<widget class="QPushButton" name="drawButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -40,6 +66,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>HiresScreenWidget</class>
|
||||||
|
<extends>QWidget</extends>
|
||||||
|
<header>HiresScreenWidget.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
@ -120,8 +120,8 @@ void HiresScreenWidget::resizeEvent(QResizeEvent *)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HiresScreenWidget::drawPixmap() {
|
void HiresScreenWidget::drawPixmap()
|
||||||
|
{
|
||||||
QPainter pmpainter(&m_pixmap);
|
QPainter pmpainter(&m_pixmap);
|
||||||
|
|
||||||
pmpainter.setBrush(Qt::black);
|
pmpainter.setBrush(Qt::black);
|
||||||
@ -207,7 +207,7 @@ void HiresScreenWidget::drawPixmap() {
|
|||||||
int xoff = cr.col() * 7;
|
int xoff = cr.col() * 7;
|
||||||
int yoff = cr.row() * 2;
|
int yoff = cr.row() * 2;
|
||||||
|
|
||||||
quint8 cOffset = 0;// highBit?1:0;
|
quint8 cOffset = highBit?1:0;
|
||||||
|
|
||||||
quint8 doubleScan = 0;
|
quint8 doubleScan = 0;
|
||||||
if (!m_showScanLines)
|
if (!m_showScanLines)
|
||||||
@ -276,7 +276,11 @@ QByteArray HiresScreenWidget::packData(QByteArray unpackedData)
|
|||||||
for (int idx = 0; idx < qMin(unpackedData.count(),8192); idx++)
|
for (int idx = 0; idx < qMin(unpackedData.count(),8192); idx++)
|
||||||
{
|
{
|
||||||
ColRow cr = getColRowFromRawAddress(idx);
|
ColRow cr = getColRowFromRawAddress(idx);
|
||||||
packedData[cr.appleAddress()] = unpackedData[idx];
|
|
||||||
|
if (cr.isDefined())
|
||||||
|
{
|
||||||
|
packedData[cr.appleAddress()] = unpackedData[idx];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return packedData;
|
return packedData;
|
||||||
@ -303,20 +307,17 @@ int HiresScreenWidget::getLineAddressOffset(int line)
|
|||||||
void HiresScreenWidget::setData(QByteArray data) {
|
void HiresScreenWidget::setData(QByteArray data) {
|
||||||
m_data = data;
|
m_data = data;
|
||||||
|
|
||||||
drawPixmap();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HiresScreenWidget::drawMonoLine(QPainter &painter, int lineNum, QBitArray data) {
|
void HiresScreenWidget::drawMonoLine(QPainter &painter, int lineNum, QBitArray data) {
|
||||||
|
painter.setPen(Qt::black);
|
||||||
|
painter.drawLine(0,lineNum,data.count(),lineNum);
|
||||||
|
painter.setPen(Qt::white);
|
||||||
for (int idx = 0; idx < data.count(); idx++) {
|
for (int idx = 0; idx < data.count(); idx++) {
|
||||||
|
|
||||||
if (data.at(idx))
|
if (data.at(idx))
|
||||||
{
|
painter.drawPoint(idx,lineNum);
|
||||||
painter.setPen(Qt::white);
|
|
||||||
} else {
|
|
||||||
painter.setPen(Qt::black);
|
|
||||||
}
|
|
||||||
|
|
||||||
painter.drawPoint(idx,lineNum);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +403,6 @@ QColor HiresScreenWidget::getColorFromBits(QBitArray bits, quint8 phase)
|
|||||||
if (bitval == 7 && phase == 3) return lightBlueColor;
|
if (bitval == 7 && phase == 3) return lightBlueColor;
|
||||||
|
|
||||||
return whiteColor;
|
return whiteColor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void HiresScreenWidget::drawNtscLine(QPainter &painter, int lineNum, QBitArray data) {
|
void HiresScreenWidget::drawNtscLine(QPainter &painter, int lineNum, QBitArray data) {
|
||||||
@ -479,7 +479,6 @@ HiresScreenWidget::ColRow HiresScreenWidget::getColRowFromRawAddress(quint16 add
|
|||||||
|
|
||||||
void HiresScreenWidget::makeAddressTables()
|
void HiresScreenWidget::makeAddressTables()
|
||||||
{
|
{
|
||||||
qDebug() << " ****** makeAddressTables()";
|
|
||||||
m_rawAddressToColRowList.resize(8192);
|
m_rawAddressToColRowList.resize(8192);
|
||||||
m_appleAddressToColRowList.resize(8192);
|
m_appleAddressToColRowList.resize(8192);
|
||||||
|
|
||||||
@ -488,7 +487,6 @@ void HiresScreenWidget::makeAddressTables()
|
|||||||
for (int col = 0; col < 40; col++)
|
for (int col = 0; col < 40; col++)
|
||||||
{
|
{
|
||||||
ColRow cr(col,row);
|
ColRow cr(col,row);
|
||||||
// qDebug() << "Col: " << col << "Row: " << row << "Raw: " << cr.rawAddress() << " Apple: " << cr.appleAddress();
|
|
||||||
|
|
||||||
m_rawAddressToColRowList[cr.rawAddress()] = cr;
|
m_rawAddressToColRowList[cr.rawAddress()] = cr;
|
||||||
m_appleAddressToColRowList[cr.appleAddress()] = cr;
|
m_appleAddressToColRowList[cr.appleAddress()] = cr;
|
||||||
|
@ -24,14 +24,13 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class CharacterSet
|
class CharacterSet
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void buildSetFromSetBlob(QByteArray data);
|
void buildSetFromSetBlob(QByteArray data);
|
||||||
CharSetCharacter operator[](int asciival) const { return m_charmap[asciival]; }
|
CharSetCharacter operator[](int asciival) const { return m_charmap[asciival]; }
|
||||||
QList<CharSetCharacter> allCharacters() const;
|
QList<CharSetCharacter> allCharacters() const;
|
||||||
|
bool contains(int asciival) { return m_charmap.keys().contains(asciival); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMap<int, CharSetCharacter> m_charmap;
|
QMap<int, CharSetCharacter> m_charmap;
|
||||||
|
Loading…
Reference in New Issue
Block a user