123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- /*
- * Paddle manager - The peTI-NESulator Project
- * paddle.c
- *
- * Created by Manoël TRAPIER.
- * Copyright (c) 2003-2018 986-Studio. All rights reserved.
- *
- */
- #include <os_dependent.h>
- #include "paddle.h"
- void InitPaddle(Paddle *pdl)
- {
- pdl->Bit = 1;
- pdl->LastWrite = 0;
- }
- void WritePaddle(Paddle *pdl, uint8_t val)
- {
- if ((pdl->LastWrite == 1) && (val == 0))
- {
- InitPaddle(pdl);
- }
- pdl->LastWrite = val;
- }
- uint8_t ReadPaddle(Paddle *pdl)
- {
- switch (pdl->Bit++)
- {
- case 1:
- if (getKeyStatus('O'))
- {
- return 0x41;
- }
- break;
- case 2:
- if (getKeyStatus('P'))
- {
- return 0x41;
- }
- break;
- case 3:
- if (getKeyStatus('I'))
- {
- return 0x41;
- }
- break;
- case 4:
- if (getKeyStatus('U'))
- {
- return 0x41;
- }
- break;
- case 5:
- if (getKeyStatus('W'))
- {
- return 0x41;
- }
- break;
- case 6:
- if (getKeyStatus('S'))
- {
- return 0x41;
- }
- break;
- case 7:
- if (getKeyStatus('A'))
- {
- return 0x41;
- }
- break;
- case 8:
- if (getKeyStatus('D'))
- {
- return 0x41;
- }
- break;
- case 20:
- return 0x40;
- case 24:
- pdl->Bit = 1;
- return 0x40;
- default:
- return 0x40;
- }
- return 0x40;
- }
|