Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/gba/sio/lockstep.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define DRIVER_ID 0x6B636F4C
#define DRIVER_STATE_VERSION 1
#define LOCKSTEP_INTERVAL 4096
#define UNLOCKED_INTERVAL 4096
#define UNLOCKED_INTERVAL 8192
#define HARD_SYNC_INTERVAL 0x80000
#define TARGET(P) (1 << (P))
#define TARGET_ALL 0xF
Expand Down Expand Up @@ -586,7 +586,7 @@ static void GBASIOLockstepDriverFinishMultiplayer(struct GBASIODriver* driver, u
mLOG(GBA_SIO, WARN, "MULTI did not receive data. Are we running behind?");
memset(data, 0xFF, sizeof(uint16_t) * 4);
} else {
mLOG(GBA_SIO, INFO, "MULTI transfer finished: %04X %04X %04X %04X",
mLOG(GBA_SIO, DEBUG, "MULTI transfer finished: %04X %04X %04X %04X",
coordinator->multiData[0],
coordinator->multiData[1],
coordinator->multiData[2],
Expand All @@ -613,7 +613,7 @@ static uint8_t GBASIOLockstepDriverFinishNormal8(struct GBASIODriver* driver) {
mLOG(GBA_SIO, WARN, "NORMAL did not receive data. Are we running behind?");
} else {
data = coordinator->normalData[player->playerId - 1];
mLOG(GBA_SIO, INFO, "NORMAL8 transfer finished: %02X", data);
mLOG(GBA_SIO, DEBUG, "NORMAL8 transfer finished: %02X", data);
}
}
player->dataReceived = false;
Expand All @@ -637,7 +637,7 @@ static uint32_t GBASIOLockstepDriverFinishNormal32(struct GBASIODriver* driver)
mLOG(GBA_SIO, WARN, "Did not receive data. Are we running behind?");
} else {
data = coordinator->normalData[player->playerId - 1];
mLOG(GBA_SIO, INFO, "NORMAL32 transfer finished: %08X", data);
mLOG(GBA_SIO, DEBUG, "NORMAL32 transfer finished: %08X", data);
}
}
player->dataReceived = false;
Expand Down Expand Up @@ -840,7 +840,7 @@ static void _setData(struct GBASIOLockstepCoordinator* coordinator, uint32_t id,
case GBA_SIO_UART:
case GBA_SIO_GPIO:
case GBA_SIO_JOYBUS:
mLOG(GBA_SIO, ERROR, "Unsupported mode %i in lockstep", coordinator->transferMode);
mLOG(GBA_SIO, WARN, "Unsupported mode %i in lockstep", coordinator->transferMode);
// TODO: Should we handle this or just abort?
break;
}
Expand Down Expand Up @@ -923,11 +923,8 @@ void _lockstepEvent(struct mTiming* timing, void* context, uint32_t cyclesLate)
if (!coordinator->transferActive) {
GBASIOLockstepCoordinatorWakePlayers(coordinator);
}
if (coordinator->nextHardSync < 0) {
if (!coordinator->waiting) {
_hardSync(coordinator, player);
}
coordinator->nextHardSync += HARD_SYNC_INTERVAL;
if (coordinator->nextHardSync < 0 && !coordinator->waiting) {
_hardSync(coordinator, player);
}
}

Expand Down Expand Up @@ -1075,6 +1072,7 @@ void GBASIOLockstepCoordinatorAckPlayer(struct GBASIOLockstepCoordinator* coordi
coordinator->transferActive = false;
}

coordinator->nextHardSync = HARD_SYNC_INTERVAL;
struct GBASIOLockstepPlayer* runner = TableLookup(&coordinator->players, coordinator->attachedPlayers[0]);
GBASIOLockstepPlayerWake(runner);
}
Expand Down