Fix a 17 year old bug: paddle were not properly handled, funny I never got issues before Twin Dragons with that!
Though Twin Dragon way of writing to 4016 is nasty! ;P
This commit is contained in:
parent
d37ad746b1
commit
1d6afc5473
@ -12,8 +12,8 @@
|
||||
|
||||
typedef struct Paddle_
|
||||
{
|
||||
uint8_t Bit;
|
||||
uint8_t LastWrite;
|
||||
uint8_t bitPos;
|
||||
uint8_t strobeState;
|
||||
} Paddle;
|
||||
|
||||
uint8_t ReadPaddle(Paddle *pdl);
|
||||
|
||||
51
src/paddle.c
51
src/paddle.c
@ -6,99 +6,94 @@
|
||||
* Copyright (c) 2002-2019 986-Studio.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <os_dependent.h>
|
||||
|
||||
#include "paddle.h"
|
||||
|
||||
void InitPaddle(Paddle *pdl)
|
||||
{
|
||||
pdl->Bit = 1;
|
||||
pdl->LastWrite = 0;
|
||||
pdl->bitPos = 1;
|
||||
pdl->strobeState = 0;
|
||||
}
|
||||
|
||||
|
||||
void WritePaddle(Paddle *pdl, uint8_t val)
|
||||
{
|
||||
if ((pdl->LastWrite == 1) && (val == 0))
|
||||
{
|
||||
InitPaddle(pdl);
|
||||
}
|
||||
|
||||
pdl->LastWrite = val;
|
||||
pdl->strobeState = val & 1;
|
||||
pdl->bitPos = 1;
|
||||
}
|
||||
|
||||
uint8_t ReadPaddle(Paddle *pdl)
|
||||
{
|
||||
switch (pdl->Bit++)
|
||||
{
|
||||
uint8_t ret = 0x40;
|
||||
|
||||
switch (pdl->bitPos)
|
||||
{
|
||||
case 1:
|
||||
if (getKeyStatus('O'))
|
||||
{
|
||||
return 0x41;
|
||||
ret = 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (getKeyStatus('P'))
|
||||
{
|
||||
return 0x41;
|
||||
ret = 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (getKeyStatus('I'))
|
||||
{
|
||||
return 0x41;
|
||||
ret = 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (getKeyStatus('U'))
|
||||
{
|
||||
return 0x41;
|
||||
ret = 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (getKeyStatus('W'))
|
||||
{
|
||||
return 0x41;
|
||||
ret = 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 6:
|
||||
if (getKeyStatus('S'))
|
||||
{
|
||||
return 0x41;
|
||||
ret = 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 7:
|
||||
if (getKeyStatus('A'))
|
||||
{
|
||||
return 0x41;
|
||||
ret = 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
if (getKeyStatus('D'))
|
||||
{
|
||||
return 0x41;
|
||||
ret = 0x41;
|
||||
}
|
||||
break;
|
||||
|
||||
case 20:
|
||||
return 0x40;
|
||||
|
||||
case 24:
|
||||
pdl->Bit = 1;
|
||||
return 0x40;
|
||||
|
||||
default:
|
||||
return 0x40;
|
||||
ret = 0x41;
|
||||
}
|
||||
|
||||
return 0x40;
|
||||
if ((pdl->strobeState == 0) && (pdl->bitPos <= 9))
|
||||
{
|
||||
pdl->bitPos++;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user