all repos — mgba @ 0a4b47cccfcbbe60a8af3616ff930b09b50b9682

mGBA Game Boy Advance Emulator

Merge branch 'master' into medusa
Vicki Pfau vi@endrift.com
Mon, 20 Mar 2017 17:37:39 -0700
commit

0a4b47cccfcbbe60a8af3616ff930b09b50b9682

parent

40f1d66685fccdd80eb14a56c07c842c332e551d

M .travis-deps.sh.travis-deps.sh

@@ -2,6 +2,11 @@ #!/bin/sh

if [ $TRAVIS_OS_NAME = "osx" ]; then brew update brew install qt5 ffmpeg imagemagick sdl2 libzip libpng + if [ "$CC" == "gcc" ]; then + brew install gcc@4.9 + export CC=gcc-4.9 + export CXX=g++-4.9 + fi else sudo apt-get clean sudo apt-get update
M .travis.yml.travis.yml

@@ -1,16 +1,19 @@

-os: - - linux - - osx - language: c -compiler: - - gcc - - clang - sudo: required -dist: trusty +matrix: + include: + - os: linux + dist: trusty + compiler: clang + - os: linux + dist: trusty + compiler: gcc + - os: osx + compiler: clang + - os: osx + compiler: gcc before_install: - - ./.travis-deps.sh + - source ./.travis-deps.sh script: mkdir build && cd build && cmake -DCMAKE_PREFIX_PATH=/usr/local/opt/qt5 .. && make
M CMakeLists.txtCMakeLists.txt

@@ -199,6 +199,7 @@ file(GLOB OS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/windows/*.c)

source_group("Windows-specific code" FILES ${OS_SRC}) if(MSVC) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) endif() elseif(UNIX) add_definitions(-DUSE_PTHREADS)

@@ -542,10 +543,12 @@ elseif(USE_ZLIB)

list(APPEND VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-zip.c ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/ioapi.c ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/unzip.c) - set_source_files_properties( - ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/ioapi.c - ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/unzip.c - PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter -Wno-implicit-function-declaration") + if(NOT MSVC) + set_source_files_properties( + ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/ioapi.c + ${CMAKE_CURRENT_SOURCE_DIR}/src/third-party/zlib/contrib/minizip/unzip.c + PROPERTIES COMPILE_FLAGS "-Wno-unused-parameter -Wno-implicit-function-declaration") + endif() endif() if (USE_LZMA)

@@ -610,7 +613,7 @@ endif()

if(M_CORE_GBA) add_definitions(-DM_CORE_GBA) - list(APPEND CORE_SRC + list(APPEND CORE_SRC ${ARM_SRC} ${GBA_SRC} ${GBA_CHEATS_SRC}

@@ -774,8 +777,11 @@ install(TARGETS ${BINARY_NAME}-openemu LIBRARY DESTINATION ${OE_LIBDIR} COMPONENT ${BINARY_NAME}.oecoreplugin NAMELINK_SKIP)

endif() if(BUILD_SDL) - add_definitions(-DBUILD_SDL) add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src/platform/sdl ${CMAKE_CURRENT_BINARY_DIR}/sdl) + # The SDL platform CMakeLists could decide to disable SDL, so check again before adding the define. + if(BUILD_SDL) + add_definitions(-DBUILD_SDL) + endif() endif() if(BUILD_QT)
M README.mdREADME.md

@@ -96,10 +96,10 @@ This will build and install mGBA into `/usr/bin` and `/usr/lib`. Dependencies that are installed will be automatically detected, and features that are disabled if the dependencies are not found will be shown after running the `cmake` command after warnings about being unable to find them.

#### 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 ("MinGW-w64 Win32 Shell") (or the 64-bit version "MinGW-w64 Win64 Shell" 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 500MiB of packages, so it will take a long time): -For x86 (32 bit) builds: - +For x86 (32 bit) builds: + pacman -Sy mingw-w64-i686-{cmake,ffmpeg,gcc,gdb,imagemagick,libzip,pkg-config,qt5,SDL2} For x86_64 (64 bit) builds:
M include/mgba-util/common.hinclude/mgba-util/common.h

@@ -46,6 +46,7 @@ #define ftruncate _chsize

#define snprintf _snprintf #define strdup _strdup #define lseek _lseek +#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR) #elif defined(__wii__) #include <sys/time.h> typedef intptr_t ssize_t;
M include/mgba-util/png-io.hinclude/mgba-util/png-io.h

@@ -12,6 +12,10 @@ CXX_GUARD_START

#ifdef USE_PNG +// png.h defines its own version of restrict which conflicts with mGBA's. +#ifdef restrict +#undef restrict +#endif #include <png.h> struct VFile;
M include/mgba/core/library.hinclude/mgba/core/library.h

@@ -39,6 +39,7 @@ void mLibraryLoadDirectory(struct mLibrary* library, const char* base);

size_t mLibraryCount(struct mLibrary* library, const struct mLibraryEntry* constraints); size_t mLibraryGetEntries(struct mLibrary* library, struct mLibraryListing* out, size_t numEntries, size_t offset, const struct mLibraryEntry* constraints); +void mLibraryEntryFree(struct mLibraryEntry* entry); struct VFile* mLibraryOpenVFile(struct mLibrary* library, const struct mLibraryEntry* entry); struct NoIntroDB;
M include/mgba/core/version.hinclude/mgba/core/version.h

@@ -6,6 +6,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef VERSION_H #define VERSION_H +#ifdef __cplusplus +extern "C" { +#endif + extern const char* const gitCommit; extern const char* const gitCommitShort; extern const char* const gitBranch;

@@ -13,5 +17,9 @@ extern const int gitRevision;

extern const char* const binaryName; extern const char* const projectName; extern const char* const projectVersion; + +#ifdef __cplusplus +} +#endif #endif
M res/shaders/wiiu.shader/wiiu.fsres/shaders/wiiu.shader/wiiu.fs

@@ -2,21 +2,28 @@ varying vec2 texCoord;

uniform sampler2D tex; uniform vec2 texSize; -const float scale[32] = float[]( - 0.0/255.0, 6.0/255.0, 12.0/255.0, 18.0/255.0, 24.0/255.0, 31.0/255.0, 37.0/255.0, 43.0/255.0, - 49.0/255.0, 55.0/255.0, 61.0/255.0, 67.0/255.0, 73.0/255.0, 79.0/255.0, 86.0/255.0, 92.0/255.0, - 98.0/255.0, 104.0/255.0, 111.0/255.0, 117.0/255.0, 123.0/255.0, 129.0/255.0, 135.0/255.0, 141.0/255.0, - 148.0/255.0, 154.0/255.0, 159.0/255.0, 166.0/255.0, 172.0/255.0, 178.0/255.0, 184.0/255.0, 191.0/255.0 -); - void main() { + float scale[32]; + scale[ 0] = 0.0/255.0; scale[ 1] = 6.0/255.0; + scale[ 2] = 12.0/255.0; scale[ 3] = 18.0/255.0; + scale[ 4] = 24.0/255.0; scale[ 5] = 31.0/255.0; + scale[ 6] = 37.0/255.0; scale[ 7] = 43.0/255.0; + scale[ 8] = 49.0/255.0; scale[ 9] = 55.0/255.0; + scale[10] = 61.0/255.0; scale[11] = 67.0/255.0; + scale[12] = 73.0/255.0; scale[13] = 79.0/255.0; + scale[14] = 86.0/255.0; scale[15] = 92.0/255.0; + scale[16] = 98.0/255.0; scale[17] = 104.0/255.0; + scale[18] = 111.0/255.0; scale[19] = 117.0/255.0; + scale[20] = 123.0/255.0; scale[21] = 129.0/255.0; + scale[22] = 135.0/255.0; scale[23] = 141.0/255.0; + scale[24] = 148.0/255.0; scale[25] = 154.0/255.0; + scale[26] = 159.0/255.0; scale[27] = 166.0/255.0; + scale[28] = 172.0/255.0; scale[29] = 178.0/255.0; + scale[30] = 184.0/255.0; scale[31] = 191.0/255.0; + vec4 color = texture2D(tex, texCoord); - color.rgb = round(color.rgb * 31.0); - color = vec4( - scale[int(color.r)], - scale[int(color.g)], - scale[int(color.b)], - 1.0 - ); + color.r = scale[int(floor(color.r * 31.0 + 0.5))]; + color.g = scale[int(floor(color.g * 31.0 + 0.5))]; + color.b = scale[int(floor(color.b * 31.0 + 0.5))]; gl_FragColor = color; -}+}
M src/core/core.csrc/core/core.c

@@ -158,7 +158,7 @@ vf->close(vf);

if (success) { mLOG(STATUS, INFO, "State %i loaded", slot); } else { - mLOG(STATUS, INFO, "State %i failed to loaded", slot); + mLOG(STATUS, INFO, "State %i failed to load", slot); } return success;
M src/core/library.csrc/core/library.c

@@ -392,6 +392,12 @@ }

return mLibraryListingSize(out); } +void mLibraryEntryFree(struct mLibraryEntry* entry) { + free((void*) entry->title); + free((void*) entry->filename); + free((void*) entry->base); +} + struct VFile* mLibraryOpenVFile(struct mLibrary* library, const struct mLibraryEntry* entry) { struct mLibraryListing entries; mLibraryListingInit(&entries, 0);
M src/gb/core.csrc/gb/core.c

@@ -283,7 +283,9 @@ break;

default: break; }; - bios = VFileOpen(configPath, O_RDONLY); + if (configPath) { + bios = VFileOpen(configPath, O_RDONLY); + } if (bios && GBIsBIOS(bios)) { found = true; } else if (bios) {
M src/gba/core.csrc/gba/core.c

@@ -311,7 +311,9 @@ }

} if (!found) { const char* configPath = mCoreConfigGetValue(&core->config, "gba.bios"); - bios = VFileOpen(configPath, O_RDONLY); + if (configPath) { + bios = VFileOpen(configPath, O_RDONLY); + } if (bios && GBAIsBIOS(bios)) { found = true; } else if (bios) {
M src/lr35902/debugger/cli-debugger.csrc/lr35902/debugger/cli-debugger.c

@@ -54,7 +54,7 @@ }

static inline uint16_t _printLine(struct CLIDebugger* debugger, uint16_t address, int segment) { struct CLIDebuggerBackend* be = debugger->backend; - struct LR35902InstructionInfo info = {}; + struct LR35902InstructionInfo info = {0}; char disassembly[48]; char* disPtr = disassembly; if (segment >= 0) {
M src/platform/qt/GameController.hsrc/platform/qt/GameController.h

@@ -14,6 +14,7 @@ #include <QString>

#include <QTimer> #include <memory> +#include <functional> #include <mgba/core/core.h> #include <mgba/core/thread.h>
M src/platform/qt/LibraryModel.cppsrc/platform/qt/LibraryModel.cpp

@@ -103,6 +103,7 @@ }

} else { m_library = new LibraryHandle(mLibraryCreateEmpty()); } + mLibraryListingInit(&m_listings, 0); memset(&m_constraints, 0, sizeof(m_constraints)); m_constraints.platform = PLATFORM_NONE; m_columns.append(s_columns["name"]);

@@ -116,6 +117,7 @@ }

LibraryModel::~LibraryModel() { clearConstraints(); + mLibraryListingDeinit(&m_listings); if (!m_library->deref()) { s_handles.remove(m_library->path); delete m_library;

@@ -128,14 +130,10 @@ QMetaObject::invokeMethod(m_library->loader, "loadDirectory", Q_ARG(const QString&, path));

} bool LibraryModel::entryAt(int row, mLibraryEntry* out) const { - mLibraryListing entries; - mLibraryListingInit(&entries, 0); - if (!mLibraryGetEntries(m_library->library, &entries, 1, row, &m_constraints)) { - mLibraryListingDeinit(&entries); + if (mLibraryListingSize(&m_listings) <= row) { return false; } - *out = *mLibraryListingGetPointer(&entries, 0); - mLibraryListingDeinit(&entries); + *out = *mLibraryListingGetConstPointer(&m_listings, row); return true; }

@@ -234,10 +232,12 @@ mLibraryAttachGameDB(m_library->library, gameDB);

} void LibraryModel::constrainBase(const QString& path) { + clearConstraints(); if (m_constraints.base) { free(const_cast<char*>(m_constraints.base)); } m_constraints.base = strdup(path.toUtf8().constData()); + reload(); } void LibraryModel::clearConstraints() {

@@ -251,6 +251,15 @@ if (m_constraints.title) {

free(const_cast<char*>(m_constraints.title)); } memset(&m_constraints, 0, sizeof(m_constraints)); + size_t i; + for (i = 0; i < mLibraryListingSize(&m_listings); ++i) { + mLibraryEntryFree(mLibraryListingGetPointer(&m_listings, i)); + } + mLibraryListingClear(&m_listings); +} + +void LibraryModel::reload() { + mLibraryGetEntries(m_library->library, &m_listings, 0, 0, m_constraints.base ? &m_constraints : nullptr); } void LibraryModel::directoryLoaded(const QString& path) {
M src/platform/qt/LibraryModel.hsrc/platform/qt/LibraryModel.h

@@ -52,6 +52,7 @@ void loadDirectory(const QString& path);

void constrainBase(const QString& path); void clearConstraints(); + void reload(); private slots: void directoryLoaded(const QString& path);

@@ -86,6 +87,7 @@ LibraryHandle* m_library;

static QMap<QString, LibraryHandle*> s_handles; mLibraryEntry m_constraints; + mLibraryListing m_listings; QStringList m_queue; QList<LibraryColumn> m_columns;
M src/platform/qt/LibraryView.cppsrc/platform/qt/LibraryView.cpp

@@ -24,6 +24,7 @@ connect(m_ui.listing, SIGNAL(activated(const QModelIndex&)), this, SIGNAL(accepted()));

m_ui.listing->horizontalHeader()->setSectionsMovable(true); m_ui.listing->setModel(&m_model); m_ui.listing->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents); + m_model.reload(); resizeColumns(); }
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -49,6 +49,10 @@ #ifdef M_CORE_GB

#include <mgba/internal/gb/gb.h> #include <mgba/internal/gb/video.h> #endif +#ifdef M_CORE_GBA +#include <mgba/internal/gba/gba.h> +#include <mgba/internal/gba/video.h> +#endif #include "feature/commandline.h" #include "feature/sqlite3/no-intro.h" #include <mgba-util/vfs.h>

@@ -104,7 +108,7 @@ m_savedScale = multiplier.toInt();

i = m_savedScale; } #ifdef USE_SQLITE3 - m_libraryView = new LibraryView(this); + m_libraryView = new LibraryView(); ConfigOption* showLibrary = m_config->addOption("showLibrary"); showLibrary->connect([this](const QVariant& value) { if (value.toBool()) {

@@ -209,6 +213,10 @@ #endif

#ifdef USE_MAGICK delete m_gifView; +#endif + +#ifdef USE_SQLITE3 + delete m_libraryView; #endif }
M src/platform/sdl/CMakeLists.txtsrc/platform/sdl/CMakeLists.txt

@@ -24,6 +24,8 @@ set(BUILD_SDL OFF PARENT_SCOPE)

return() endif() +add_definitions(-DBUILD_SDL) + find_feature(USE_PIXMAN "pixman-1") if(USE_PIXMAN) add_definitions(-DUSE_PIXMAN)
M src/util/vfs/vfs-fd.csrc/util/vfs/vfs-fd.c

@@ -53,7 +53,7 @@ return 0;

} struct stat stat; - if (fstat(fd, &stat) < 0 || S_ISDIR(stat.st_mode)) { + if (fstat(fd, &stat) < 0 || (stat.st_mode & S_IFDIR)) { close(fd); return 0; }