From 9c07698068ec289786178c36a273d0de588dcab0 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 26 Apr 2015 13:43:30 -0700 Subject: [PATCH] GBA: Add status log level --- CHANGES | 1 + src/gba/gba.c | 2 +- src/gba/gba.h | 3 ++- src/gba/serialize.c | 6 ++++++ src/gba/supervisor/thread.c | 5 ++++- src/platform/qt/GameController.cpp | 2 +- src/platform/qt/LogView.cpp | 12 ++++++++++++ src/platform/qt/LogView.h | 1 + src/platform/qt/LogView.ui | 10 ++++++++++ 9 files changed, 38 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 27052cede..afbd738ab 100644 --- a/CHANGES +++ b/CHANGES @@ -45,6 +45,7 @@ Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints - Qt: Move GL frame drawing back onto its own thread + - GBA: Add status log level 0.2.0: (2015-04-03) Features: diff --git a/src/gba/gba.c b/src/gba/gba.c index fbf38f06a..35eb8573e 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -530,7 +530,7 @@ void GBAHalt(struct GBA* gba) { static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format, va_list args) { struct GBAThread* threadContext = GBAThreadGetContext(); - enum GBALogLevel logLevel = -1; + enum GBALogLevel logLevel = GBA_LOG_ALL; if (gba) { logLevel = gba->logLevel; diff --git a/src/gba/gba.h b/src/gba/gba.h index ec5b3f2f5..5c2d4fbcf 100644 --- a/src/gba/gba.h +++ b/src/gba/gba.h @@ -45,8 +45,9 @@ enum GBALogLevel { GBA_LOG_GAME_ERROR = 0x100, GBA_LOG_SWI = 0x200, + GBA_LOG_STATUS = 0x400, - GBA_LOG_ALL = 0x33F, + GBA_LOG_ALL = 0x73F, #ifdef NDEBUG GBA_LOG_DANGER = GBA_LOG_ERROR diff --git a/src/gba/serialize.c b/src/gba/serialize.c index 9412d7ac0..4ba96eb37 100644 --- a/src/gba/serialize.c +++ b/src/gba/serialize.c @@ -192,6 +192,9 @@ bool GBASaveState(struct GBAThread* threadContext, struct VDir* dir, int slot, b } bool success = GBASaveStateNamed(threadContext->gba, vf, screenshot); vf->close(vf); + if (success) { + GBALog(threadContext->gba, GBA_LOG_STATUS, "State %i saved", slot); + } return success; } @@ -203,6 +206,9 @@ bool GBALoadState(struct GBAThread* threadContext, struct VDir* dir, int slot) { threadContext->rewindBufferSize = 0; bool success = GBALoadStateNamed(threadContext->gba, vf); vf->close(vf); + if (success) { + GBALog(threadContext->gba, GBA_LOG_STATUS, "State %i loaded", slot); + } return success; } diff --git a/src/gba/supervisor/thread.c b/src/gba/supervisor/thread.c index 98a207fd8..f9f04a411 100644 --- a/src/gba/supervisor/thread.c +++ b/src/gba/supervisor/thread.c @@ -681,9 +681,12 @@ void GBAThreadTakeScreenshot(struct GBAThread* threadContext) { threadContext->gba->video.renderer->getPixels(threadContext->gba->video.renderer, &stride, &pixels); png_structp png = PNGWriteOpen(vf); 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); vf->close(vf); + if (success) { + GBALog(threadContext->gba, GBA_LOG_STATUS, "Screenshot saved"); + } } #endif diff --git a/src/platform/qt/GameController.cpp b/src/platform/qt/GameController.cpp index 4d34ddf0d..92c843f6b 100644 --- a/src/platform/qt/GameController.cpp +++ b/src/platform/qt/GameController.cpp @@ -61,7 +61,7 @@ GameController::GameController(QObject* parent) m_threadContext.userData = this; m_threadContext.rewindBufferCapacity = 0; m_threadContext.cheats = &m_cheatDevice; - m_threadContext.logLevel = -1; + m_threadContext.logLevel = GBA_LOG_ALL; m_lux.p = this; m_lux.sample = [] (GBALuminanceSource* context) { diff --git a/src/platform/qt/LogView.cpp b/src/platform/qt/LogView.cpp index 41b8cc4d6..15a299480 100644 --- a/src/platform/qt/LogView.cpp +++ b/src/platform/qt/LogView.cpp @@ -25,6 +25,7 @@ LogView::LogView(QWidget* parent) 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.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.maxLines, SIGNAL(valueChanged(int)), this, SLOT(setMaxLines(int))); 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.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); 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) { m_lineLimit = limit; while (m_lines > m_lineLimit) { @@ -150,6 +160,8 @@ QString LogView::toString(int level) { return tr("GAME ERROR"); case GBA_LOG_SWI: return tr("SWI"); + case GBA_LOG_STATUS: + return tr("STATUS"); } return QString(); } diff --git a/src/platform/qt/LogView.h b/src/platform/qt/LogView.h index 56fa33640..66eb18b71 100644 --- a/src/platform/qt/LogView.h +++ b/src/platform/qt/LogView.h @@ -40,6 +40,7 @@ public slots: void setLevelFatal(bool); void setLevelGameError(bool); void setLevelSWI(bool); + void setLevelStatus(bool); void setMaxLines(int); diff --git a/src/platform/qt/LogView.ui b/src/platform/qt/LogView.ui index 467d37053..020c826ad 100644 --- a/src/platform/qt/LogView.ui +++ b/src/platform/qt/LogView.ui @@ -106,6 +106,16 @@ + + + + Status + + + true + + +