Add Uthernet II support and make Uthernet I a Card. (PR #1047)

. tfe.cpp renamed to Uthernet1.cpp.
. add class NetworkBackend: common to both U1 and U2 cards, and abstracts Windows/Linux backends.
. modernise error message if WPCAP.DLL is not installed.
This commit is contained in:
Andrea
2022-02-27 17:26:48 +00:00
committed by GitHub
parent 514d2adb79
commit 9f8c4d99af
32 changed files with 3210 additions and 1823 deletions
+2 -2
View File
@@ -6,7 +6,7 @@
#include "../DiskImage.h" // Disk_Status_e
#include "../Harddisk.h"
#include "../Interface.h" // VideoRefreshRate_e, GetVideoRefreshRate()
#include "../Tfe/tfe.h"
#include "../Tfe/PCapBackend.h"
class CConfigNeedingRestart
{
@@ -40,7 +40,7 @@ public:
for (UINT slot = SLOT0; slot < NUM_SLOTS; slot++)
m_Slot[slot] = cardManager.QuerySlot(slot);
m_SlotAux = cardManager.QueryAux();
m_tfeInterface = get_tfe_interface();
m_tfeInterface = PCapBackend::tfe_interface;
m_bEnableTheFreezesF8Rom = GetPropertySheet().GetTheFreezesF8Rom();
m_uSaveLoadStateMsg = 0;
m_videoRefreshRate = GetVideo().GetVideoRefreshRate();
+15 -6
View File
@@ -112,7 +112,8 @@ INT_PTR CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPA
case IDC_ETHERNET:
ui_tfe_settings_dialog(hWnd);
m_PropertySheetHelper.GetConfigNew().m_Slot[SLOT3] = m_PageConfigTfe.m_tfe_enabled ? CT_Uthernet : CT_Empty;
m_PropertySheetHelper.GetConfigNew().m_Slot[SLOT3] = m_PageConfigTfe.m_tfe_selected;
m_PropertySheetHelper.GetConfigNew().m_tfeInterface = m_PageConfigTfe.m_tfe_interface_name;
InitOptions(hWnd);
break;
@@ -249,8 +250,18 @@ INT_PTR CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPA
}
{
m_PageConfigTfe.m_tfe_enabled = get_tfe_enabled();
m_PageConfigTfe.m_tfe_interface_name = get_tfe_interface();
SS_CARDTYPE cardInSlot3 = GetCardMgr().QuerySlot(SLOT3);
switch (cardInSlot3) {
case CT_Uthernet:
case CT_Uthernet2:
m_PageConfigTfe.m_tfe_selected = cardInSlot3;
break;
default:
m_PageConfigTfe.m_tfe_selected = CT_Empty;
break;
}
m_PageConfigTfe.m_tfe_interface_name = PCapBackend::tfe_interface;
}
InitOptions(hWnd);
@@ -325,8 +336,6 @@ void CPageConfig::DlgOK(HWND hWnd)
m_PropertySheetHelper.GetConfigNew().m_videoRefreshRate = isNewVideoRate50Hz ? VR_50HZ : VR_60HZ;
}
m_PropertySheetHelper.GetConfigNew().m_tfeInterface = m_PageConfigTfe.m_tfe_interface_name;
if (bVideoReinit)
{
win32Frame.FrameRefreshStatus(DRAW_TITLE);
@@ -381,7 +390,7 @@ void CPageConfig::DlgOK(HWND hWnd)
void CPageConfig::InitOptions(HWND hWnd)
{
const SS_CARDTYPE slot3 = m_PropertySheetHelper.GetConfigNew().m_Slot[SLOT3];
const BOOL enableUthernetDialog = slot3 == CT_Empty || slot3 == CT_Uthernet;
const BOOL enableUthernetDialog = slot3 == CT_Empty || slot3 == CT_Uthernet || slot3 == CT_Uthernet2;
EnableWindow(GetDlgItem(hWnd, IDC_ETHERNET), enableUthernetDialog);
const bool bIsSlot3VidHD = slot3 == CT_VidHD;
+42 -19
View File
@@ -28,7 +28,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../Common.h"
#include "../Registry.h"
#include "../resource/resource.h"
#include "../Tfe/tfe.h"
#include "../Tfe/PCapBackend.h"
#include "../Tfe/tfesupp.h"
CPageConfigTfe* CPageConfigTfe::ms_this = 0; // reinit'd in ctor
@@ -111,29 +111,29 @@ void CPageConfigTfe::DlgCANCEL(HWND window)
BOOL CPageConfigTfe::get_tfename(int number, char **ppname, char **ppdescription)
{
if (tfe_enumadapter_open())
if (PCapBackend::tfe_enumadapter_open())
{
char *pname = NULL;
char *pdescription = NULL;
while (number--)
{
if (!tfe_enumadapter(&pname, &pdescription))
if (!PCapBackend::tfe_enumadapter(&pname, &pdescription))
break;
lib_free(pname);
lib_free(pdescription);
}
if (tfe_enumadapter(&pname, &pdescription))
if (PCapBackend::tfe_enumadapter(&pname, &pdescription))
{
*ppname = pname;
*ppdescription = pdescription;
tfe_enumadapter_close();
PCapBackend::tfe_enumadapter_close();
return TRUE;
}
tfe_enumadapter_close();
PCapBackend::tfe_enumadapter_close();
}
return FALSE;
@@ -145,7 +145,7 @@ int CPageConfigTfe::gray_ungray_items(HWND hwnd)
int number;
int disabled = 0;
get_disabled_state(&disabled);
PCapBackend::get_disabled_state(&disabled);
if (disabled)
{
@@ -199,14 +199,26 @@ void CPageConfigTfe::init_tfe_dialog(HWND hwnd)
uilib_adjust_group_width(hwnd, ms_leftgroup);
uilib_move_group(hwnd, ms_rightgroup, xsize + 30);
active_value = (m_tfe_enabled > 0 ? 1 : 0);
switch (m_tfe_selected)
{
case CT_Uthernet:
active_value = 1;
break;
case CT_Uthernet2:
active_value = 2;
break;
default:
active_value = 0;
break;
}
temp_hwnd=GetDlgItem(hwnd,IDC_TFE_SETTINGS_ENABLE);
SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Disabled");
SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Uthernet");
SendMessage(temp_hwnd, CB_ADDSTRING, 0, (LPARAM)"Uthernet II");
SendMessage(temp_hwnd, CB_SETCURSEL, (WPARAM)active_value, 0);
if (tfe_enumadapter_open())
if (PCapBackend::tfe_enumadapter_open())
{
int cnt = 0;
@@ -215,7 +227,7 @@ void CPageConfigTfe::init_tfe_dialog(HWND hwnd)
temp_hwnd=GetDlgItem(hwnd,IDC_TFE_SETTINGS_INTERFACE);
for (cnt = 0; tfe_enumadapter(&pname, &pdescription); cnt++)
for (cnt = 0; PCapBackend::tfe_enumadapter(&pname, &pdescription); cnt++)
{
BOOL this_entry = FALSE;
@@ -237,7 +249,7 @@ void CPageConfigTfe::init_tfe_dialog(HWND hwnd)
}
}
tfe_enumadapter_close();
PCapBackend::tfe_enumadapter_close();
}
if (gray_ungray_items(hwnd))
@@ -246,12 +258,12 @@ void CPageConfigTfe::init_tfe_dialog(HWND hwnd)
// TC (18 Dec 2017) this vicekb URL is a broken link now, so I copied it to the AppleWin repo, here:
// . https://github.com/AppleWin/AppleWin/blob/master/docs/VICE%20Knowledge%20Base%20-%20Article%2013-005.htm
MessageBox( hwnd,
"TFE support is not available on your system,\n"
"there is some important part missing. Please have a\n"
"look at the VICE knowledge base support page\n"
"\n http://vicekb.trikaliotis.net/13-005\n\n"
"for possible reasons and to activate networking with VICE.",
"TFE support", MB_ICONINFORMATION|MB_OK);
"Uthernet support is not available on your system,\n"
"WPCAP.DLL cannot be loaded.\n\n"
"Install Npcap from\n\n"
" https://npcap.com\n\n"
"to activate networking with AppleWin.",
"Uthernet support", MB_ICONINFORMATION|MB_OK);
/* just quit the dialog before it is open */
SendMessage( hwnd, WM_COMMAND, IDCANCEL, 0);
@@ -271,11 +283,22 @@ void CPageConfigTfe::save_tfe_dialog(HWND hwnd)
{
m_tfe_interface_name = buffer;
active_value = SendMessage(GetDlgItem(hwnd, IDC_TFE_SETTINGS_ENABLE), CB_GETCURSEL, 0, 0);
m_tfe_enabled = active_value > 0 ? 1 : 0;
switch (active_value)
{
case 1:
m_tfe_selected = CT_Uthernet;
break;
case 2:
m_tfe_selected = CT_Uthernet2;
break;
default:
m_tfe_selected = CT_Empty;
break;
}
}
else
{
m_tfe_enabled = 0;
m_tfe_selected = CT_Empty;
m_tfe_interface_name.clear();
}
}
+3 -2
View File
@@ -2,6 +2,7 @@
#include "IPropertySheetPage.h"
#include "../Tfe/Uilib.h"
#include "../Card.h"
#include <string>
@@ -11,13 +12,13 @@ public:
CPageConfigTfe()
{
CPageConfigTfe::ms_this = this;
m_tfe_enabled = 0;
m_tfe_selected = CT_Empty;
}
virtual ~CPageConfigTfe(){}
static INT_PTR CALLBACK DlgProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam);
int m_tfe_enabled;
SS_CARDTYPE m_tfe_selected;
std::string m_tfe_interface_name;
protected:
+6 -4
View File
@@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../Log.h"
#include "../Registry.h"
#include "../SaveState.h"
#include "../Tfe/PCapBackend.h"
/*
Config causing AfterClose msgs:
@@ -330,12 +331,10 @@ void CPropertySheetHelper::ApplyNewConfig(const CConfigNeedingRestart& ConfigNew
UINT slot = SLOT3;
if (CONFIG_CHANGED_LOCAL(m_Slot[slot]))
{
SetSlot(slot, ConfigNew.m_Slot[slot]);
if (ConfigNew.m_Slot[slot] == CT_Uthernet) // TODO: move this to UthernetCard object
tfe_SetRegistryInterface(slot, ConfigNew.m_tfeInterface);
}
// unconditionally save it, as the previous SetSlot might have removed the setting
PCapBackend::tfe_SetRegistryInterface(slot, ConfigNew.m_tfeInterface);
slot = SLOT4;
if (CONFIG_CHANGED_LOCAL(m_Slot[slot]))
@@ -451,6 +450,9 @@ bool CPropertySheetHelper::HardwareConfigChanged(HWND hWnd)
if (CONFIG_CHANGED(m_Slot[SLOT3]))
strMsgMain += GetSlot(SLOT3);
if (CONFIG_CHANGED(m_tfeInterface))
strMsgMain += ". Uthernet interface has changed\n";
if (CONFIG_CHANGED(m_Slot[SLOT4]))
strMsgMain += GetSlot(SLOT4);