GBA: SIO logging layer

This commit is contained in:
Jeffrey Pfau 2015-06-08 22:30:28 -07:00
parent ce647c8613
commit a816bd960b
6 changed files with 29 additions and 1 deletions

View File

@ -62,6 +62,7 @@ Misc:
- Perf: Ability to load savestates immediately on launch
- Qt: Replace pause-after-frame mutex with an atomic
- Util: Allow disabling the threading code entirely
- GBA: SIO logging layer
0.2.1: (2015-05-13)
Bugfixes:

View File

@ -46,8 +46,9 @@ enum GBALogLevel {
GBA_LOG_GAME_ERROR = 0x100,
GBA_LOG_SWI = 0x200,
GBA_LOG_STATUS = 0x400,
GBA_LOG_SIO = 0x800,
GBA_LOG_ALL = 0x73F,
GBA_LOG_ALL = 0xF3F,
#ifdef NDEBUG
GBA_LOG_DANGER = GBA_LOG_ERROR

View File

@ -82,6 +82,7 @@ bool GBASIOLockstepNodeInit(struct GBASIODriver* driver) {
struct GBASIOLockstepNode* node = (struct GBASIOLockstepNode*) driver;
node->nextEvent = LOCKSTEP_INCREMENT;
node->d.p->multiplayerControl.slave = node->id > 0;
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: Node init", node->id);
return true;
}
@ -115,9 +116,11 @@ bool GBASIOLockstepNodeUnload(struct GBASIODriver* driver) {
static uint16_t GBASIOLockstepNodeWriteRegister(struct GBASIODriver* driver, uint32_t address, uint16_t value) {
struct GBASIOLockstepNode* node = (struct GBASIOLockstepNode*) driver;
if (address == REG_SIOCNT) {
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: SIOCNT <- %04x", node->id, value);
if (value & 0x0080) {
value &= ~0x0080;
if (!node->id) {
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: Transfer initiated", node->id);
MutexLock(&node->p->mutex);
node->p->transferActive = true;
node->p->transferCycles = GBASIOCyclesPerTransfer[node->d.p->multiplayerControl.baud][node->p->attached - 1];
@ -126,6 +129,8 @@ static uint16_t GBASIOLockstepNodeWriteRegister(struct GBASIODriver* driver, uin
}
value &= 0xFF03;
value |= driver->p->siocnt & 0x007C;
} else if (address == REG_SIOMLT_SEND) {
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: SIOMLT_SEND <- %04x", node->id, value);
}
return value;
}
@ -162,6 +167,7 @@ static int32_t GBASIOLockstepNodeProcessEvents(struct GBASIODriver* driver, int3
ConditionWake(&node->p->barrier);
}
if (node->state == LOCKSTEP_FINISHED) {
GBALog(node->d.p->p, GBA_LOG_SIO, "Lockstep %i: Finishing transfer: %04x %04x %04x %04x", node->id, node->p->multiRecv[0], node->p->multiRecv[1], node->p->multiRecv[2], node->p->multiRecv[3]);
node->d.p->p->memory.io[REG_SIOMULTI0 >> 1] = node->p->multiRecv[0];
node->d.p->p->memory.io[REG_SIOMULTI1 >> 1] = node->p->multiRecv[1];
node->d.p->p->memory.io[REG_SIOMULTI2 >> 1] = node->p->multiRecv[2];

View File

@ -26,6 +26,7 @@ LogView::LogView(QWidget* parent)
connect(m_ui.levelGameError, SIGNAL(toggled(bool)), this, SLOT(setLevelGameError(bool)));
connect(m_ui.levelSWI, SIGNAL(toggled(bool)), this, SLOT(setLevelSWI(bool)));
connect(m_ui.levelStatus, SIGNAL(toggled(bool)), this, SLOT(setLevelStatus(bool)));
connect(m_ui.levelSIO, SIGNAL(toggled(bool)), this, SLOT(setLevelSIO(bool)));
connect(m_ui.clear, SIGNAL(clicked()), this, SLOT(clear()));
connect(m_ui.maxLines, SIGNAL(valueChanged(int)), this, SLOT(setMaxLines(int)));
m_ui.maxLines->setValue(DEFAULT_LINE_LIMIT);
@ -59,6 +60,7 @@ void LogView::setLevels(int levels) {
m_ui.levelGameError->setCheckState(levels & GBA_LOG_GAME_ERROR ? Qt::Checked : Qt::Unchecked);
m_ui.levelSWI->setCheckState(levels & GBA_LOG_SWI ? Qt::Checked : Qt::Unchecked);
m_ui.levelStatus->setCheckState(levels & GBA_LOG_STATUS ? Qt::Checked : Qt::Unchecked);
m_ui.levelSIO->setCheckState(levels & GBA_LOG_SIO ? Qt::Checked : Qt::Unchecked);
emit levelsSet(levels);
}
@ -135,6 +137,14 @@ void LogView::setLevelStatus(bool set) {
}
}
void LogView::setLevelSIO(bool set) {
if (set) {
setLevel(GBA_LOG_SIO);
} else {
clearLevel(GBA_LOG_SIO);
}
}
void LogView::setMaxLines(int limit) {
m_lineLimit = limit;
while (m_lines > m_lineLimit) {
@ -162,6 +172,8 @@ QString LogView::toString(int level) {
return tr("SWI");
case GBA_LOG_STATUS:
return tr("STATUS");
case GBA_LOG_SIO:
return tr("SIO");
}
return QString();
}

View File

@ -41,6 +41,7 @@ public slots:
void setLevelGameError(bool);
void setLevelSWI(bool);
void setLevelStatus(bool);
void setLevelSIO(bool);
void setMaxLines(int);

View File

@ -116,6 +116,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="levelSIO">
<property name="text">
<string>Serial I/O</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>