2022-12-16 09:04:29 +00:00
|
|
|
/*
|
|
|
|
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
|
2022-12-31 17:32:50 +00:00
|
|
|
Copyright (C) 2006-2022, Tom Charlesworth, Michael Pohoreski
|
2022-12-16 09:04:29 +00:00
|
|
|
|
|
|
|
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:
|
2023-01-01 19:34:32 +00:00
|
|
|
- Southwestern Data Systems DataKey for SpeedStar Applesoft Compiler
|
2022-12-16 09:04:29 +00:00
|
|
|
|
|
|
|
Matthew D'Asaro Dec 2022
|
|
|
|
*/
|
|
|
|
#include "StdAfx.h"
|
2023-01-01 18:47:21 +00:00
|
|
|
#include <sstream>
|
2022-12-16 09:04:29 +00:00
|
|
|
|
|
|
|
#include "CopyProtectionDongles.h"
|
|
|
|
#include "Memory.h"
|
2022-12-31 19:51:05 +00:00
|
|
|
#include "YamlHelper.h"
|
2022-12-16 09:04:29 +00:00
|
|
|
|
2022-12-31 17:32:50 +00:00
|
|
|
static DONGLETYPE copyProtectionDongleType = DT_EMPTY;
|
2022-12-16 09:04:29 +00:00
|
|
|
|
2022-12-31 17:32:50 +00:00
|
|
|
void SetCopyProtectionDongleType(DONGLETYPE type)
|
2022-12-16 09:04:29 +00:00
|
|
|
{
|
|
|
|
copyProtectionDongleType = type;
|
|
|
|
}
|
|
|
|
|
2022-12-31 17:32:50 +00:00
|
|
|
DONGLETYPE GetCopyProtectionDongleType(void)
|
2022-12-16 09:04:29 +00:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2023-01-01 19:34:32 +00:00
|
|
|
case DT_SDSSPEEDSTAR: // Southwestern Data Systems DataKey for SpeedStar Applesoft Compiler
|
2022-12-16 09:04:29 +00:00
|
|
|
return SdsSpeedStar();
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-12-31 19:51:05 +00:00
|
|
|
|
2023-01-01 18:47:21 +00:00
|
|
|
//===========================================================================
|
|
|
|
|
|
|
|
static const UINT kUNIT_VERSION = 1;
|
|
|
|
|
|
|
|
static const std::string& GetSnapshotStructName_SDSSpeedStar(void)
|
2022-12-31 19:51:05 +00:00
|
|
|
{
|
|
|
|
static const std::string name("SDS SpeedStar dongle");
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CopyProtectionDongleSaveSnapshot(YamlSaveHelper& yamlSaveHelper)
|
|
|
|
{
|
|
|
|
if (copyProtectionDongleType == DT_SDSSPEEDSTAR)
|
|
|
|
{
|
2023-01-01 18:47:21 +00:00
|
|
|
yamlSaveHelper.SaveString(SS_YAML_KEY_DEVICE, GetSnapshotStructName_SDSSpeedStar());
|
2022-12-31 19:51:05 +00:00
|
|
|
// NB. No state for this dongle
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_ASSERT(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-01 18:47:21 +00:00
|
|
|
void CopyProtectionDongleLoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT version)
|
2022-12-31 19:51:05 +00:00
|
|
|
{
|
2023-01-01 18:47:21 +00:00
|
|
|
if (version < 1 || version > kUNIT_VERSION)
|
|
|
|
{
|
|
|
|
std::ostringstream msg;
|
|
|
|
msg << "Version " << version;
|
|
|
|
msg << " is not supported for game I/O device.";
|
|
|
|
|
|
|
|
throw std::runtime_error(msg.str());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string device = yamlLoadHelper.LoadString(SS_YAML_KEY_DEVICE);
|
|
|
|
|
|
|
|
if (device == GetSnapshotStructName_SDSSpeedStar())
|
2022-12-31 19:51:05 +00:00
|
|
|
{
|
|
|
|
copyProtectionDongleType = DT_SDSSPEEDSTAR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_ASSERT(0);
|
|
|
|
}
|
|
|
|
}
|