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_
|
typedef struct Paddle_
|
||||||
{
|
{
|
||||||
uint8_t Bit;
|
uint8_t bitPos;
|
||||||
uint8_t LastWrite;
|
uint8_t strobeState;
|
||||||
} Paddle;
|
} Paddle;
|
||||||
|
|
||||||
uint8_t ReadPaddle(Paddle *pdl);
|
uint8_t ReadPaddle(Paddle *pdl);
|
||||||
|
|||||||
51
src/paddle.c
51
src/paddle.c
@ -6,99 +6,94 @@
|
|||||||
* Copyright (c) 2002-2019 986-Studio.
|
* Copyright (c) 2002-2019 986-Studio.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
#include <os_dependent.h>
|
#include <os_dependent.h>
|
||||||
|
|
||||||
#include "paddle.h"
|
#include "paddle.h"
|
||||||
|
|
||||||
void InitPaddle(Paddle *pdl)
|
void InitPaddle(Paddle *pdl)
|
||||||
{
|
{
|
||||||
pdl->Bit = 1;
|
pdl->bitPos = 1;
|
||||||
pdl->LastWrite = 0;
|
pdl->strobeState = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void WritePaddle(Paddle *pdl, uint8_t val)
|
void WritePaddle(Paddle *pdl, uint8_t val)
|
||||||
{
|
{
|
||||||
if ((pdl->LastWrite == 1) && (val == 0))
|
pdl->strobeState = val & 1;
|
||||||
{
|
pdl->bitPos = 1;
|
||||||
InitPaddle(pdl);
|
|
||||||
}
|
|
||||||
|
|
||||||
pdl->LastWrite = val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t ReadPaddle(Paddle *pdl)
|
uint8_t ReadPaddle(Paddle *pdl)
|
||||||
{
|
{
|
||||||
switch (pdl->Bit++)
|
uint8_t ret = 0x40;
|
||||||
{
|
|
||||||
|
|
||||||
|
switch (pdl->bitPos)
|
||||||
|
{
|
||||||
case 1:
|
case 1:
|
||||||
if (getKeyStatus('O'))
|
if (getKeyStatus('O'))
|
||||||
{
|
{
|
||||||
return 0x41;
|
ret = 0x41;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if (getKeyStatus('P'))
|
if (getKeyStatus('P'))
|
||||||
{
|
{
|
||||||
return 0x41;
|
ret = 0x41;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
if (getKeyStatus('I'))
|
if (getKeyStatus('I'))
|
||||||
{
|
{
|
||||||
return 0x41;
|
ret = 0x41;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
if (getKeyStatus('U'))
|
if (getKeyStatus('U'))
|
||||||
{
|
{
|
||||||
return 0x41;
|
ret = 0x41;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case 5:
|
||||||
if (getKeyStatus('W'))
|
if (getKeyStatus('W'))
|
||||||
{
|
{
|
||||||
return 0x41;
|
ret = 0x41;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case 6:
|
||||||
if (getKeyStatus('S'))
|
if (getKeyStatus('S'))
|
||||||
{
|
{
|
||||||
return 0x41;
|
ret = 0x41;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 7:
|
case 7:
|
||||||
if (getKeyStatus('A'))
|
if (getKeyStatus('A'))
|
||||||
{
|
{
|
||||||
return 0x41;
|
ret = 0x41;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 8:
|
case 8:
|
||||||
if (getKeyStatus('D'))
|
if (getKeyStatus('D'))
|
||||||
{
|
{
|
||||||
return 0x41;
|
ret = 0x41;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 20:
|
|
||||||
return 0x40;
|
|
||||||
|
|
||||||
case 24:
|
|
||||||
pdl->Bit = 1;
|
|
||||||
return 0x40;
|
|
||||||
|
|
||||||
default:
|
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