Fixed the crash that would occur if a GBA link mode were used with a GB game.

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@1243 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
skidau 2015-03-23 13:35:01 +00:00
parent b03200a15f
commit a483633c96
3 changed files with 22 additions and 8 deletions

View File

@ -806,7 +806,7 @@ void gbWriteMemory(register u16 address, register u8 value)
} }
EmuReseted = false; EmuReseted = false;
gbMemory[0xff02] = value; gbMemory[0xff02] = value;
if (gbSerialOn) { if (gbSerialOn && GetLinkMode() == LINK_GAMEBOY) {
gbSerialTicks = GBSERIAL_CLOCK_TICKS; gbSerialTicks = GBSERIAL_CLOCK_TICKS;
LinkIsWaiting = true; LinkIsWaiting = true;
@ -2199,8 +2199,10 @@ void gbGetHardwareType()
void gbReset() void gbReset()
{ {
#ifndef NO_LINK #ifndef NO_LINK
if (GetLinkMode() == LINK_GAMEBOY) {
EmuReseted = true; EmuReseted = true;
gbLinkReset(); gbLinkReset();
}
#endif #endif
gbGetHardwareType(); gbGetHardwareType();
@ -5237,7 +5239,8 @@ void gbEmulate(int ticksToStop)
static int SIOctr = 0; static int SIOctr = 0;
SIOctr++; SIOctr++;
if (SIOctr % 5) if (SIOctr % 5)
if (gbSerialOn) { //Transfer Started //Transfer Started
if (gbSerialOn && GetLinkMode() == LINK_GAMEBOY) {
#ifdef OLD_GB_LINK #ifdef OLD_GB_LINK
if (linkConnected) { if (linkConnected) {
gbSerialTicks -= clockTicks; gbSerialTicks -= clockTicks;

View File

@ -300,7 +300,6 @@ typedef struct {
int type; int type;
bool server; bool server;
bool speed; //speedhack bool speed; //speedhack
bool active; //network/single computer
} LANLINKDATA; } LANLINKDATA;
class lserver{ class lserver{
@ -1882,7 +1881,7 @@ bool LinkRFUUpdate()
{ {
//if (IsLinkConnected()) { //if (IsLinkConnected()) {
//} //}
if (!lanlink.active || rfu_enabled) { if (rfu_enabled) {
if (transfer&&rfu_transfer_end <= 0) if (transfer&&rfu_transfer_end <= 0)
{ {
if (rfu_waiting) { if (rfu_waiting) {
@ -2231,6 +2230,9 @@ static ConnectionState InitSocket() {
ConnectionState InitLink(LinkMode mode) ConnectionState InitLink(LinkMode mode)
{ {
if (mode == LINK_DISCONNECTED)
return LINK_ABORT;
// Do nothing if we are already connected // Do nothing if we are already connected
if (GetLinkMode() != LINK_DISCONNECTED) { if (GetLinkMode() != LINK_DISCONNECTED) {
systemMessage(0, N_("Error, link already connected")); systemMessage(0, N_("Error, link already connected"));
@ -2720,7 +2722,7 @@ u8 gbStartLink(u8 b) //used on internal clock
if (!gba_link_enabled) return 0xff; if (!gba_link_enabled) return 0xff;
//Single Computer //Single Computer
if (!lanlink.active) if (GetLinkMode() == LINK_GAMEBOY)
{ {
u32 tm = GetTickCount(); u32 tm = GetTickCount();
do { do {
@ -2764,7 +2766,7 @@ u16 gbLinkUpdate(u8 b, int gbSerialOn) //used on external clock
if (gbSerialOn) { if (gbSerialOn) {
if (gba_link_enabled) if (gba_link_enabled)
//Single Computer //Single Computer
if (!lanlink.active) if (GetLinkMode() == LINK_GAMEBOY)
{ {
u32 tm;// = GetTickCount(); u32 tm;// = GetTickCount();
//do { //do {

View File

@ -133,6 +133,15 @@ void LinkOptions::OnOk()
SetLinkTimeout(timeout); SetLinkTimeout(timeout);
LinkMode newMode = (LinkMode) m_type; LinkMode newMode = (LinkMode) m_type;
if (newMode == LINK_DISCONNECTED) {
theApp.linkTimeout = timeout;
theApp.linkMode = LINK_DISCONNECTED;
theApp.linkHost = host;
CDialog::OnOK();
return;
}
bool needsServerHost = newMode == LINK_GAMECUBE_DOLPHIN || (newMode == LINK_CABLE_SOCKET && !m_server); bool needsServerHost = newMode == LINK_GAMECUBE_DOLPHIN || (newMode == LINK_CABLE_SOCKET && !m_server);
if (needsServerHost) { if (needsServerHost) {