all repos — mgba @ 9c07698068ec289786178c36a273d0de588dcab0

mGBA Game Boy Advance Emulator

GBA: Add status log level
Jeffrey Pfau jeffrey@endrift.com
Sun, 26 Apr 2015 13:43:30 -0700
commit

9c07698068ec289786178c36a273d0de588dcab0

parent

f52d91c6c8b93f82827254fa46c2a16c799fa2ae

M CHANGESCHANGES

@@ -45,6 +45,7 @@ - Qt: Show multiplayer numbers in window title

- 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:
M src/gba/gba.csrc/gba/gba.c

@@ -530,7 +530,7 @@ }

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;
M src/gba/gba.hsrc/gba/gba.h

@@ -45,8 +45,9 @@ GBA_LOG_STUB = 0x20,

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
M src/gba/serialize.csrc/gba/serialize.c

@@ -192,6 +192,9 @@ return false;

} 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 @@ }

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; }
M src/gba/supervisor/thread.csrc/gba/supervisor/thread.c

@@ -681,9 +681,12 @@ struct VFile* vf = VDirOptionalOpenIncrementFile(threadContext->stateDir, threadContext->gba->activeFile, "screenshot", "-", ".png", O_CREAT | O_TRUNC | O_WRONLY);

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
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -61,7 +61,7 @@ m_threadContext.renderer = &m_renderer->d;

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) {
M src/platform/qt/LogView.cppsrc/platform/qt/LogView.cpp

@@ -25,6 +25,7 @@ connect(m_ui.levelError, SIGNAL(toggled(bool)), this, SLOT(setLevelError(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.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 @@ m_ui.levelError->setCheckState(levels & GBA_LOG_ERROR ? 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.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 @@ clearLevel(GBA_LOG_SWI);

} } +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 @@ case GBA_LOG_GAME_ERROR:

return tr("GAME ERROR"); case GBA_LOG_SWI: return tr("SWI"); + case GBA_LOG_STATUS: + return tr("STATUS"); } return QString(); }
M src/platform/qt/LogView.hsrc/platform/qt/LogView.h

@@ -40,6 +40,7 @@ void setLevelError(bool);

void setLevelFatal(bool); void setLevelGameError(bool); void setLevelSWI(bool); + void setLevelStatus(bool); void setMaxLines(int);
M src/platform/qt/LogView.uisrc/platform/qt/LogView.ui

@@ -106,6 +106,16 @@ <string>SW Interrupt</string>

</property> </widget> </item> + <item> + <widget class="QCheckBox" name="levelStatus"> + <property name="text"> + <string>Status</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </item> </layout> </widget> </item>