diff --git a/src/win32/JoybusOptions.cpp b/src/win32/JoybusOptions.cpp index fe3e1c76..f78be118 100644 --- a/src/win32/JoybusOptions.cpp +++ b/src/win32/JoybusOptions.cpp @@ -34,7 +34,7 @@ BOOL JoybusOptions::OnInitDialog() { CDialog::OnInitDialog(); - enable_check.SetCheck(gba_joybus_enabled ? BST_CHECKED : BST_UNCHECKED); + enable_check.SetCheck(GetLinkMode() == LINK_GAMECUBE_DOLPHIN ? BST_CHECKED : BST_UNCHECKED); hostname.EnableWindow(enable_check.GetCheck() == BST_CHECKED); @@ -57,8 +57,6 @@ void JoybusOptions::OnBnClickedOk() return; } - gba_joybus_enabled = enable_check.GetCheck() == BST_CHECKED; - CString address; hostname.GetWindowText(address); @@ -72,7 +70,12 @@ void JoybusOptions::OnBnClickedOk() } joybusHostAddr = new_server; - JoyBusConnect(); + + if (enable_check.GetCheck() == BST_CHECKED) + { + CloseLink(); + InitLink(LINK_GAMECUBE_DOLPHIN); + } OnOK(); } diff --git a/src/win32/LinkOptions.cpp b/src/win32/LinkOptions.cpp index dd04a08e..52543f48 100644 --- a/src/win32/LinkOptions.cpp +++ b/src/win32/LinkOptions.cpp @@ -113,7 +113,7 @@ void LinkGeneral::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(LinkGeneral) - DDX_Radio(pDX, IDC_LINK_SINGLE, m_type); + DDX_Radio(pDX, IDC_LINK_DISCONNECTED, m_type); DDX_Control(pDX, IDC_LINKTIMEOUT, m_timeout); //}}AFX_DATA_MAP } @@ -124,6 +124,9 @@ BEGIN_MESSAGE_MAP(LinkGeneral, CDialog) ON_BN_CLICKED(IDC_LINK_SINGLE, OnRadio1) ON_BN_CLICKED(IDC_LINK_LAN, OnRadio2) //}}AFX_MSG_MAP + ON_BN_CLICKED(IDC_LINK_DISCONNECTED, &LinkGeneral::OnBnClickedLinkDisconnected) + ON_BN_CLICKED(IDC_LINK_RFU, &LinkGeneral::OnBnClickedLinkRfu) + ON_BN_CLICKED(IDC_LINK_GAMECUBE, &LinkGeneral::OnBnClickedLinkGamecube) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// @@ -234,7 +237,9 @@ BOOL CMyTabCtrl::SubclassDlgItem(UINT nID, CWnd* pParent) BOOL CMyTabCtrl::IsTabEnabled(int iTab) { - if (!lanlink.active && iTab > 0) + LinkGeneral *general = (LinkGeneral*)m_tabdialog[0]; + + if (general->m_type != LINK_CABLE_SOCKET && iTab > 0) return false; return true; } @@ -426,6 +431,7 @@ void CMyTabCtrl::OnSwitchTabs(void) { CRect clientRect, wndRect; int i; + LinkGeneral *general = (LinkGeneral*)m_tabdialog[0]; GetClientRect(clientRect); AdjustRect(FALSE, clientRect); @@ -433,7 +439,9 @@ void CMyTabCtrl::OnSwitchTabs(void) GetParent()->ScreenToClient(wndRect); clientRect.OffsetRect(wndRect.left, wndRect.top); - if(lanlink.active==0) + + + if (general->m_type != LINK_CABLE_SOCKET) SetCurSel(0); for(i=0;i<3;i++){ @@ -456,15 +464,13 @@ void LinkOptions::OnOk() void LinkGeneral::OnRadio1() { - m_type = 0; - lanlink.active = 0; + m_type = LINK_CABLE_IPC; GetParent()->Invalidate(); } void LinkGeneral::OnRadio2() { - m_type = 1; - lanlink.active = 1; + m_type = LINK_CABLE_SOCKET; GetParent()->Invalidate(); } @@ -474,12 +480,12 @@ BOOL LinkGeneral::OnInitDialog(){ CDialog::OnInitDialog(); + m_type = GetLinkMode(); + m_timeout.LimitText(5); sprintf(timeout, "%d", linktimeout); m_timeout.SetWindowText(timeout); - m_type = lanlink.active; - UpdateData(FALSE); return TRUE; @@ -674,10 +680,18 @@ void LinkOptions::GetAllData(LinkGeneral *src) src->m_timeout.GetWindowText(timeout, 5); sscanf(timeout, "%d", &linktimeout); - if(src->m_type==0){ + if(src->m_type == LINK_CABLE_SOCKET){ lanlink.speed = 0; } + LinkMode oldMode = GetLinkMode(); + LinkMode newMode = (LinkMode) src->m_type; + + if (newMode != oldMode) { + CloseLink(); + InitLink(newMode); + } + return; } ///////////////////////////////////////////////////////////////////////////// @@ -751,3 +765,24 @@ BOOL LinkServer::PreTranslateMessage(MSG* pMsg) } #endif // NO_LINK + + +void LinkGeneral::OnBnClickedLinkDisconnected() +{ + m_type = LINK_DISCONNECTED; + GetParent()->Invalidate(); +} + + +void LinkGeneral::OnBnClickedLinkRfu() +{ + m_type = LINK_RFU_IPC; + GetParent()->Invalidate(); +} + + +void LinkGeneral::OnBnClickedLinkGamecube() +{ + m_type = LINK_GAMECUBE_DOLPHIN; + GetParent()->Invalidate(); +} diff --git a/src/win32/LinkOptions.h b/src/win32/LinkOptions.h index 17d1383c..b2a34a06 100644 --- a/src/win32/LinkOptions.h +++ b/src/win32/LinkOptions.h @@ -67,6 +67,10 @@ protected: afx_msg void OnRadio2(); //}}AFX_MSG DECLARE_MESSAGE_MAP() +public: + afx_msg void OnBnClickedLinkDisconnected(); + afx_msg void OnBnClickedLinkRfu(); + afx_msg void OnBnClickedLinkGamecube(); }; ///////////////////////////////////////////////////////////////////////////// diff --git a/src/win32/MainWnd.cpp b/src/win32/MainWnd.cpp index 73416365..b44ee50a 100644 --- a/src/win32/MainWnd.cpp +++ b/src/win32/MainWnd.cpp @@ -323,10 +323,6 @@ BEGIN_MESSAGE_MAP(MainWnd, CWnd) ON_UPDATE_COMMAND_UI(ID_OPTIONS_EMULATOR_GAMEOVERRIDES, OnUpdateOptionsEmulatorGameoverrides) ON_COMMAND(ID_HELP_GNUPUBLICLICENSE, OnHelpGnupubliclicense) ON_COMMAND(ID_OPTIONS_LINK_OPTIONS, OnLinkOptions) - ON_COMMAND(ID_OPTIONS_LINK_WIRELESSADAPTER, OnOptionsLinkRFU) - ON_UPDATE_COMMAND_UI(ID_OPTIONS_LINK_WIRELESSADAPTER, OnUpdateOptionsLinkRFU) - ON_COMMAND(ID_OPTIONS_LINK_ENABLE, OnOptionsLinkEnable) - ON_UPDATE_COMMAND_UI(ID_OPTIONS_LINK_ENABLE, OnUpdateOptionsLinkEnable) ON_COMMAND(ID_OPTIONS_JOYBUS, &MainWnd::OnOptionsJoybus) //}}AFX_MSG_MAP diff --git a/src/win32/MainWnd.h b/src/win32/MainWnd.h index 49993323..c2b9bff3 100644 --- a/src/win32/MainWnd.h +++ b/src/win32/MainWnd.h @@ -330,10 +330,6 @@ protected: afx_msg void OnOptionsSoundHardwareacceleration(); afx_msg void OnUpdateOptionsSoundHardwareacceleration(CCmdUI *pCmdUI); afx_msg void OnLinkOptions(); - afx_msg void OnOptionsLinkRFU(); - afx_msg void OnUpdateOptionsLinkRFU(CCmdUI* pCmdUI); - afx_msg void OnOptionsLinkEnable(); - afx_msg void OnUpdateOptionsLinkEnable(CCmdUI* pCmdUI); afx_msg void OnOptionsJoybus(); afx_msg void OnOutputapiDirectsound(); diff --git a/src/win32/MainWndOptions.cpp b/src/win32/MainWndOptions.cpp index ddb87c5e..6effd764 100644 --- a/src/win32/MainWndOptions.cpp +++ b/src/win32/MainWndOptions.cpp @@ -1555,30 +1555,6 @@ void MainWnd::OnLinkOptions() dlg.DoModal(); } -void MainWnd::OnOptionsLinkRFU() -{ - if(rfu_enabled) rfu_enabled = false; - else { - rfu_enabled = true; - MessageBox("Please note this is the first version\nof RFU emulation code and it's not 100% bug free.\nAlso only 2 players single computer are supported at this time.", "Warning", MB_OK); - } -} - -void MainWnd::OnUpdateOptionsLinkEnable(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(gba_link_enabled); -} - -void MainWnd::OnOptionsLinkEnable() -{ - gba_link_enabled = !gba_link_enabled; -} - -void MainWnd::OnUpdateOptionsLinkRFU(CCmdUI* pCmdUI) -{ - pCmdUI->SetCheck(rfu_enabled); -} - void MainWnd::OnOptionsJoybus() { JoybusOptions dlg; @@ -1586,10 +1562,6 @@ void MainWnd::OnOptionsJoybus() } #else void MainWnd::OnLinkOptions() { } -void MainWnd::OnOptionsLinkRFU() { } -void MainWnd::OnUpdateOptionsLinkEnable(CCmdUI*) { } -void MainWnd::OnOptionsLinkEnable() { } -void MainWnd::OnUpdateOptionsLinkRFU(CCmdUI*) { } void MainWnd::OnOptionsJoybus() { } #endif diff --git a/src/win32/VBA.cpp b/src/win32/VBA.cpp index 0977987e..1f1adb08 100644 --- a/src/win32/VBA.cpp +++ b/src/win32/VBA.cpp @@ -115,9 +115,6 @@ void winlog(const char *msg, ...); /* Link ---------------------*/ -extern bool InitLink(void); -extern void CloseLink(void); -//extern int linkid; extern char inifile[]; /* ------------------- */ #ifdef _DEBUG @@ -354,7 +351,7 @@ VBA::~VBA() regInit(winBuffer); - JoyBusShutdown(); + CloseLink(); saveSettings(); @@ -449,9 +446,6 @@ BOOL VBA::InitInstance() if(p) *p = 0; - if(!InitLink()) - return FALSE; - bool force = false; if (m_lpCmdLine[0]) @@ -481,7 +475,10 @@ BOOL VBA::InitInstance() loadSettings(); - if(!initDisplay()) { + if(!InitLink((LinkMode) linkMode)) + return FALSE; + + if(!initDisplay()) { if(videoOption >= VIDEO_320x240) { regSetDwordValue("video", VIDEO_2X); } @@ -1629,16 +1626,14 @@ void VBA::loadSettings() #ifndef NO_LINK linktimeout = regQueryDwordValue("LinkTimeout", 1000); - rfu_enabled = regQueryDwordValue("RFU", false) ? true : false; - gba_link_enabled = regQueryDwordValue("linkEnabled", false) ? true : false; - gba_joybus_enabled = regQueryDwordValue("joybusEnabled", false) ? true : false; + linkMode = regQueryDwordValue("LinkMode", LINK_DISCONNECTED); + buffer = regQueryStringValue("joybusHostAddr", ""); if(!buffer.IsEmpty()) { joybusHostAddr = std::string(buffer); } - lanlink.active = regQueryDwordValue("LAN", 0) ? true : false; #endif Sm60FPS::bSaveMoreCPU = regQueryDwordValue("saveMoreCPU", 0); @@ -2566,9 +2561,7 @@ void VBA::saveSettings() #ifndef NO_LINK regSetDwordValue("LinkTimeout", linktimeout); - regSetDwordValue("RFU", rfu_enabled); - regSetDwordValue("linkEnabled", gba_link_enabled); - regSetDwordValue("joybusEnabled", gba_joybus_enabled); + regSetDwordValue("LinkMode", GetLinkMode()); regSetStringValue("joybusHostAddr", joybusHostAddr.ToString().c_str()); #endif diff --git a/src/win32/VBA.h b/src/win32/VBA.h index 0f8c3a8e..a90afb9c 100644 --- a/src/win32/VBA.h +++ b/src/win32/VBA.h @@ -203,6 +203,8 @@ class VBA : public CWinApp CString wndClass; + int linkMode; + public: VBA(); ~VBA(); diff --git a/src/win32/VBA.rc b/src/win32/VBA.rc index be713c1c..c6ffffc7 100644 --- a/src/win32/VBA.rc +++ b/src/win32/VBA.rc @@ -122,14 +122,17 @@ BEGIN PUSHBUTTON "Cancel",ID_CANCEL,140,180,57,15 END -IDD_LINKTAB1 DIALOGEX 0, 0, 184, 79 +IDD_LINKTAB1 DIALOGEX 0, 0, 184, 113 STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - LTEXT "Link timeout (in milliseconds)",IDC_STATIC,17,12,92,16 + CONTROL "Disconnected",IDC_LINK_DISCONNECTED,"Button",BS_AUTORADIOBUTTON | WS_GROUP,15,23,152,16 + CONTROL "Cable - Single Computer",IDC_LINK_SINGLE,"Button",BS_AUTORADIOBUTTON,15,39,152,16 + CONTROL "Cable - Network",IDC_LINK_LAN,"Button",BS_AUTORADIOBUTTON,15,55,154,16 + CONTROL "Wireless adapter",IDC_LINK_RFU,"Button",BS_AUTORADIOBUTTON,15,71,152,16 + CONTROL "GameCube",IDC_LINK_GAMECUBE,"Button",BS_AUTORADIOBUTTON,15,87,152,16 + LTEXT "Link timeout (in milliseconds)",IDC_STATIC,17,12,92,12 EDITTEXT IDC_LINKTIMEOUT,116,10,53,14,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "Single Computer",IDC_LINK_SINGLE,"Button",BS_AUTORADIOBUTTON | WS_GROUP,17,27,71,16 - CONTROL "Network",IDC_LINK_LAN,"Button",BS_AUTORADIOBUTTON,17,43,70,16 END IDD_LINKTAB2 DIALOGEX 0, 0, 210, 113 @@ -141,7 +144,7 @@ BEGIN CONTROL "4",IDC_LINK4P,"Button",BS_AUTORADIOBUTTON,142,16,21,13 CONTROL "TCP/IP",IDC_LINKTCP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,54,47,42,14 CONTROL "UDP",IDC_LINKUDP,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,121,47,33,14 - PUSHBUTTON "Start!",IDC_SERVERSTART,79,89,50,17,WS_DISABLED + PUSHBUTTON "Start!",IDC_SERVERSTART,79,89,50,17 LTEXT "Select number of players:",IDC_STATIC,60,7,89,10 LTEXT "Select protocol:",IDC_STATIC,78,33,53,11 CONTROL "Speed hacks",IDC_SSPEED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,76,70,57,12 @@ -154,7 +157,7 @@ BEGIN CONTROL "TCP/IP",IDC_CLINKTCP,"Button",BS_AUTORADIOBUTTON | WS_GROUP,58,20,39,12 CONTROL "UDP",IDC_CLINKUDP,"Button",BS_AUTORADIOBUTTON | WS_DISABLED,118,20,32,12 EDITTEXT IDC_SERVERIP,84,39,79,12,ES_AUTOHSCROLL | WS_GROUP - PUSHBUTTON "Connect",IDC_LINKCONNECT,75,81,59,16,WS_DISABLED + PUSHBUTTON "Connect",IDC_LINKCONNECT,75,81,59,16 LTEXT "Select protocol:",IDC_STATIC,78,7,53,9 LTEXT "Server IP address or hostname:",IDC_STATIC,7,37,62,18 LTEXT "Speed hacks:",IDC_STATIC,7,64,47,10 @@ -1245,6 +1248,7 @@ BEGIN IDD_LINKTAB1, DIALOG BEGIN + BOTTOMMARGIN, 79 END IDD_LINKTAB2, DIALOG @@ -1971,8 +1975,6 @@ BEGIN END POPUP "&Link" BEGIN - MENUITEM "Enable GBA Linking", ID_OPTIONS_LINK_ENABLE - MENUITEM "&Wireless Adapter", ID_OPTIONS_LINK_WIRELESSADAPTER MENUITEM "&Options...", ID_OPTIONS_LINK_OPTIONS MENUITEM SEPARATOR MENUITEM "&Joybus Options...", ID_OPTIONS_JOYBUS diff --git a/src/win32/resource.h b/src/win32/resource.h index 493aaba5..0eb717b9 100644 --- a/src/win32/resource.h +++ b/src/win32/resource.h @@ -823,9 +823,12 @@ #define IDC_TAB1 40305 #define IDC_LINK_SINGLE 40306 #define IDC_LINK_TIMEOUT 40307 +#define IDC_LINK_DISCONNECTED 40307 #define IDC_LINK_LAN 40308 #define IDC_LINK2P 40309 +#define IDC_LINK_RFU 40309 #define IDC_LINKTCP 40310 +#define IDC_LINK_GAMECUBE 40310 #define IDC_SSPEED 40311 #define IDC_SERVERSTART 40312 #define IDC_SERVERIP 40313