Merge branch 'master' into medusa

This commit is contained in:
Vicki Pfau 2017-04-25 11:59:48 -07:00
commit 6265ff20bd
6 changed files with 34 additions and 15 deletions

View File

@ -83,6 +83,10 @@ Bugfixes:
- GBA Video: Don't update background scanline params in mode 0 (fixes mgba.io/i/377) - GBA Video: Don't update background scanline params in mode 0 (fixes mgba.io/i/377)
- Qt: Ensure CLI backend is attached when submitting commands (fixes mgba.io/i/662) - Qt: Ensure CLI backend is attached when submitting commands (fixes mgba.io/i/662)
- Core: Fix crash with rewind if savestates shrink - Core: Fix crash with rewind if savestates shrink
- Test: Fix crash when loading invalid file
- GBA Hardware: Fix crash if a savestate lies about game hardware
- Test: Fix crash when fuzzing fails to load a file
- GBA: Fix multiboot loading resulting in too small WRAM
Misc: Misc:
- SDL: Remove scancode key input - SDL: Remove scancode key input
- GBA Video: Clean up unused timers - GBA Video: Clean up unused timers

View File

@ -76,6 +76,8 @@ static void GBAInit(void* cpu, struct mCPUComponent* component) {
gba->sio.p = gba; gba->sio.p = gba;
GBASIOInit(&gba->sio); GBASIOInit(&gba->sio);
GBAHardwareInit(&gba->memory.hw, NULL);
gba->springIRQ = 0; gba->springIRQ = 0;
gba->keySource = 0; gba->keySource = 0;
gba->rotationSource = 0; gba->rotationSource = 0;
@ -295,14 +297,9 @@ bool GBALoadMB(struct GBA* gba, struct VFile* vf) {
gba->pristineRomSize = SIZE_WORKING_RAM; gba->pristineRomSize = SIZE_WORKING_RAM;
} }
gba->isPristine = true; gba->isPristine = true;
#ifdef _3DS gba->memory.wram = anonymousMemoryMap(SIZE_WORKING_RAM);
if (gba->pristineRomSize <= romBufferSize) { memset(gba->memory.wram, 0, SIZE_WORKING_RAM);
gba->memory.wram = romBuffer; vf->read(vf, gba->memory.wram, gba->pristineRomSize);
vf->read(vf, romBuffer, gba->pristineRomSize);
}
#else
gba->memory.wram = vf->map(vf, gba->pristineRomSize, MAP_READ);
#endif
if (!gba->memory.wram) { if (!gba->memory.wram) {
mLOG(GBA, WARN, "Couldn't map ROM"); mLOG(GBA, WARN, "Couldn't map ROM");
return false; return false;

View File

@ -73,6 +73,9 @@ void GBAHardwareClear(struct GBACartridgeHardware* hw) {
} }
void GBAHardwareGPIOWrite(struct GBACartridgeHardware* hw, uint32_t address, uint16_t value) { void GBAHardwareGPIOWrite(struct GBACartridgeHardware* hw, uint32_t address, uint16_t value) {
if (!hw->gpioBase) {
return;
}
switch (address) { switch (address) {
case GPIO_REG_DATA: case GPIO_REG_DATA:
hw->pinState &= ~hw->direction; hw->pinState &= ~hw->direction;

View File

@ -80,10 +80,11 @@ const char* DebuggerConsoleController::readLine(struct CLIDebuggerBackend* be, s
while (self->m_lines.isEmpty()) { while (self->m_lines.isEmpty()) {
self->m_cond.wait(&self->m_mutex); self->m_cond.wait(&self->m_mutex);
} }
self->m_last = self->m_lines.takeFirst().toUtf8(); QString last = self->m_lines.takeFirst();
if (self->m_last.isEmpty()) { if (last.isNull()) {
self->m_last = "\n"; return nullptr;
} }
self->m_last = last.toUtf8();
*len = self->m_last.size(); *len = self->m_last.size();
return self->m_last.constData(); return self->m_last.constData();
@ -101,7 +102,7 @@ const char* DebuggerConsoleController::historyLast(struct CLIDebuggerBackend* be
GameController::Interrupter interrupter(self->m_gameController, true); GameController::Interrupter interrupter(self->m_gameController, true);
QMutexLocker lock(&self->m_mutex); QMutexLocker lock(&self->m_mutex);
if (self->m_history.isEmpty()) { if (self->m_history.isEmpty()) {
return "\n"; return "i";
} }
self->m_last = self->m_history.last().toUtf8(); self->m_last = self->m_history.last().toUtf8();
return self->m_last.constData(); return self->m_last.constData();

View File

@ -158,6 +158,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent)
#endif #endif
m_screenWidget->setPixmap(m_logo); m_screenWidget->setPixmap(m_logo);
m_screenWidget->setCenteredAspectRatio(m_logo.width(), m_logo.height()); m_screenWidget->setCenteredAspectRatio(m_logo.width(), m_logo.height());
m_screenWidget->setLockIntegerScaling(false);
setCentralWidget(m_screenWidget); setCentralWidget(m_screenWidget);
connect(m_controller, SIGNAL(gameStarted(mCoreThread*, const QString&)), this, SLOT(gameStarted(mCoreThread*, const QString&))); connect(m_controller, SIGNAL(gameStarted(mCoreThread*, const QString&)), this, SLOT(gameStarted(mCoreThread*, const QString&)));
@ -795,6 +796,7 @@ void Window::gameStarted(mCoreThread* context, const QString& fname) {
context->core->desiredVideoDimensions(context->core, &width, &height); context->core->desiredVideoDimensions(context->core, &width, &height);
m_display->setMinimumSize(width, height); m_display->setMinimumSize(width, height);
m_screenWidget->setMinimumSize(m_display->minimumSize()); m_screenWidget->setMinimumSize(m_display->minimumSize());
m_config->updateOption("lockIntegerScaling");
if (m_savedScale > 0) { if (m_savedScale > 0) {
resizeFrame(QSize(width, height) * m_savedScale); resizeFrame(QSize(width, height) * m_savedScale);
} }
@ -858,6 +860,7 @@ void Window::gameStopped() {
updateTitle(); updateTitle();
detachWidget(m_display); detachWidget(m_display);
m_screenWidget->setCenteredAspectRatio(m_logo.width(), m_logo.height()); m_screenWidget->setCenteredAspectRatio(m_logo.width(), m_logo.height());
m_screenWidget->setLockIntegerScaling(false);
m_screenWidget->setPixmap(m_logo); m_screenWidget->setPixmap(m_logo);
m_screenWidget->unsetCursor(); m_screenWidget->unsetCursor();
#ifdef M_CORE_GB #ifdef M_CORE_GB
@ -1342,7 +1345,9 @@ void Window::setupMenu(QMenuBar* menubar) {
lockIntegerScaling->addBoolean(tr("Force integer scaling"), avMenu); lockIntegerScaling->addBoolean(tr("Force integer scaling"), avMenu);
lockIntegerScaling->connect([this](const QVariant& value) { lockIntegerScaling->connect([this](const QVariant& value) {
m_display->lockIntegerScaling(value.toBool()); m_display->lockIntegerScaling(value.toBool());
m_screenWidget->setLockIntegerScaling(value.toBool()); if (m_controller->isLoaded()) {
m_screenWidget->setLockIntegerScaling(value.toBool());
}
}, this); }, this);
m_config->updateOption("lockIntegerScaling"); m_config->updateOption("lockIntegerScaling");

View File

@ -68,6 +68,9 @@ int main(int argc, char** argv) {
return 0; return 0;
} }
struct mCore* core = mCoreFind(args.fname); struct mCore* core = mCoreFind(args.fname);
if (!core) {
return 1;
}
core->init(core); core->init(core);
mCoreInitConfig(core, "fuzz"); mCoreInitConfig(core, "fuzz");
applyArguments(&args, NULL, &core->config); applyArguments(&args, NULL, &core->config);
@ -91,10 +94,15 @@ int main(int argc, char** argv) {
#ifdef __AFL_HAVE_MANUAL_CONTROL #ifdef __AFL_HAVE_MANUAL_CONTROL
__AFL_INIT(); __AFL_INIT();
#endif #endif
bool cleanExit = true;
if (!mCoreLoadFile(core, args.fname)) {
cleanExit = false;
goto loadError;
}
if (args.patch) { if (args.patch) {
core->loadPatch(core, VFileOpen(args.patch, O_RDONLY)); core->loadPatch(core, VFileOpen(args.patch, O_RDONLY));
} }
mCoreLoadFile(core, args.fname);
struct VFile* savestate = 0; struct VFile* savestate = 0;
struct VFile* savestateOverlay = 0; struct VFile* savestateOverlay = 0;
@ -155,13 +163,14 @@ int main(int argc, char** argv) {
savestateOverlay->close(savestateOverlay); savestateOverlay->close(savestateOverlay);
} }
loadError:
freeArguments(&args); freeArguments(&args);
if (outputBuffer) { if (outputBuffer) {
free(outputBuffer); free(outputBuffer);
} }
core->deinit(core); core->deinit(core);
return 0; return !cleanExit;
} }
static void _fuzzRunloop(struct mCore* core, int frames) { static void _fuzzRunloop(struct mCore* core, int frames) {