Add support for hardware copy protection dongles in game i/o socket (#1153, PR #1154)

Changes:
- Add a drop-down menu to the 'Advanced' tab that lets the user select a dongle in use
- Add a new file "CopyProtectionDongles.cpp" that is a place to put drivers for these.
- Add a driver for the one known dongle we have now - Speed Star
- Modify Joystick.cpp to allow PB0-PB2 to be "pushed" by the protection dongle.
This commit is contained in:
Matthew D'Asaro 2022-12-16 01:04:29 -08:00 committed by GitHub
parent 5c0f3d03ad
commit e5a87b5063
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 152 additions and 2 deletions

View File

@ -53,6 +53,7 @@
<ClInclude Include="source\Configuration\PropertySheet.h" />
<ClInclude Include="source\Configuration\PropertySheetDefs.h" />
<ClInclude Include="source\Configuration\PropertySheetHelper.h" />
<ClInclude Include="source\CopyProtectionDongles.h" />
<ClInclude Include="source\Core.h" />
<ClInclude Include="source\CPU.h" />
<ClInclude Include="source\CPU\cpu6502.h" />
@ -167,6 +168,7 @@
<ClCompile Include="source\Configuration\PageSound.cpp" />
<ClCompile Include="source\Configuration\PropertySheet.cpp" />
<ClCompile Include="source\Configuration\PropertySheetHelper.cpp" />
<ClCompile Include="source\CopyProtectionDongles.cpp" />
<ClCompile Include="source\Core.cpp" />
<ClCompile Include="source\CPU.cpp" />
<ClCompile Include="source\Debugger\Debugger_Disassembler.cpp" />

View File

@ -268,6 +268,9 @@
<ClCompile Include="source\Configuration\Config.cpp">
<Filter>Source Files\Configuration</Filter>
</ClCompile>
<ClCompile Include="source\CopyProtectionDongles.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="source\CommonVICE\6510core.h">
@ -609,6 +612,9 @@
<ClInclude Include="source\Tfe\DNS.h">
<Filter>Source Files\Uthernet</Filter>
</ClInclude>
<ClInclude Include="source\CopyProtectionDongles.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Image Include="resource\Applewin.bmp">

View File

@ -256,6 +256,8 @@ BEGIN
COMBOBOX IDC_CLONETYPE,35,185,100,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "The Free&ze's non-autostart F8 rom (Apple ][ or ][+ only)",IDC_THE_FREEZES_F8_ROM_FW,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,201,194,10
LTEXT "&Copy Protection Dongle:",IDC_STATIC,5,220,82,8
COMBOBOX IDC_COMBO_CP_DONGLE,89,218,100,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END

View File

@ -113,6 +113,7 @@
#define IDC_COMBO_DISK1 1080
#define IDC_COMBO_DISK2 1081
#define IDC_CHECK_FS_SHOW_SUBUNIT_STATUS 1082
#define IDC_COMBO_CP_DONGLE 1082
#define IDC_CHECK_VERTICAL_BLEND 1083
#define IDC_CHECK_50HZ_VIDEO 1084
#define IDC_COMBO_DISK1_SLOT5 1085
@ -137,7 +138,7 @@
#define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 149
#define _APS_NEXT_COMMAND_VALUE 40012
#define _APS_NEXT_CONTROL_VALUE 1082
#define _APS_NEXT_CONTROL_VALUE 1083
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -73,6 +73,7 @@ enum AppMode_e
#define REGVALUE_MB_VOLUME "Mockingboard Volume"
#define REGVALUE_SAVESTATE_FILENAME "Save State Filename"
#define REGVALUE_SAVE_STATE_ON_EXIT "Save State On Exit"
#define REGVALUE_COPYPROTECTIONDONGLE_TYPE "Copy Protection Dongle Type"
#define REGVALUE_HDD_ENABLED "Harddisk Enable" // Deprecated from 1.30.5
#define REGVALUE_JOYSTICK0_EMU_TYPE "Joystick0 Emu Type v3" // GH#434: Added at 1.26.3.0 (previously was "Joystick0 Emu Type")
#define REGVALUE_JOYSTICK1_EMU_TYPE "Joystick1 Emu Type v3" // GH#434: Added at 1.26.3.0 (previously was "Joystick1 Emu Type")

View File

@ -31,6 +31,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../Registry.h"
#include "../SaveState.h"
#include "../CardManager.h"
#include "../CopyProtectionDongles.h"
#include "../resource/resource.h"
CPageAdvanced* CPageAdvanced::ms_this = 0; // reinit'd in ctor
@ -43,6 +44,11 @@ const TCHAR CPageAdvanced::m_CloneChoices[] =
TEXT("TK3000 //e\0") // Brazilian
TEXT("Base 64A\0"); // Taiwanese
enum COPYPROTECTIONDONGLECHOICE { MENUITEM_NONE, MENUITEM_SPEEDSTAR };
const TCHAR CPageAdvanced::m_CopyProtectionDongleChoices[] =
TEXT("None\0")
TEXT("SDS DataKey - Speed Star\0"); // Protection dongle for Southwestern Data Systems "Speed Star" Applesoft Compiler
INT_PTR CALLBACK CPageAdvanced::DlgProc(HWND hWnd, UINT message, WPARAM wparam, LPARAM lparam)
{
@ -123,6 +129,13 @@ INT_PTR CPageAdvanced::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, L
m_PropertySheetHelper.GetConfigNew().m_Apple2Type = NewCloneType;
m_PropertySheetHelper.GetConfigNew().m_CpuType = ProbeMainCpuDefault(NewCloneType);
}
case IDC_COMBO_CP_DONGLE:
if (HIWORD(wparam) == CBN_SELCHANGE)
{
const DWORD NewCopyProtectionDongleMenuItem = (DWORD)SendDlgItemMessage(hWnd, IDC_COMBO_CP_DONGLE, CB_GETCURSEL, 0, 0);
SetCopyProtectionDongleType(NewCopyProtectionDongleMenuItem);
}
break;
}
break;
@ -179,6 +192,9 @@ void CPageAdvanced::DlgOK(HWND hWnd)
g_bSaveStateOnExit = IsDlgButtonChecked(hWnd, IDC_SAVESTATE_ON_EXIT) ? true : false;
REGSAVE(TEXT(REGVALUE_SAVE_STATE_ON_EXIT), g_bSaveStateOnExit ? 1 : 0);
// Save the copy protection dongle type
REGSAVE(TEXT(REGVALUE_COPYPROTECTIONDONGLE_TYPE), GetCopyProtectionDongleType());
if (GetCardMgr().IsParallelPrinterCardInstalled())
{
ParallelPrinterCard* card = GetCardMgr().GetParallelPrinterCard();
@ -217,6 +233,7 @@ void CPageAdvanced::InitOptions(HWND hWnd)
{
InitFreezeDlgButton(hWnd);
InitCloneDropdownMenu(hWnd);
InitCopyProtectionDongleDropdownMenu(hWnd);
}
// Advanced->Clone: Menu item to eApple2Type
@ -282,3 +299,10 @@ void CPageAdvanced::InitCloneDropdownMenu(HWND hWnd)
const bool bIsClone = IsClone( m_PropertySheetHelper.GetConfigNew().m_Apple2Type );
EnableWindow(GetDlgItem(hWnd, IDC_CLONETYPE), bIsClone ? TRUE : FALSE);
}
void CPageAdvanced::InitCopyProtectionDongleDropdownMenu(HWND hWnd)
{
// Set copy protection dongle menu choice
const int nCurrentChoice = GetCopyProtectionDongleType();
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_CP_DONGLE, m_CopyProtectionDongleChoices, nCurrentChoice);
}

View File

@ -35,9 +35,11 @@ private:
int GetCloneMenuItem(void);
void InitFreezeDlgButton(HWND hWnd);
void InitCloneDropdownMenu(HWND hWnd);
void InitCopyProtectionDongleDropdownMenu(HWND hWnd);
static CPageAdvanced* ms_this;
static const TCHAR m_CloneChoices[];
static const TCHAR m_CopyProtectionDongleChoices[];
const PAGETYPE m_Page;
CPropertySheetHelper& m_PropertySheetHelper;

View File

@ -0,0 +1,85 @@
/*
AppleWin : An Apple //e emulator for Windows
Copyright (C) 1994-1996, Michael O'Brien
Copyright (C) 1999-2001, Oliver Schmidt
Copyright (C) 2002-2005, Tom Charlesworth
Copyright (C) 2006-2007, Tom Charlesworth, Michael Pohoreski
AppleWin is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
AppleWin is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with AppleWin; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
CopyProtectionDongles.cpp
Emulate hardware copy protection dongles for Apple II
Currently supported:
- Southwestern Data Systems SoftKey for Speed Star Applesoft Compiler
Matthew D'Asaro Dec 2022
*/
#include "StdAfx.h"
#include "CopyProtectionDongles.h"
#include "Memory.h"
static DWORD copyProtectionDongleType = 0;
// Must be in the same order as in PageAdvanced.cpp
enum COPYPROTECTIONDONGLETYPE { NONE, SDSSPEEDSTAR };
void SetCopyProtectionDongleType(DWORD type)
{
copyProtectionDongleType = type;
}
DWORD GetCopyProtectionDongleType(void)
{
return copyProtectionDongleType;
}
// This protection dongle consists of a NAND gate connected with AN1 and AN2 on the inputs
// PB2 on the output, and AN0 connected to power it.
bool SdsSpeedStar(void)
{
return !MemGetAnnunciator(0) || !(MemGetAnnunciator(1) && MemGetAnnunciator(2));
}
// Returns the copy protection dongle state of PB0. A return value of -1 means not used by copy protection dongle
int CopyProtectionDonglePB0(void)
{
return -1;
}
// Returns the copy protection dongle state of PB1. A return value of -1 means not used by copy protection dongle
int CopyProtectionDonglePB1(void)
{
return -1;
}
// Returns the copy protection dongle state of PB2. A return value of -1 means not used by copy protection dongle
int CopyProtectionDonglePB2(void)
{
switch (copyProtectionDongleType)
{
case SDSSPEEDSTAR: // Southwestern Data Systems SoftKey for Speed Star Applesoft Compiler
return SdsSpeedStar();
break;
default:
return -1;
break;
}
}

View File

@ -0,0 +1,11 @@
#pragma once
#include "Common.h"
void SetCopyProtectionDongleType(DWORD type);
DWORD GetCopyProtectionDongleType(void);
int CopyProtectionDonglePB0(void);
int CopyProtectionDonglePB1(void);
int CopyProtectionDonglePB2(void);
bool SdsSpeedStar(void);

View File

@ -45,6 +45,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Memory.h"
#include "YamlHelper.h"
#include "Interface.h"
#include "CopyProtectionDongles.h"
#include "Configuration/PropertySheet.h"
@ -576,6 +577,8 @@ BYTE __stdcall JoyReadButton(WORD pc, WORD address, BYTE, BYTE, ULONG nExecutedC
pressed = !swapButtons0and1 ? CheckButton0Pressed() : CheckButton1Pressed();
const UINT button0 = !swapButtons0and1 ? 0 : 1;
DoAutofire(button0, pressed);
if(CopyProtectionDonglePB0() >= 0) //If a copy protection dongle needs PB0, this overrides the joystick
pressed = CopyProtectionDonglePB0();
}
break;
@ -584,11 +587,15 @@ BYTE __stdcall JoyReadButton(WORD pc, WORD address, BYTE, BYTE, ULONG nExecutedC
pressed = !swapButtons0and1 ? CheckButton1Pressed() : CheckButton0Pressed();
const UINT button1 = !swapButtons0and1 ? 1 : 0;
DoAutofire(button1, pressed);
if (CopyProtectionDonglePB1() >= 0) //If a copy protection dongle needs PB1, this overrides the joystick
pressed = CopyProtectionDonglePB1();
}
break;
case 0x63:
if (IS_APPLE2 && (joyinfo[joytype[1]] == DEVICE_NONE))
if (CopyProtectionDonglePB2() >= 0) //If a copy protection dongle needs PB2, this overrides the joystick
pressed = CopyProtectionDonglePB2();
else if (IS_APPLE2 && (joyinfo[joytype[1]] == DEVICE_NONE))
{
// Apple II/II+ with no joystick has the "SHIFT key mod"
// See Sather's Understanding The Apple II p7-36

View File

@ -56,6 +56,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Tape.h"
#include "RGBMonitor.h"
#include "VidHD.h"
#include "CopyProtectionDongles.h"
#include "z80emu.h"
#include "Z80VICE/z80.h"

View File

@ -47,6 +47,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Mockingboard.h"
#include "Interface.h"
#include "SoundCore.h"
#include "CopyProtectionDongles.h"
#include "Configuration/IPropertySheet.h"
#include "Tfe/PCapBackend.h"
@ -167,6 +168,13 @@ void LoadConfiguration(bool loadImages)
else
LoadConfigOldJoystick_v1(JN_JOYSTICK1);
DWORD copyProtectionDongleType;
if (REGLOAD(TEXT(REGVALUE_COPYPROTECTIONDONGLE_TYPE), &copyProtectionDongleType))
SetCopyProtectionDongleType(copyProtectionDongleType);
else
SetCopyProtectionDongleType(0); // None
DWORD dwSoundType;
REGLOAD_DEFAULT(TEXT(REGVALUE_SOUND_EMULATION), &dwSoundType, REG_SOUNDTYPE_WAVE);
switch (dwSoundType)