From 401bc9e9d632869c25072694b3c491f86e93ba8c Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 16 Aug 2015 17:19:05 -0700 Subject: [PATCH] GBA SIO: Fix reseting when there are SIO devices attached --- CHANGES | 1 + src/gba/gba.c | 3 +-- src/gba/sio.c | 15 ++++++++++----- src/gba/sio.h | 1 + 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index a6d461e3b..e913a37fe 100644 --- a/CHANGES +++ b/CHANGES @@ -74,6 +74,7 @@ Bugfixes: - GBA: Ensure cycles never go negative - Util: Fix formatting of floats - Debugger: Fix use-after-free in breakpoint clearing code + - GBA SIO: Fix reseting when there are SIO devices attached Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints diff --git a/src/gba/gba.c b/src/gba/gba.c index a7356ad3a..2ae273760 100644 --- a/src/gba/gba.c +++ b/src/gba/gba.c @@ -163,8 +163,7 @@ void GBAReset(struct ARMCore* cpu) { GBAAudioReset(&gba->audio); GBAIOInit(gba); - GBASIODeinit(&gba->sio); - GBASIOInit(&gba->sio); + GBASIOReset(&gba->sio); gba->timersEnabled = 0; memset(gba->timers, 0, sizeof(gba->timers)); diff --git a/src/gba/sio.c b/src/gba/sio.c index 49f66ff58..2e4251c9c 100644 --- a/src/gba/sio.c +++ b/src/gba/sio.c @@ -48,14 +48,10 @@ static void _switchMode(struct GBASIO* sio) { } void GBASIOInit(struct GBASIO* sio) { - sio->rcnt = RCNT_INITIAL; - sio->siocnt = 0; - sio->mode = -1; - sio->activeDriver = 0; sio->drivers.normal = 0; sio->drivers.multiplayer = 0; sio->drivers.joybus = 0; - _switchMode(sio); + GBASIOReset(sio); } void GBASIODeinit(struct GBASIO* sio) { @@ -70,6 +66,15 @@ void GBASIODeinit(struct GBASIO* sio) { } } +void GBASIOReset(struct GBASIO* sio) { + GBASIODeinit(sio); + sio->rcnt = RCNT_INITIAL; + sio->siocnt = 0; + sio->mode = -1; + sio->activeDriver = 0; + _switchMode(sio); +} + void GBASIOSetDriverSet(struct GBASIO* sio, struct GBASIODriverSet* drivers) { GBASIOSetDriver(sio, drivers->normal, SIO_NORMAL_8); GBASIOSetDriver(sio, drivers->multiplayer, SIO_MULTI); diff --git a/src/gba/sio.h b/src/gba/sio.h index 5963698d9..2707fb0e8 100644 --- a/src/gba/sio.h +++ b/src/gba/sio.h @@ -65,6 +65,7 @@ struct GBASIO { void GBASIOInit(struct GBASIO* sio); void GBASIODeinit(struct GBASIO* sio); +void GBASIOReset(struct GBASIO* sio); void GBASIOSetDriverSet(struct GBASIO* sio, struct GBASIODriverSet* drivers); void GBASIOSetDriver(struct GBASIO* sio, struct GBASIODriver* driver, enum GBASIOMode mode);