mirror of
https://github.com/preble/libpinproc
synced 2026-02-24 18:25:23 +01:00
Added Stern code to PRDecode
This commit is contained in:
@@ -234,11 +234,17 @@ PR_EXPORT void PRDriverStatePatter(PRDriverState *driver, uint16_t millisecondsO
|
|||||||
|
|
||||||
PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str)
|
PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str)
|
||||||
{
|
{
|
||||||
|
uint16_t x;
|
||||||
|
printf("hello\n");
|
||||||
|
|
||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
if (strlen(str) != 3)
|
|
||||||
return atoi(str);
|
if ( strlen(str) == 3 )
|
||||||
uint16_t x = (str[1]-'0') * 10 + (str[2]-'0');
|
x = (str[1]-'0') * 10 + (str[2]-'0');
|
||||||
|
else if ( strlen(str) == 4)
|
||||||
|
x = (str[2]-'0') * 10 + (str[3]-'0');
|
||||||
|
else return atoi(str);
|
||||||
|
|
||||||
if (machineType == kPRMachineWPC)
|
if (machineType == kPRMachineWPC)
|
||||||
{
|
{
|
||||||
@@ -273,6 +279,36 @@ PR_EXPORT uint16_t PRDecode(PRMachineType machineType, const char *str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (machineType == kPRMachineStern)
|
||||||
|
{
|
||||||
|
printf("hi\n");
|
||||||
|
switch (str[0])
|
||||||
|
{
|
||||||
|
case 'L':
|
||||||
|
case 'l':
|
||||||
|
return 80 + 16 * (7 - ((x - 1) % 8)) + (x - 1) / 8;
|
||||||
|
case 'C':
|
||||||
|
case 'c':
|
||||||
|
return x + 31;
|
||||||
|
case 'S':
|
||||||
|
case 's':
|
||||||
|
{
|
||||||
|
switch (str[1])
|
||||||
|
{
|
||||||
|
case 'D':
|
||||||
|
case 'd':
|
||||||
|
if (strlen(str) == 3)
|
||||||
|
return (str[2]-'0') + 7;
|
||||||
|
else return x + 7;
|
||||||
|
default:
|
||||||
|
if ((x - 1) % 16 < 8)
|
||||||
|
return 32 + 8 * (x / 8) + (7 - ((x - 1) % 8));
|
||||||
|
else
|
||||||
|
return 32 + (x - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return atoi(str);
|
return atoi(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user