1
0
Fork 0
2019-nes-emulator/Source/Input.cpp

41 lines
499 B
C++
Raw Normal View History

2019-09-11 23:20:30 +00:00
#include "Input.hpp"
void Input::Strobe(uint8_t* but)
{
if (strobe)
{
for (int i = 0; i < 8; ++i)
{
buttons[i] = but[i];
}
}
}
uint8_t Input::Poll()
{
uint8_t buttonState;
// Strobe set - return state of A button
if (strobe)
{
buttonState = buttons[Buttons::A];
}
// All 8 bits read - return 1u
else if (buttonIndex > Buttons::Right)
{
buttonState = 1u;
}
// Return next bit
else
{
buttonState = buttons[buttonIndex];
++buttonIndex;
}
return buttonState;
}