MCPcopy Create free account
hub / github.com/AppleWin/AppleWin / CopyProtectionDonglePDL

Function CopyProtectionDonglePDL

source/CopyProtectionDongles.cpp:123–168  ·  view source on GitHub ↗

Returns the copy protection dongle state of PDL(n). A return value of -1 means not used by copy protection dongle

Source from the content-addressed store, hash-verified

121
122// Returns the copy protection dongle state of PDL(n). A return value of -1 means not used by copy protection dongle
123int CopyProtectionDonglePDL(UINT pdl)
124{
125 if (copyProtectionDongleType == DT_HAYDENCOMPILER && pdl == 3)
126 {
127 static BYTE haydenValue[4] = {0xFF, 0x96, 0x96, 0x50}; // Derived from reverse-engineered Hayden code - although other than 0xFF, actual values are unknown.
128 UINT haydenDongleMode = ((UINT)MemGetAnnunciator(2) << 1) | (UINT)MemGetAnnunciator(0);
129 return haydenValue[haydenDongleMode];
130 }
131
132 //
133
134 if (copyProtectionDongleType != DT_ROBOCOM500 && copyProtectionDongleType != DT_ROBOCOM1000 && copyProtectionDongleType != DT_ROBOCOM1500)
135 return -1;
136
137 bool roboComInterfaceModulePower = !MemGetAnnunciator(3);
138 if (!roboComInterfaceModulePower || pdl != 3)
139 return -1;
140
141 UINT roboComInterfaceModuleMode = ((UINT)MemGetAnnunciator(2) << 2) | ((UINT)MemGetAnnunciator(1) << 1) | (UINT)MemGetAnnunciator(0);
142
143 switch (copyProtectionDongleType)
144 {
145 case DT_ROBOCOM500:
146 {
147 static BYTE robo500_lo[8] = { 0x3F,0x2E,0x54,0x54,0x2E,0x22,0x72,0x17 }; // PDL3 lower bound - see GH#1247
148 static BYTE robo500_hi[8] = { 0x6F,0x54,0x94,0x94,0x54,0x40,0xC4,0x2E }; // PDL3 upper bound - see GH#1247
149 // This mean value gives values that are very close to the actual 1000 & 1500 Module Interfaces - so assume it's similar for the 500 series.
150 return (robo500_lo[roboComInterfaceModuleMode] + robo500_hi[roboComInterfaceModuleMode] - 1) / 2;
151 }
152
153 case DT_ROBOCOM1000:
154 {
155 static BYTE robo1000[8] = { 34,151,48,64,113,113,64,85 }; // Actual Module Interface values for PDL3
156 return robo1000[roboComInterfaceModuleMode];
157 }
158
159 case DT_ROBOCOM1500:
160 {
161 static BYTE robo1500[8] = { 153,34,64,34,48,86,114,48 }; // Actual Module Interface values for PDL3
162 return robo1500[roboComInterfaceModuleMode];
163 }
164
165 default:
166 return -1;
167 }
168}
169
170//===========================================================================
171

Callers 2

JoyReadPositionFunction · 0.85
JoyResetPositionFunction · 0.85

Calls 1

MemGetAnnunciatorFunction · 0.85

Tested by

no test coverage detected