Code Style Cleanups

- Rename all new variables and function names to use full words instead of truncated words (i.e. GetCpyPrtDongleType() -> GetCopyProtectionDongleType())
- In Memory.cpp and CopyProtectionDongles.cpp, don't reimplement MemGetAnnunciator(), instead use it.
- Add missing newline to the end of PageAdvanced.cpp
- Include Visual Studio project files (since I have added a new source file, they must be updated.)

NOTE: The state of copyProtectionDongleType will have to be saved in the save state. This is not implemented yet.
This commit is contained in:
Matthew D'Asaro 2022-12-14 21:31:54 -08:00
parent d583011494
commit e985f99e83
14 changed files with 58 additions and 89 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" />
@ -374,13 +376,13 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>AppleWin</RootNamespace>
<ProjectName>AppleWin</ProjectName>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug v141_xp|Win32'" Label="Configuration">

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

@ -42,13 +42,13 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>yaml2013</RootNamespace>
<ProjectName>yaml</ProjectName>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug v141_xp|Win32'" Label="Configuration">

View File

@ -73,7 +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_CPYPRTDONGLE_TYPE "Copy Protection Dongle Type"
#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

@ -44,8 +44,8 @@ const TCHAR CPageAdvanced::m_CloneChoices[] =
TEXT("TK3000 //e\0") // Brazilian
TEXT("Base 64A\0"); // Taiwanese
enum CPYPRTDONGLE { MENUITEM_NONE, MENUITEM_SPEEDSTAR };
const TCHAR CPageAdvanced::m_CopyPrtDongleChoices[] =
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
@ -133,8 +133,8 @@ INT_PTR CPageAdvanced::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, L
case IDC_COMBO_CP_DONGLE:
if (HIWORD(wparam) == CBN_SELCHANGE)
{
const DWORD NewCpyPrtDongleMenuItem = (DWORD)SendDlgItemMessage(hWnd, IDC_COMBO_CP_DONGLE, CB_GETCURSEL, 0, 0);
SetCpyPrtDongleType(NewCpyPrtDongleMenuItem);
const DWORD NewCopyProtectionDongleMenuItem = (DWORD)SendDlgItemMessage(hWnd, IDC_COMBO_CP_DONGLE, CB_GETCURSEL, 0, 0);
SetCopyProtectionDongleType(NewCopyProtectionDongleMenuItem);
}
break;
}
@ -193,7 +193,7 @@ void CPageAdvanced::DlgOK(HWND hWnd)
REGSAVE(TEXT(REGVALUE_SAVE_STATE_ON_EXIT), g_bSaveStateOnExit ? 1 : 0);
// Save the copy protection dongle type
REGSAVE(TEXT(REGVALUE_CPYPRTDONGLE_TYPE), GetCpyPrtDongleType());
REGSAVE(TEXT(REGVALUE_COPYPROTECTIONDONGLE_TYPE), GetCopyProtectionDongleType());
if (GetCardMgr().IsParallelPrinterCardInstalled())
{
@ -233,7 +233,7 @@ void CPageAdvanced::InitOptions(HWND hWnd)
{
InitFreezeDlgButton(hWnd);
InitCloneDropdownMenu(hWnd);
InitCpyPrtDongleDropdownMenu(hWnd);
InitCopyProtectionDongleDropdownMenu(hWnd);
}
// Advanced->Clone: Menu item to eApple2Type
@ -300,9 +300,9 @@ void CPageAdvanced::InitCloneDropdownMenu(HWND hWnd)
EnableWindow(GetDlgItem(hWnd, IDC_CLONETYPE), bIsClone ? TRUE : FALSE);
}
void CPageAdvanced::InitCpyPrtDongleDropdownMenu(HWND hWnd)
void CPageAdvanced::InitCopyProtectionDongleDropdownMenu(HWND hWnd)
{
// Set copy protection dongle menu choice
const int nCurrentChoice = GetCpyPrtDongleType();
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_CP_DONGLE, m_CopyPrtDongleChoices, nCurrentChoice);
}
const int nCurrentChoice = GetCopyProtectionDongleType();
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMBO_CP_DONGLE, m_CopyProtectionDongleChoices, nCurrentChoice);
}

View File

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

View File

@ -33,81 +33,46 @@
#include "StdAfx.h"
#include "CopyProtectionDongles.h"
#include "Memory.h"
static DWORD cpyPrtDongleType = 0;
static bool g_AN0 = 0;
static bool g_AN1 = 0;
static bool g_AN2 = 0;
static bool g_AN3 = 0;
static DWORD copyProtectionDongleType = 0;
// Must be in the same order as in PageAdvanced.cpp
enum CPYPRTDONGLETYPE { NONE, SDSSPEEDSTAR };
enum COPYPROTECTIONDONGLETYPE { NONE, SDSSPEEDSTAR };
void SetCpyPrtDongleType(DWORD type)
void SetCopyProtectionDongleType(DWORD type)
{
cpyPrtDongleType = type;
copyProtectionDongleType = type;
}
DWORD GetCpyPrtDongleType(void)
DWORD GetCopyProtectionDongleType(void)
{
return cpyPrtDongleType;
}
void CopyProtDongleControl(const UINT uControl)
{
switch (uControl)
{
case 0xC058: // AN0 clr
g_AN0 = 0;
break;
case 0xC059: // AN0 set
g_AN0 = 1;
break;
case 0xC05A: // AN1 clr
g_AN1 = 0;
break;
case 0xC05B: // AN1 set
g_AN1 = 1;
break;
case 0xC05C: // AN2 clr
g_AN2 = 0;
break;
case 0xC05D: // AN2 set
g_AN2 = 1;
break;
case 0xC05E: // AN3 clr
g_AN3 = 0;
break;
case 0xC05F: // AN3 set
g_AN3 = 1;
break;
}
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 !g_AN0 || !(g_AN1 && g_AN2);
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
DWORD CopyProtDonglePB0(void)
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
DWORD CopyProtDonglePB1(void)
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
DWORD CopyProtDonglePB2(void)
int CopyProtectionDonglePB2(void)
{
switch (cpyPrtDongleType)
switch (copyProtectionDongleType)
{
case SDSSPEEDSTAR: // Southwestern Data Systems SoftKey for Speed Star Applesoft Compiler
return SdsSpeedStar();

View File

@ -3,10 +3,9 @@
#include "Common.h"
void SetCpyPrtDongleType(DWORD type);
DWORD GetCpyPrtDongleType(void);
void CopyProtDongleControl(const UINT uControl);
DWORD CopyProtDonglePB0(void);
DWORD CopyProtDonglePB1(void);
DWORD CopyProtDonglePB2(void);
void SetCopyProtectionDongleType(DWORD type);
DWORD GetCopyProtectionDongleType(void);
int CopyProtectionDonglePB0(void);
int CopyProtectionDonglePB1(void);
int CopyProtectionDonglePB2(void);
bool SdsSpeedStar(void);

View File

@ -577,8 +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(CopyProtDonglePB0() >= 0) //If a copy protection dongle needs PB0, this overrides the joystick
pressed = CopyProtDonglePB0();
if(CopyProtectionDonglePB0() >= 0) //If a copy protection dongle needs PB0, this overrides the joystick
pressed = CopyProtectionDonglePB0();
}
break;
@ -587,14 +587,14 @@ 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 (CopyProtDonglePB1() >= 0) //If a copy protection dongle needs PB1, this overrides the joystick
pressed = CopyProtDonglePB1();
if (CopyProtectionDonglePB1() >= 0) //If a copy protection dongle needs PB1, this overrides the joystick
pressed = CopyProtectionDonglePB1();
}
break;
case 0x63:
if (CopyProtDonglePB2() >= 0) //If a copy protection dongle needs PB2, this overrides the joystick
pressed = CopyProtDonglePB2();
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"

View File

@ -731,9 +731,6 @@ BYTE __stdcall IO_Annunciator(WORD programcounter, WORD address, BYTE write, BYT
if (address >= 0xC05C && address <= 0xC05D && IsApple2JPlus(GetApple2Type()))
NTSC_VideoInitAppleType(); // AN2 switches between Katakana & ASCII video rom chars (GH#773)
if (address >= 0xC058 && address <= 0xC05F)
CopyProtDongleControl(address); // Update AN0 - AN3 state for copy protection dongles
if (!write)
return MemReadFloatingBus(nExecutedCycles);
else

View File

@ -169,11 +169,11 @@ void LoadConfiguration(bool loadImages)
LoadConfigOldJoystick_v1(JN_JOYSTICK1);
DWORD cpyPrtDongleType;
if (REGLOAD(TEXT(REGVALUE_CPYPRTDONGLE_TYPE), &cpyPrtDongleType))
SetCpyPrtDongleType(cpyPrtDongleType);
DWORD copyProtectionDongleType;
if (REGLOAD(TEXT(REGVALUE_COPYPROTECTIONDONGLE_TYPE), &copyProtectionDongleType))
SetCopyProtectionDongleType(copyProtectionDongleType);
else
SetCpyPrtDongleType(0); // None
SetCopyProtectionDongleType(0); // None
DWORD dwSoundType;
REGLOAD_DEFAULT(TEXT(REGVALUE_SOUND_EMULATION), &dwSoundType, REG_SOUNDTYPE_WAVE);

View File

@ -31,13 +31,13 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>TestCPU6502vs2013</RootNamespace>
<ProjectName>TestCPU6502</ProjectName>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug v141_xp|Win32'" Label="Configuration">

View File

@ -38,13 +38,13 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>zip_lib</RootNamespace>
<ProjectName>zip_lib</ProjectName>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug v141_xp|Win32'" Label="Configuration">

View File

@ -53,13 +53,13 @@
<Keyword>Win32Proj</Keyword>
<RootNamespace>zlib</RootNamespace>
<ProjectName>zlib</ProjectName>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug v141_xp|Win32'" Label="Configuration">