all repos — mgba @ 1a0e44c014ad34bea30d237d27015d82d02cda4b

mGBA Game Boy Advance Emulator

Merge branch 'master' (early part) into medusa
Vicki Pfau vi@endrift.com
Fri, 28 Jun 2019 15:45:45 -0700
commit

1a0e44c014ad34bea30d237d27015d82d02cda4b

parent

3b379d7e8db493693eb549b5cb6aff76803e7c83

M CHANGESCHANGES

@@ -71,6 +71,8 @@ - GBA Hardware: RTC accuracy improvements

- GB Timer: Minor accuracy improvements - GB Audio: Clock frame events on DIV - GBA: Fix SharkPort saves for EEPROM games + - Qt: Fix opening in fullscreen (fixes mgba.io/i/993) + - Python: Fix package directory Misc: - GBA Timer: Use global cycles for timers - GBA: Extend oddly-sized ROMs to full address space (fixes mgba.io/i/722)
M CMakeLists.txtCMakeLists.txt

@@ -322,13 +322,20 @@ check_function_exists(freelocale HAVE_FREELOCALE)

check_function_exists(uselocale HAVE_USELOCALE) check_function_exists(setlocale HAVE_SETLOCALE) else() - if(DEFINED 3DS) + if(DEFINED 3DS OR DEFINED WII) + set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,snprintf_l) check_function_exists(snprintf_l HAVE_SNPRINTF_L) + set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,strtof_l) check_function_exists(strtof_l HAVE_STRTOF_L) + set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,newlocale) check_function_exists(newlocale HAVE_NEWLOCALE) + set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,freelocale) check_function_exists(freelocale HAVE_FREELOCALE) + set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,uselocale) check_function_exists(uselocale HAVE_USELOCALE) + set(CMAKE_REQUIRED_FLAGS -Wl,--require-defined,setlocale) check_function_exists(setlocale HAVE_SETLOCALE) + unset(CMAKE_REQUIRED_FLAGS) endif() if(NOT DEFINED 3DS AND NOT DEFINED PSP2 AND NOT DEFINED WII) set(DISABLE_DEPS ON CACHE BOOL "This platform cannot build with dependencies" FORCE)

@@ -355,7 +362,7 @@ if(HAVE_LOCALTIME_R)

list(APPEND FUNCTION_DEFINES HAVE_LOCALTIME_R) endif() -if(HAVE_NEWLOCALE AND HAVE_FREELOCALE AND HAVE_USELOCALE OR APPLE OR DEFINED 3DS) +if(HAVE_NEWLOCALE AND HAVE_FREELOCALE AND HAVE_USELOCALE OR APPLE) list(APPEND FUNCTION_DEFINES HAVE_LOCALE) if (HAVE_STRTOF_L) list(APPEND FUNCTION_DEFINES HAVE_STRTOF_L)

@@ -379,6 +386,7 @@ endif()

# Feature dependencies set(FEATURE_DEFINES) +set(FEATURE_FLAGS) set(FEATURES) set(ENABLES) if(CMAKE_SYSTEM_NAME MATCHES .*BSD)

@@ -517,6 +525,7 @@ else()

set(MAGICKWAND_DEB_VERSION "-6.q16-2") endif() list(APPEND FEATURE_DEFINES MAGICKWAND_VERSION_MAJOR=${MAGICKWAND_VERSION_MAJOR}) + list(APPEND FEATURE_FLAGS ${MAGICKWAND_CFLAGS_OTHER}) set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS},libmagickwand${MAGICKWAND_DEB_VERSION}") endif()

@@ -807,7 +816,7 @@ if(BUILD_SHARED)

add_library(${BINARY_NAME} SHARED ${SRC} ${VFS_SRC}) if(BUILD_STATIC) add_library(${BINARY_NAME}-static STATIC ${SRC}) - set_target_properties(${BINARY_NAME}-static PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}") + set_target_properties(${BINARY_NAME}-static PROPERTIES COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}" COMPILE_OPTIONS "${FEATURE_FLAGS}") install(TARGETS ${BINARY_NAME}-static DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME}) add_dependencies(${BINARY_NAME}-static version-info) endif()

@@ -816,7 +825,7 @@ add_library(${BINARY_NAME} STATIC ${SRC})

endif() add_dependencies(${BINARY_NAME} version-info) - set_target_properties(${BINARY_NAME} PROPERTIES VERSION ${LIB_VERSION_STRING} SOVERSION ${LIB_VERSION_ABI} COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}") + set_target_properties(${BINARY_NAME} PROPERTIES VERSION ${LIB_VERSION_STRING} SOVERSION ${LIB_VERSION_ABI} COMPILE_DEFINITIONS "${OS_DEFINES};${FEATURE_DEFINES};${FUNCTION_DEFINES}" COMPILE_OPTIONS "${FEATURE_FLAGS}") target_link_libraries(${BINARY_NAME} ${DEBUGGER_LIB} ${DEPENDENCY_LIB} ${OS_LIB}) install(TARGETS ${BINARY_NAME} LIBRARY DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME} NAMELINK_SKIP ARCHIVE DESTINATION ${LIBDIR} RUNTIME DESTINATION ${LIBDIR} COMPONENT lib${BINARY_NAME})
M README.mdREADME.md

@@ -124,7 +124,7 @@ Note that you should not do a `make install` on macOS, as it will not work properly.

#### Windows developer building -To build on Windows for development, using MSYS2 is recommended. Follow the installation steps found on their [website](https://msys2.github.io). Make sure you're running the 32-bit version ("MSYS2 MinGW 32-bit") (or the 64-bit version "MSYS2 MinGW 64-bit" if you want to build for x86_64) and run this additional command (including the braces) to install the needed dependencies (please note that this involves downloading over 500MiB of packages, so it will take a long time): +To build on Windows for development, using MSYS2 is recommended. Follow the installation steps found on their [website](https://msys2.github.io). Make sure you're running the 32-bit version ("MSYS2 MinGW 32-bit") (or the 64-bit version "MSYS2 MinGW 64-bit" if you want to build for x86_64) and run this additional command (including the braces) to install the needed dependencies (please note that this involves downloading over 1100MiB of packages, so it will take a long time): For x86 (32 bit) builds:

@@ -221,7 +221,7 @@

Copyright --------- -medusa is Copyright © 2013 – 2017 Jeffrey Pfau. It is distributed under the [Mozilla Public License version 2.0](https://www.mozilla.org/MPL/2.0/). A copy of the license is available in the distributed LICENSE file. +medusa is Copyright © 2013 – 2019 Jeffrey Pfau. It is distributed under the [Mozilla Public License version 2.0](https://www.mozilla.org/MPL/2.0/). A copy of the license is available in the distributed LICENSE file. medusa contains the following third-party libraries:
M README_DE.mdREADME_DE.md

@@ -106,7 +106,7 @@ Bitte beachte, dass Du unter macOS nicht 'make install' verwenden solltest, da dies nicht korrekt funktionieren wird.

### Für Entwickler: Kompilieren unter Windows -Um mGBA auf Windows zu kompilieren, wird MSYS2 empfohlen. Befolge die Installationsschritte auf der [MSYS2-Website](https://msys2.github.io). Stelle sicher, dass Du die 32-Bit-Version ("MSYS2 MinGW 32-bit") (oder die 64-Bit-Version "MSYS2 MinGW 64-bit", wenn Du mGBA für x86_64 kompilieren willst) verwendest und führe folgendes Kommando (einschließlich der Klammern) aus, um alle benötigten Abhängigkeiten zu installieren. Bitte beachte, dass dafür über 500MiB an Paketen heruntergeladen werden, was eine Weile dauern kann): +Um mGBA auf Windows zu kompilieren, wird MSYS2 empfohlen. Befolge die Installationsschritte auf der [MSYS2-Website](https://msys2.github.io). Stelle sicher, dass Du die 32-Bit-Version ("MSYS2 MinGW 32-bit") (oder die 64-Bit-Version "MSYS2 MinGW 64-bit", wenn Du mGBA für x86_64 kompilieren willst) verwendest und führe folgendes Kommando (einschließlich der Klammern) aus, um alle benötigten Abhängigkeiten zu installieren. Bitte beachte, dass dafür über 1100MiB an Paketen heruntergeladen werden, was eine Weile dauern kann: Für x86 (32 Bit):

@@ -164,7 +164,7 @@

Copyright --------- -Copyright für mGBA © 2013 – 2017 Jeffrey Pfau. mGBA wird unter der [Mozilla Public License version 2.0](https://www.mozilla.org/MPL/2.0/) veröffentlicht. Eine Kopie der Lizenz ist in der mitgelieferten Datei LICENSE verfügbar. +Copyright für mGBA © 2013 – 2018 Jeffrey Pfau. mGBA wird unter der [Mozilla Public License version 2.0](https://www.mozilla.org/MPL/2.0/) veröffentlicht. Eine Kopie der Lizenz ist in der mitgelieferten Datei LICENSE verfügbar. mGBA beinhaltet die folgenden Bibliotheken von Drittanbietern:
M src/gba/cheats/gameshark.csrc/gba/cheats/gameshark.c

@@ -93,6 +93,7 @@

bool GBACheatAddGameSharkRaw(struct GBACheatSet* cheats, uint32_t op1, uint32_t op2) { enum GBAGameSharkType type = op1 >> 28; struct mCheat* cheat = 0; + int romPatch = 0; if (cheats->incompleteCheat != COMPLETE) { struct mCheat* incompleteCheat = mCheatListGetPointer(&cheats->d.list, cheats->incompleteCheat);

@@ -148,10 +149,16 @@ cheat->address = op2;

cheats->incompleteCheat = mCheatListIndex(&cheats->d.list, cheat); break; case GSA_PATCH: - cheats->romPatches[0].address = BASE_CART0 | ((op1 & 0xFFFFFF) << 1); - cheats->romPatches[0].newValue = op2; - cheats->romPatches[0].applied = false; - cheats->romPatches[0].exists = true; + while (cheats->romPatches[romPatch].exists) { + ++romPatch; + if (romPatch >= MAX_ROM_PATCHES) { + break; + } + } + cheats->romPatches[romPatch].address = BASE_CART0 | ((op1 & 0xFFFFFF) << 1); + cheats->romPatches[romPatch].newValue = op2; + cheats->romPatches[romPatch].applied = false; + cheats->romPatches[romPatch].exists = true; return true; case GSA_BUTTON: switch (op1 & 0x00F00000) {
M src/platform/python/setup.py.insrc/platform/python/setup.py.in

@@ -22,7 +22,7 @@ author_email="jeffrey@endrift.com",

url="http://github.com/mgba-emu/mgba/", packages=["mgba"], package_dir={ - "mgba": "${CMAKE_CURRENT_SOURCE_DIR}" + "mgba": "${CMAKE_CURRENT_SOURCE_DIR}/mgba" }, setup_requires=['cffi>=1.6', 'pytest-runner'], install_requires=['cffi>=1.6', 'cached-property'],
M src/platform/qt/AboutScreen.uisrc/platform/qt/AboutScreen.ui

@@ -83,8 +83,8 @@ <pointsize>10</pointsize>

</font> </property> <property name="text"> - <string>© 2013 – 2017 Jeffrey Pfau, licensed under the Mozilla Public License, version 2.0 -Game Boy and Game Boy Advance are registered trademarks of Nintendo Co., Ltd.</string> + <string>© 2013 – 2019 Jeffrey Pfau, licensed under the Mozilla Public License, version 2.0 +Game Boy Advance is a registered trademark of Nintendo Co., Ltd.</string> </property> <property name="alignment"> <set>Qt::AlignCenter</set>
M src/platform/qt/CMakeLists.txtsrc/platform/qt/CMakeLists.txt

@@ -217,9 +217,6 @@ if(WIN32)

configure_file(${CMAKE_SOURCE_DIR}/res/win.rc.in ${CMAKE_BINARY_DIR}/res/${BINARY_NAME}.rc) list(APPEND RESOURCES ${CMAKE_BINARY_DIR}/res/${BINARY_NAME}.rc) set_source_files_properties(${CMAKE_BINARY_DIR}/res/${BINARY_NAME}.rc PROPERTIES OBJECT_DEPENDS ${CMAKE_SOURCE_DIR}/res/${BINARY_NAME}.ico) - if(QT_STATIC) - list(APPEND QT_LIBRARIES qwindows Qt5PlatformSupport imm32) - endif() endif() if(NOT DEFINED DATADIR) if(APPLE)

@@ -275,6 +272,10 @@

list(APPEND QT_LIBRARIES Qt5::Widgets) if(BUILD_GL OR BUILD_GLES2) list(APPEND QT_LIBRARIES Qt5::OpenGL ${OPENGL_LIBRARY} ${OPENGLES2_LIBRARY}) +endif() +if(WIN32 AND QT_STATIC) + list(APPEND QT_LIBRARIES qwindows dwmapi imm32 uxtheme Qt5EventDispatcherSupport Qt5FontDatabaseSupport Qt5ThemeSupport) + set_target_properties(Qt5::Core PROPERTIES INTERFACE_LINK_LIBRARIES "qtpcre2;version;ws2_32") endif() target_link_libraries(${BINARY_NAME}-qt ${PLATFORM_LIBRARY} ${BINARY_NAME} ${QT_LIBRARIES}) set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}" PARENT_SCOPE)
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -216,7 +216,9 @@ QSize newSize(size);

m_screenWidget->setSizeHint(newSize); newSize -= m_screenWidget->size(); newSize += this->size(); - resize(newSize); + if (!isFullScreen()) { + resize(newSize); + } } void Window::setConfig(ConfigController* config) {
M src/platform/qt/ts/medusa-emu-de.tssrc/platform/qt/ts/medusa-emu-de.ts

@@ -40,10 +40,10 @@ <translation>{projectVersion}</translation>

</message> <message> <location filename="../AboutScreen.ui" line="86"/> - <source>© 2013 – 2017 Jeffrey Pfau, licensed under the Mozilla Public License, version 2.0 -Game Boy and Game Boy Advance are registered trademarks of Nintendo Co., Ltd.</source> - <translation>© 2013 – 2017 Jeffrey Pfau, lizenziert unter der Mozilla Public License, Version 2.0 -Game Boy und Game Boy Advance sind eingetragene Warenzeichen von Nintendo Co., Ltd.</translation> + <source>© 2013 – 2019 Jeffrey Pfau, licensed under the Mozilla Public License, version 2.0 +Game Boy Advance is a registered trademark of Nintendo Co., Ltd.</source> + <translation>© 2013 – 2019 Jeffrey Pfau, lizenziert unter der Mozilla Public License, Version 2.0 +Game Boy Advance ist ein eingetragenes Warenzeichen von Nintendo Co., Ltd.</translation> </message> <message> <location filename="../AboutScreen.ui" line="155"/>
M src/platform/qt/ts/medusa-emu-es.tssrc/platform/qt/ts/medusa-emu-es.ts

@@ -30,9 +30,9 @@ <translation>{projectName} desea agradecer a los siguientes patrocinadores desde Patreon:</translation>

</message> <message> <location filename="../AboutScreen.ui" line="86"/> - <source>© 2013 – 2017 Jeffrey Pfau, licensed under the Mozilla Public License, version 2.0 + <source>© 2013 – 2018 Jeffrey Pfau, licensed under the Mozilla Public License, version 2.0 Game Boy Advance is a registered trademark of Nintendo Co., Ltd.</source> - <translation>© 2013 – 2017 Jeffrey Pfau, licenciado bajo la Mozilla Public License, versión 2.0 + <translation>© 2013 – 2018 Jeffrey Pfau, licenciado bajo la Mozilla Public License, versión 2.0 Game Boy Advance es una marca registrada de Nintendo Co., Ltd.</translation> </message> <message>
M src/platform/sdl/gl-common.csrc/platform/sdl/gl-common.c

@@ -7,6 +7,13 @@ #include "main.h"

#include <mgba/core/version.h> +void mSDLGLDoViewport(int w, int h, struct VideoBackend* v) { + v->resized(v, w, h); + v->clear(v); + v->swap(v); + v->clear(v); +} + void mSDLGLCommonSwap(struct VideoBackend* context) { struct mSDLRenderer* renderer = (struct mSDLRenderer*) context->user; #if SDL_VERSION_ATLEAST(2, 0, 0)
M src/platform/sdl/gl-common.hsrc/platform/sdl/gl-common.h

@@ -12,6 +12,7 @@ CXX_GUARD_START

#include "main.h" +void mSDLGLDoViewport(int w, int h, struct VideoBackend* v); void mSDLGLCommonSwap(struct VideoBackend* context); void mSDLGLCommonInit(struct mSDLRenderer* renderer);
M src/platform/sdl/gl-sdl.csrc/platform/sdl/gl-sdl.c

@@ -13,13 +13,6 @@ #include <mgba-util/math.h>

#include "platform/opengl/gl.h" -static void _doViewport(int w, int h, struct VideoBackend* v) { - v->resized(v, w, h); - v->clear(v); - v->swap(v); - v->clear(v); -} - static bool mSDLGLInit(struct mSDLRenderer* renderer); static void mSDLGLRunloop(struct mSDLRenderer* renderer, void* user); static void mSDLGLDeinit(struct mSDLRenderer* renderer);

@@ -47,7 +40,7 @@ renderer->gl.d.swap = mSDLGLCommonSwap;

renderer->gl.d.init(&renderer->gl.d, 0); renderer->gl.d.setDimensions(&renderer->gl.d, renderer->width, renderer->height); - _doViewport(renderer->viewportWidth, renderer->viewportHeight, &renderer->gl.d); + mSDLGLDoViewport(renderer->viewportWidth, renderer->viewportHeight, &renderer->gl.d); return true; }

@@ -63,7 +56,7 @@ #if SDL_VERSION_ATLEAST(2, 0, 0)

// Event handling can change the size of the screen if (renderer->player.windowUpdated) { SDL_GetWindowSize(renderer->window, &renderer->viewportWidth, &renderer->viewportHeight); - _doViewport(renderer->viewportWidth, renderer->viewportHeight, v); + mSDLGLDoViewport(renderer->viewportWidth, renderer->viewportHeight, v); renderer->player.windowUpdated = 0; } #endif
M src/platform/sdl/gles2-sdl.csrc/platform/sdl/gles2-sdl.c

@@ -115,6 +115,8 @@ renderer->gl2.d.filter = renderer->filter;

renderer->gl2.d.swap = mSDLGLCommonSwap; renderer->gl2.d.init(&renderer->gl2.d, 0); renderer->gl2.d.setDimensions(&renderer->gl2.d, renderer->width, renderer->height); + + mSDLGLDoViewport(renderer->viewportWidth, renderer->viewportHeight, &renderer->gl2.d); return true; }

@@ -126,6 +128,14 @@

while (mCoreThreadIsActive(context)) { while (SDL_PollEvent(&event)) { mSDLHandleEvent(context, &renderer->player, &event); +#if SDL_VERSION_ATLEAST(2, 0, 0) + // Event handling can change the size of the screen + if (renderer->player.windowUpdated) { + SDL_GetWindowSize(renderer->window, &renderer->viewportWidth, &renderer->viewportHeight); + mSDLGLDoViewport(renderer->viewportWidth, renderer->viewportHeight, v); + renderer->player.windowUpdated = 0; + } +#endif } if (mCoreSyncWaitFrameStart(&context->impl->sync)) {
M src/util/vfs/vfs-zip.csrc/util/vfs/vfs-zip.c

@@ -61,6 +61,7 @@ struct VFileZip {

struct VFile d; unzFile z; void* buffer; + size_t bufferSize; size_t fileSize; }; #endif

@@ -451,7 +452,9 @@ #else

bool _vfzClose(struct VFile* vf) { struct VFileZip* vfz = (struct VFileZip*) vf; unzCloseCurrentFile(vfz->z); - free(vfz->buffer); + if (vfz->buffer) { + mappedMemoryFree(vfz->buffer, vfz->bufferSize); + } free(vfz); return true; }

@@ -536,6 +539,8 @@ unzCloseCurrentFile(vfz->z);

unzOpenCurrentFile(vfz->z); vf->seek(vf, pos, SEEK_SET); + vfz->bufferSize = size; + return vfz->buffer; }

@@ -619,6 +624,7 @@

struct VFileZip* vfz = malloc(sizeof(struct VFileZip)); vfz->z = vdz->z; vfz->buffer = 0; + vfz->bufferSize = 0; vfz->fileSize = info.uncompressed_size; vfz->d.close = _vfzClose;