Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Features:
- Tool for converting scanned pictures of e-Reader cards to raw dotcode data
Emulation fixes:
- ARM: Fix LDM^ with empty rlist (fixes mgba.io/i/2127)
- Core: Fix first event scheduling after loading savestate
- GB Serialize: Fix switching speed modes when loading a state (fixes mgba.io/i/2097)
- GB: Fix skipping BIOS
Expand All @@ -18,11 +19,13 @@ Other fixes:
- Qt: Fix OpenGL renderer lagging behind when fast-forwarding (fixes mgba.io/i/2094)
- Qt: Fix smudged window icon on Windows
- Qt: Fix saving settings enabling camera when camera name changes (fixes mgba.io/i/2125)
- Qt: Fix frames getting backlogged (fixes mgba.io/i/2122)
Misc:
- Core: Truncate preloading ROMs that slightly exceed max size (fixes mgba.io/i/2093)
- GBA: Default-enable VBA bug compat for Ruby and Emerald ROM hacks
- GBA Memory: Log GPIO writes on non-GPIO carts as Pak Hardware instead of Memory
- Qt: Add ROM filename and size to bug reporter
- Qt: Rearrange menus some

0.9.0: (2021-03-28)
Features:
Expand Down
4 changes: 2 additions & 2 deletions src/arm/isa-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,15 @@ ATTRIBUTE_NOINLINE static void _neutralS(struct ARMCore* cpu, int32_t d) {

#define ARM_MS_PRE_load \
enum PrivilegeMode privilegeMode; \
if (!(rs & 0x8000)) { \
if (!(rs & 0x8000) && rs) { \
privilegeMode = cpu->privilegeMode; \
ARMSetPrivilegeMode(cpu, MODE_SYSTEM); \
}

#define ARM_MS_POST_store ARMSetPrivilegeMode(cpu, privilegeMode);

#define ARM_MS_POST_load \
if (!(rs & 0x8000)) { \
if (!(rs & 0x8000) && rs) { \
ARMSetPrivilegeMode(cpu, privilegeMode); \
} else if (_ARMModeHasSPSR(cpu->cpsr.priv)) { \
cpu->cpsr = cpu->spsr; \
Expand Down
11 changes: 11 additions & 0 deletions src/platform/qt/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ Display::Display(QWidget* parent)
setMouseTracking(true);
}

void Display::attach(std::shared_ptr<CoreController> controller) {
connect(controller.get(), &CoreController::stateLoaded, this, &Display::resizeContext);
connect(controller.get(), &CoreController::stateLoaded, this, &Display::forceDraw);
connect(controller.get(), &CoreController::rewound, this, &Display::forceDraw);
connect(controller.get(), &CoreController::paused, this, &Display::pauseDrawing);
connect(controller.get(), &CoreController::unpaused, this, &Display::unpauseDrawing);
connect(controller.get(), &CoreController::frameAvailable, this, &Display::framePosted);
connect(controller.get(), &CoreController::statusPosted, this, &Display::showMessage);
connect(controller.get(), &CoreController::didReset, this, &Display::resizeContext);
}

void Display::resizeEvent(QResizeEvent*) {
m_messagePainter.resize(size(), m_lockAspectRatio, devicePixelRatio());
}
Expand Down
1 change: 1 addition & 0 deletions src/platform/qt/Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Q_OBJECT
bool isFiltered() const { return m_filter; }
bool isShowOSD() const { return m_showOSD; }

void attach(std::shared_ptr<CoreController>);
virtual void startDrawing(std::shared_ptr<CoreController>) = 0;
virtual bool isDrawing() const = 0;
virtual bool supportsShaders() const = 0;
Expand Down
26 changes: 18 additions & 8 deletions src/platform/qt/DisplayGL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ void PainterGL::resizeContext() {
if (m_dims == size) {
return;
}
dequeueAll();
dequeueAll(false);
m_backend->setDimensions(m_backend, size.width(), size.height());
}

Expand Down Expand Up @@ -429,7 +429,7 @@ void PainterGL::start() {
}

void PainterGL::draw() {
if (!m_active || m_queue.isEmpty()) {
if (!m_started || m_queue.isEmpty()) {
return;
}
mCoreSync* sync = &m_context->thread()->impl->sync;
Expand Down Expand Up @@ -461,6 +461,11 @@ void PainterGL::draw() {
performDraw();
m_backend->swap(m_backend);
}

QMutexLocker locker(&m_mutex);
if (!m_queue.isEmpty()) {
QTimer::singleShot(1, this, &PainterGL::draw);
}
}

void PainterGL::forceDraw() {
Expand All @@ -477,7 +482,7 @@ void PainterGL::forceDraw() {
void PainterGL::stop() {
m_active = false;
m_started = false;
dequeueAll();
dequeueAll(false);
if (m_context) {
if (m_videoProxy) {
m_videoProxy->detach(m_context.get());
Expand All @@ -499,6 +504,7 @@ void PainterGL::stop() {

void PainterGL::pause() {
m_active = false;
dequeueAll(true);
}

void PainterGL::unpause() {
Expand Down Expand Up @@ -551,20 +557,24 @@ void PainterGL::dequeue() {
m_buffer = buffer;
}

void PainterGL::dequeueAll() {
void PainterGL::dequeueAll(bool keep) {
QMutexLocker locker(&m_mutex);
uint32_t* buffer = 0;
m_mutex.lock();
while (!m_queue.isEmpty()) {
buffer = m_queue.dequeue();
if (buffer) {
if (keep) {
if (m_buffer && buffer) {
m_free.append(m_buffer);
m_buffer = buffer;
}
} else if (buffer) {
m_free.append(buffer);
}
}
if (m_buffer) {
if (m_buffer && !keep) {
m_free.append(m_buffer);
m_buffer = nullptr;
}
m_mutex.unlock();
}

void PainterGL::setVideoProxy(std::shared_ptr<VideoProxy> proxy) {
Expand Down
2 changes: 1 addition & 1 deletion src/platform/qt/DisplayGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public slots:
void makeCurrent();
void performDraw();
void dequeue();
void dequeueAll();
void dequeueAll(bool keep = false);

std::array<std::array<uint32_t, 0x100000>, 3> m_buffers;
QList<uint32_t*> m_free;
Expand Down
18 changes: 4 additions & 14 deletions src/platform/qt/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1181,9 +1181,6 @@ void Window::setupMenu(QMenuBar* menubar) {
m_actions.addMenu(tr("Recent"), "mru", "file");
m_actions.addSeparator("file");

m_actions.addAction(tr("Make portable"), "makePortable", this, &Window::tryMakePortable, "file");
m_actions.addSeparator("file");

Action* loadState = addGameAction(tr("&Load state"), "loadState", [this]() {
this->openStateWindow(LoadSave::LOAD);
}, "file", QKeySequence("F10"));
Expand Down Expand Up @@ -1241,9 +1238,6 @@ void Window::setupMenu(QMenuBar* menubar) {
m_nonMpActions.append(quickSave);
}

m_actions.addSeparator("file");
m_actions.addAction(tr("Load camera image..."), "loadCamImage", this, &Window::loadCamImage, "file");

#ifdef M_CORE_GBA
m_actions.addSeparator("file");
m_actions.addAction(tr("Convert save game..."), "convertSave", openControllerTView<SaveConverter>(), "file");
Expand Down Expand Up @@ -1373,6 +1367,8 @@ void Window::setupMenu(QMenuBar* menubar) {
}

#ifdef M_CORE_GB
m_actions.addAction(tr("Load camera image..."), "loadCamImage", this, &Window::loadCamImage, "emu");

Action* gbPrint = addGameAction(tr("Game Boy Printer..."), "gbPrint", [this]() {
PrinterView* view = new PrinterView(m_controller);
openView(view);
Expand Down Expand Up @@ -1540,6 +1536,7 @@ void Window::setupMenu(QMenuBar* menubar) {

m_actions.addSeparator("tools");
m_actions.addAction(tr("Settings..."), "settings", this, &Window::openSettingsWindow, "tools");
m_actions.addAction(tr("Make portable"), "makePortable", this, &Window::tryMakePortable, "tools");

#ifdef USE_DEBUGGERS
m_actions.addSeparator("tools");
Expand Down Expand Up @@ -1963,14 +1960,7 @@ void Window::setController(CoreController* controller, const QString& fname) {
}

void Window::attachDisplay() {
connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::resizeContext);
connect(m_controller.get(), &CoreController::stateLoaded, m_display.get(), &Display::forceDraw);
connect(m_controller.get(), &CoreController::rewound, m_display.get(), &Display::forceDraw);
connect(m_controller.get(), &CoreController::paused, m_display.get(), &Display::pauseDrawing);
connect(m_controller.get(), &CoreController::unpaused, m_display.get(), &Display::unpauseDrawing);
connect(m_controller.get(), &CoreController::frameAvailable, m_display.get(), &Display::framePosted);
connect(m_controller.get(), &CoreController::statusPosted, m_display.get(), &Display::showMessage);
connect(m_controller.get(), &CoreController::didReset, m_display.get(), &Display::resizeContext);
m_display->attach(m_controller);
connect(m_display.get(), &Display::drawingStarted, this, &Window::changeRenderer);
m_display->startDrawing(m_controller);
}
Expand Down
14 changes: 11 additions & 3 deletions src/platform/qt/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,17 @@ int main(int argc, char* argv[]) {
mSubParser subparser;
initParserForGraphics(&subparser, &graphicsOpts);
bool loaded = configController.parseArguments(&args, argc, argv, &subparser);
if (loaded && args.showHelp) {
usage(argv[0], subparser.usage);
return 0;
if (loaded) {
if (args.showHelp) {
usage(argv[0], subparser.usage);
freeArguments(&args);
return 0;
}
if (args.showVersion) {
version(argv[0]);
freeArguments(&args);
return 0;
}
}

QApplication::setApplicationName(projectName);
Expand Down
Loading