Mesen/Core/FourScore.h
Sour c3b1b3effc Input: Reading the controller while the strobe signal is high should always return the state of button A
Fixed an edge case that occurred when setting strobe bit after reading $4016 once and then reading $4016 again
2019-12-23 20:47:10 -05:00

49 lines
1 KiB
C++

#pragma once
#include "BaseControlDevice.h"
class FourScore : public BaseControlDevice
{
private:
uint32_t _signature4016 = 0;
uint32_t _signature4017 = 0;
protected:
void StreamState(bool saving) override
{
BaseControlDevice::StreamState(saving);
Stream(_signature4016, _signature4017);
}
void RefreshStateBuffer() override
{
//Signature for port 0 = 0x10, reversed bit order => 0x08
//Signature for port 1 = 0x20, reversed bit order => 0x04
_signature4016 = (0x08 << 16);
_signature4017 = (0x04 << 16);
}
public:
FourScore(shared_ptr<Console> console) : BaseControlDevice(console, BaseControlDevice::ExpDevicePort)
{
}
uint8_t ReadRAM(uint16_t addr) override
{
StrobeProcessRead();
uint8_t output = 0;
if(addr == 0x4016) {
output = _signature4016 & 0x01;
_signature4016 >>= 1;
} else if(addr == 0x4017) {
output = _signature4017 & 0x01;
_signature4017 >>= 1;
}
return output;
}
void WriteRAM(uint16_t addr, uint8_t value) override
{
StrobeProcessWrite(value);
}
};