GBA: Add status log level

This commit is contained in:
Jeffrey Pfau 2015-04-26 13:43:30 -07:00
parent f52d91c6c8
commit 9c07698068
9 changed files with 38 additions and 4 deletions

View File

@ -45,6 +45,7 @@ Misc:
- Qt: Handle saving input settings better - Qt: Handle saving input settings better
- Debugger: Free watchpoints in addition to breakpoints - Debugger: Free watchpoints in addition to breakpoints
- Qt: Move GL frame drawing back onto its own thread - Qt: Move GL frame drawing back onto its own thread
- GBA: Add status log level
0.2.0: (2015-04-03) 0.2.0: (2015-04-03)
Features: Features:

View File

@ -530,7 +530,7 @@ void GBAHalt(struct GBA* gba) {
static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format, va_list args) { static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format, va_list args) {
struct GBAThread* threadContext = GBAThreadGetContext(); struct GBAThread* threadContext = GBAThreadGetContext();
enum GBALogLevel logLevel = -1; enum GBALogLevel logLevel = GBA_LOG_ALL;
if (gba) { if (gba) {
logLevel = gba->logLevel; logLevel = gba->logLevel;

View File

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

View File

@ -192,6 +192,9 @@ bool GBASaveState(struct GBAThread* threadContext, struct VDir* dir, int slot, b
} }
bool success = GBASaveStateNamed(threadContext->gba, vf, screenshot); bool success = GBASaveStateNamed(threadContext->gba, vf, screenshot);
vf->close(vf); vf->close(vf);
if (success) {
GBALog(threadContext->gba, GBA_LOG_STATUS, "State %i saved", slot);
}
return success; return success;
} }
@ -203,6 +206,9 @@ bool GBALoadState(struct GBAThread* threadContext, struct VDir* dir, int slot) {
threadContext->rewindBufferSize = 0; threadContext->rewindBufferSize = 0;
bool success = GBALoadStateNamed(threadContext->gba, vf); bool success = GBALoadStateNamed(threadContext->gba, vf);
vf->close(vf); vf->close(vf);
if (success) {
GBALog(threadContext->gba, GBA_LOG_STATUS, "State %i loaded", slot);
}
return success; return success;
} }

View File

@ -681,9 +681,12 @@ void GBAThreadTakeScreenshot(struct GBAThread* threadContext) {
threadContext->gba->video.renderer->getPixels(threadContext->gba->video.renderer, &stride, &pixels); threadContext->gba->video.renderer->getPixels(threadContext->gba->video.renderer, &stride, &pixels);
png_structp png = PNGWriteOpen(vf); png_structp png = PNGWriteOpen(vf);
png_infop info = PNGWriteHeader(png, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS); png_infop info = PNGWriteHeader(png, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS);
PNGWritePixels(png, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, stride, pixels); bool success = PNGWritePixels(png, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS, stride, pixels);
PNGWriteClose(png, info); PNGWriteClose(png, info);
vf->close(vf); vf->close(vf);
if (success) {
GBALog(threadContext->gba, GBA_LOG_STATUS, "Screenshot saved");
}
} }
#endif #endif

View File

@ -61,7 +61,7 @@ GameController::GameController(QObject* parent)
m_threadContext.userData = this; m_threadContext.userData = this;
m_threadContext.rewindBufferCapacity = 0; m_threadContext.rewindBufferCapacity = 0;
m_threadContext.cheats = &m_cheatDevice; m_threadContext.cheats = &m_cheatDevice;
m_threadContext.logLevel = -1; m_threadContext.logLevel = GBA_LOG_ALL;
m_lux.p = this; m_lux.p = this;
m_lux.sample = [] (GBALuminanceSource* context) { m_lux.sample = [] (GBALuminanceSource* context) {

View File

@ -25,6 +25,7 @@ LogView::LogView(QWidget* parent)
connect(m_ui.levelFatal, SIGNAL(toggled(bool)), this, SLOT(setLevelFatal(bool))); connect(m_ui.levelFatal, SIGNAL(toggled(bool)), this, SLOT(setLevelFatal(bool)));
connect(m_ui.levelGameError, SIGNAL(toggled(bool)), this, SLOT(setLevelGameError(bool))); 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.levelSWI, SIGNAL(toggled(bool)), this, SLOT(setLevelSWI(bool)));
connect(m_ui.levelStatus, SIGNAL(toggled(bool)), this, SLOT(setLevelStatus(bool)));
connect(m_ui.clear, SIGNAL(clicked()), this, SLOT(clear())); connect(m_ui.clear, SIGNAL(clicked()), this, SLOT(clear()));
connect(m_ui.maxLines, SIGNAL(valueChanged(int)), this, SLOT(setMaxLines(int))); connect(m_ui.maxLines, SIGNAL(valueChanged(int)), this, SLOT(setMaxLines(int)));
m_ui.maxLines->setValue(DEFAULT_LINE_LIMIT); m_ui.maxLines->setValue(DEFAULT_LINE_LIMIT);
@ -57,6 +58,7 @@ void LogView::setLevels(int levels) {
m_ui.levelFatal->setCheckState(levels & GBA_LOG_FATAL ? Qt::Checked : Qt::Unchecked); m_ui.levelFatal->setCheckState(levels & GBA_LOG_FATAL ? Qt::Checked : Qt::Unchecked);
m_ui.levelGameError->setCheckState(levels & GBA_LOG_GAME_ERROR ? Qt::Checked : Qt::Unchecked); 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.levelSWI->setCheckState(levels & GBA_LOG_SWI ? Qt::Checked : Qt::Unchecked);
m_ui.levelStatus->setCheckState(levels & GBA_LOG_STATUS ? Qt::Checked : Qt::Unchecked);
emit levelsSet(levels); emit levelsSet(levels);
} }
@ -125,6 +127,14 @@ void LogView::setLevelSWI(bool set) {
} }
} }
void LogView::setLevelStatus(bool set) {
if (set) {
setLevel(GBA_LOG_STATUS);
} else {
clearLevel(GBA_LOG_STATUS);
}
}
void LogView::setMaxLines(int limit) { void LogView::setMaxLines(int limit) {
m_lineLimit = limit; m_lineLimit = limit;
while (m_lines > m_lineLimit) { while (m_lines > m_lineLimit) {
@ -150,6 +160,8 @@ QString LogView::toString(int level) {
return tr("GAME ERROR"); return tr("GAME ERROR");
case GBA_LOG_SWI: case GBA_LOG_SWI:
return tr("SWI"); return tr("SWI");
case GBA_LOG_STATUS:
return tr("STATUS");
} }
return QString(); return QString();
} }

View File

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

View File

@ -106,6 +106,16 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="levelStatus">
<property name="text">
<string>Status</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>