1
0
mirror of https://github.com/preble/libpinproc synced 2026-02-24 18:25:23 +01:00

Added switch statement to change setup of driver globals and groups between WPC and Stern. Also changed the order of the WPC drivers to better match the order in game manuals

This commit is contained in:
gstellenberg
2009-05-28 18:50:53 -05:00
parent b3b1298d23
commit 1b9865da78

View File

@@ -89,24 +89,50 @@ PRResult LoadConfiguration(YAML::Node& yamlDoc, const char *yamlFilePath)
return kPRSuccess; return kPRSuccess;
} }
void ConfigureDrivers(PRHandle proc, YAML::Node& yamlDoc) void ConfigureDrivers(PRHandle proc, PRMachineType machineType, YAML::Node& yamlDoc)
{ {
int i; int i;
int mappedDriverGroupEnableIndex[kPRDriverGroupsMax];
int mappedWPCDriverGroupEnableIndex[] = {0, 0, 0, 0, 0, 4, 3, 2, 1, 5, 7, 7, 7, 7, 7, 7, 7, 7, 0, 0, 0, 0, 0, 0, 0, 0};
int rowEnableIndex1;
int rowEnableIndex0;
bool tickleSternWatchdog;
bool globalPolarity;
bool activeLowMatrixRows;
int driverLoopTime;
int watchdogResetTime;
int slowGroupTime;
switch (machineType)
{
case kPRMachineWPC: {
memcpy(mappedDriverGroupEnableIndex,mappedWPCDriverGroupEnableIndex, sizeof(mappedDriverGroupEnableIndex));
rowEnableIndex1 = 6; // Unused in WPC
rowEnableIndex0 = 6;
tickleSternWatchdog = false;
globalPolarity = false;
activeLowMatrixRows = true;
driverLoopTime = 4; // milliseconds
watchdogResetTime = 1000; // milliseconds
slowGroupTime = driverLoopTime * 100; // microseconds
break;
}
}
PRDriverGlobalConfig globals; PRDriverGlobalConfig globals;
globals.enableOutputs = false; globals.enableOutputs = false;
globals.globalPolarity = false; globals.globalPolarity = globalPolarity;
globals.useClear = false; globals.useClear = false;
globals.strobeStartSelect = false; globals.strobeStartSelect = false;
globals.startStrobeTime = 4; // milliseconds per output loop globals.startStrobeTime = driverLoopTime; // milliseconds per output loop
globals.matrixRowEnableIndex1 = 12; globals.matrixRowEnableIndex1 = rowEnableIndex1;
globals.matrixRowEnableIndex0 = 6; globals.matrixRowEnableIndex0 = rowEnableIndex0;
globals.activeLowMatrixRows = true; globals.activeLowMatrixRows = activeLowMatrixRows;
globals.tickleSternWatchdog = false; globals.tickleSternWatchdog = tickleSternWatchdog;
globals.encodeEnables = false; globals.encodeEnables = false;
globals.watchdogExpired = false; globals.watchdogExpired = false;
globals.watchdogEnable = true; globals.watchdogEnable = true;
globals.watchdogResetTime = 1000; // milliseconds globals.watchdogResetTime = watchdogResetTime;
// We want to start up safely, so we'll update the global driver config twice. // We want to start up safely, so we'll update the global driver config twice.
// When we toggle enableOutputs like this P-ROC will reset the polarity: // When we toggle enableOutputs like this P-ROC will reset the polarity:
@@ -120,13 +146,14 @@ void ConfigureDrivers(PRHandle proc, YAML::Node& yamlDoc)
// Configure the groups. Each group corresponds to 8 consecutive drivers, starting // Configure the groups. Each group corresponds to 8 consecutive drivers, starting
// with driver #32. The following 6 groups are configured for coils/flashlamps. // with driver #32. The following 6 groups are configured for coils/flashlamps.
PRDriverGroupConfig group; PRDriverGroupConfig group;
for (i = 0; i < 6; i++) for (i = 4; i < 10; i++)
{ {
PRDriverGetGroupConfig(proc, i + 4, &group); PRDriverGetGroupConfig(proc, i, &group);
group.slowTime = 0; group.slowTime = 0;
group.enableIndex = i; group.enableIndex = mappedDriverGroupEnableIndex[i];
group.rowActivateIndex = i; group.rowActivateIndex = 0;
group.rowEnableSelect = 0; group.rowEnableSelect = 0;
group.matrixed = false; group.matrixed = false;
group.polarity = false; group.polarity = false;
@@ -137,11 +164,11 @@ void ConfigureDrivers(PRHandle proc, YAML::Node& yamlDoc)
} }
// The following 8 groups are configured for the feature lamp matrix. // The following 8 groups are configured for the feature lamp matrix.
for (i = 6; i < 14; i++) { for (i = 10; i < 18; i++) {
PRDriverGetGroupConfig(proc, i + 4, &group); PRDriverGetGroupConfig(proc, i, &group);
group.slowTime = 400; group.slowTime = slowGroupTime;
group.enableIndex = 7; group.enableIndex = mappedDriverGroupEnableIndex[i];
group.rowActivateIndex = i - 6; group.rowActivateIndex = i - 10;
group.rowEnableSelect = 0; group.rowEnableSelect = 0;
group.matrixed = 1; group.matrixed = 1;
group.polarity = 0; group.polarity = 0;
@@ -402,7 +429,7 @@ int main(int argc, const char **argv)
// Make Drivers the last thing to configure so watchdog doesn't expire // Make Drivers the last thing to configure so watchdog doesn't expire
// before the RunLoop begins. // before the RunLoop begins.
ConfigureDrivers(proc, yamlDoc); ConfigureDrivers(proc, machineType, yamlDoc);
printf("Running. Hit Ctrl-C to exit.\n"); printf("Running. Hit Ctrl-C to exit.\n");