Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Sérgio Benjamim 2018-07-08 13:59:50 -03:00
commit abf712f061
16 changed files with 100 additions and 40 deletions

View File

@ -2,19 +2,4 @@
if [ $TRAVIS_OS_NAME = "osx" ]; then
brew update
brew install qt5 ffmpeg imagemagick sdl2 libedit libelf libpng libzip
else
sudo apt-get clean
sudo add-apt-repository -y ppa:beineri/opt-qt542-trusty
sudo add-apt-repository -y ppa:george-edison55/cmake-3.x
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install -y -q cmake libedit-dev libelf-dev libmagickwand-dev \
libpng-dev libsdl2-dev libzip-dev qt54base qt54multimedia \
libavcodec-dev libavutil-dev libavformat-dev libavresample-dev \
libswscale-dev
if [ "$CC" == "gcc" ]; then
sudo apt-get install -y -q gcc-5 g++-5
export CC=gcc-5
export CXX=g++-5
fi
fi

View File

@ -1,14 +1,30 @@
if: type = pull_request OR NOT branch =~ /^(master$|optimization)/ OR fork
language: c
sudo: required
services:
- docker
os: linux
env:
- DOCKER_TAG=ubuntu:xenial
- DOCKER_TAG=ubuntu:artful
- DOCKER_TAG=ubuntu:bionic
- DOCKER_TAG=3ds
- DOCKER_TAG=wii
- DOCKER_TAG=vita
- DOCKER_TAG=windows:w32
- DOCKER_TAG=windows:w64
matrix:
include:
- os: linux
dist: trusty
compiler: gcc
- os: osx
compiler: clang
- os: osx
compiler: clang
env: DOCKER_TAG=
before_install:
- source ./.travis-deps.sh
- '[ -z "$DOCKER_TAG" ] || docker pull mgba/$DOCKER_TAG'
- '[ "$TRAVIS_OS_NAME" != "osx" ] || . ./.travis-deps.sh'
- 'mkdir build && chmod 777 build'
script: mkdir build && cd build && cmake -DCMAKE_PREFIX_PATH='/usr/local/opt/qt5;/opt/qt54' .. && make -j2
script:
- '[ -z "$DOCKER_TAG" ] || docker run -e BUILD_DIR=build -e MAKEFLAGS=-j2 -v $PWD:/home/mgba/src mgba/$DOCKER_TAG'
- '[ "$TRAVIS_OS_NAME" != "osx" ] || (cd build && cmake -DCMAKE_PREFIX_PATH="/usr/local/opt/qt5" .. && make -j2)'

View File

@ -66,6 +66,7 @@ Misc:
- GB Audio: Improved audio quality
- GB, GBA Audio: Increase max audio volume
- GB: Fix VRAM/palette locking (fixes mgba.io/i/1109)
- GB Video: Darken colors in GBA mode
0.6.3: (2017-04-14)
Bugfixes:

View File

@ -311,11 +311,13 @@ if(DEFINED 3DS)
endif()
include(CheckFunctionExists)
include(CheckIncludeFiles)
check_function_exists(strdup HAVE_STRDUP)
check_function_exists(strndup HAVE_STRNDUP)
if(NOT DEFINED PSP2)
check_function_exists(localtime_r HAVE_LOCALTIME_R)
endif()
check_include_files("xlocale.h" HAVE_XLOCALE)
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Generic")
check_function_exists(snprintf_l HAVE_SNPRINTF_L)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
@ -373,9 +375,6 @@ endif()
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)
endif()
if (HAVE_SNPRINTF_L)
list(APPEND FUNCTION_DEFINES HAVE_SNPRINTF_L)
endif()
@ -385,6 +384,14 @@ if(HAVE_SETLOCALE)
list(APPEND FUNCTION_DEFINES HAVE_SETLOCALE)
endif()
if (HAVE_STRTOF_L)
list(APPEND FUNCTION_DEFINES HAVE_STRTOF_L)
endif()
if(HAVE_XLOCALE)
list(APPEND FUNCTION_DEFINES HAVE_XLOCALE)
endif()
if(HAVE_CHMOD)
list(APPEND FUNCTION_DEFINES HAVE_CHMOD)
endif()

View File

@ -12,8 +12,8 @@ CXX_GUARD_START
#include "locale.h"
#if defined(__APPLE__) || defined(__FreeBSD__)
#include "xlocale.h"
#ifdef HAVE_XLOCALE
#include <xlocale.h>
#elif !defined(HAVE_LOCALE)
typedef const char* locale_t;
#endif

View File

@ -271,6 +271,9 @@ static THREAD_ENTRY _mCoreThreadRun(void* context) {
}
core->clearCoreCallbacks(core);
if (threadContext->logger.d.filter == &filter) {
mLogFilterDeinit(&filter);
}
threadContext->logger.d.filter = NULL;
return 0;

View File

@ -682,6 +682,18 @@ void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext* contex
if (context->initialState) {
mappedMemoryFree(context->initialState, context->initialStateSize);
}
size_t i;
for (i = 0; i < context->nChannels; ++i) {
CircleBufferDeinit(&context->channels[i].buffer);
#ifdef USE_ZLIB
if (context->channels[i].inflating) {
inflateEnd(&context->channels[i].inflateStream);
context->channels[i].inflating = false;
}
#endif
}
free(context);
}

View File

@ -437,10 +437,29 @@ static void GBVideoSoftwareRendererWritePalette(struct GBVideoRenderer* renderer
color = softwareRenderer->palette[0];
}
}
softwareRenderer->palette[index] = color;
if (renderer->cache) {
mCacheSetWritePalette(renderer->cache, index, color);
}
if (softwareRenderer->model == GB_MODEL_AGB) {
unsigned r = M_R5(value);
unsigned g = M_G5(value);
unsigned b = M_B5(value);
r = r * r;
g = g * g;
b = b * b;
#ifdef COLOR_16_BIT
r /= 31;
g /= 31;
b /= 31;
color = mColorFrom555(r | (g << 5) | (b << 10));
#else
r >>= 2;
g >>= 2;
b >>= 2;
color = r | (g << 8) | (b << 16);
#endif
}
softwareRenderer->palette[index] = color;
if (softwareRenderer->model == GB_MODEL_SGB && !index && GBRegisterLCDCIsEnable(softwareRenderer->lcdc)) {
renderer->writePalette(renderer, 0x04, value);

View File

@ -251,7 +251,7 @@ static void _MidiKey2Freq(struct GBA* gba) {
uint32_t key = cpu->memory.load32(cpu, cpu->gprs[0] + 4, 0);
gba->memory.activeRegion = oldRegion;
cpu->gprs[0] = key / powf(2, (180.f - cpu->gprs[1] - cpu->gprs[2] / 256.f) / 12.f);
cpu->gprs[0] = key / exp2f((180.f - cpu->gprs[1] - cpu->gprs[2] / 256.f) / 12.f);
}
static void _Div(struct GBA* gba, int32_t num, int32_t denom) {

View File

@ -398,6 +398,7 @@ bool GBALoadROM(struct GBA* gba, struct VFile* vf) {
gba->memory.rom = newRom;
#endif
gba->memory.romSize = SIZE_CART0;
gba->memory.romMask = SIZE_CART0 - 1;
gba->isPristine = false;
}
if (gba->cpu && gba->memory.activeRegion >= REGION_CART0) {

View File

@ -29,8 +29,11 @@ using namespace QGBA;
DisplayGL::DisplayGL(const QGLFormat& format, QWidget* parent)
: Display(parent)
, m_gl(new EmptyGLWidget(format, this))
, m_gl(nullptr)
{
// This can spontaneously re-enter into this->resizeEvent before creation is done, so we
// need to make sure it's initialized to nullptr before we assign the new object to it
m_gl = new EmptyGLWidget(format, this);
m_painter = new PainterGL(format.majorVersion() < 2 ? 1 : m_gl->format().majorVersion(), m_gl);
m_gl->setMouseTracking(true);
m_gl->setAttribute(Qt::WA_TransparentForMouseEvents); // This doesn't seem to work?
@ -162,7 +165,9 @@ void DisplayGL::resizeEvent(QResizeEvent* event) {
}
void DisplayGL::resizePainter() {
m_gl->resize(size());
if (m_gl) {
m_gl->resize(size());
}
if (m_drawThread) {
QMetaObject::invokeMethod(m_painter, "resize", Qt::BlockingQueuedConnection, Q_ARG(QSize, size()));
}
@ -180,7 +185,7 @@ PainterGL::PainterGL(int majorVersion, QGLWidget* parent)
#if !defined(_WIN32) || defined(USE_EPOXY)
if (majorVersion >= 2) {
gl2Backend = new mGLES2Context;
gl2Backend = static_cast<mGLES2Context*>(malloc(sizeof(mGLES2Context)));
mGLES2ContextCreate(gl2Backend);
m_backend = &gl2Backend->d;
m_supportsShaders = true;
@ -189,7 +194,7 @@ PainterGL::PainterGL(int majorVersion, QGLWidget* parent)
#ifdef BUILD_GL
if (!m_backend) {
glBackend = new mGLContext;
glBackend = static_cast<mGLContext*>(malloc(sizeof(mGLContext)));
mGLContextCreate(glBackend);
m_backend = &glBackend->d;
m_supportsShaders = false;
@ -239,7 +244,7 @@ PainterGL::~PainterGL() {
#endif
m_backend->deinit(m_backend);
m_gl->doneCurrent();
delete m_backend;
free(m_backend);
m_backend = nullptr;
}

View File

@ -25,6 +25,10 @@ LogController::LogController(int levels, QObject* parent)
}
}
LogController::~LogController() {
mLogFilterDeinit(&m_filter);
}
LogController::Stream LogController::operator()(int category, int level) {
return Stream(this, category, level);
}

View File

@ -35,6 +35,7 @@ private:
public:
LogController(int levels, QObject* parent = nullptr);
~LogController();
int levels() const { return m_filter.defaultLevels; }
mLogFilter* filter() { return &m_filter; }

View File

@ -45,10 +45,10 @@ LibraryController::LibraryController(QWidget* parent, const QString& path, Confi
mLibraryAttachGameDB(m_library.get(), GBAApp::app()->gameDB());
m_libraryTree = new LibraryTree(this);
m_libraryTree = std::make_unique<LibraryTree>(this);
addWidget(m_libraryTree->widget());
m_libraryGrid = new LibraryGrid(this);
m_libraryGrid = std::make_unique<LibraryGrid>(this);
addWidget(m_libraryGrid->widget());
setViewStyle(LibraryStyle::STYLE_LIST);
@ -67,9 +67,9 @@ void LibraryController::setViewStyle(LibraryStyle newStyle) {
AbstractGameList* newCurrentList = nullptr;
if (newStyle == LibraryStyle::STYLE_LIST || newStyle == LibraryStyle::STYLE_TREE) {
newCurrentList = m_libraryTree;
newCurrentList = m_libraryTree.get();
} else {
newCurrentList = m_libraryGrid;
newCurrentList = m_libraryGrid.get();
}
newCurrentList->selectEntry(selectedEntry());
newCurrentList->setViewStyle(newStyle);

View File

@ -107,8 +107,8 @@ private:
LibraryStyle m_currentStyle;
AbstractGameList* m_currentList = nullptr;
LibraryGrid* m_libraryGrid = nullptr;
LibraryTree* m_libraryTree = nullptr;
std::unique_ptr<LibraryGrid> m_libraryGrid;
std::unique_ptr<LibraryTree> m_libraryTree;
};
}

View File

@ -62,6 +62,12 @@ LibraryTree::LibraryTree(LibraryController* parent)
});
}
LibraryTree::~LibraryTree() {
for (QTreeWidgetItem* i : m_items.values()) {
delete i;
}
}
void LibraryTree::resizeAllCols() {
for (int i = 0; i < m_widget->columnCount(); i++) {
m_widget->resizeColumnToContents(i);