Mesen-X/Core/VsZapper.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

43 lines
No EOL
780 B
C++

#pragma once
#include "stdafx.h"
#include "Zapper.h"
class VsZapper : public Zapper
{
private:
uint32_t _stateBuffer = 0;
protected:
void StreamState(bool saving) override
{
Zapper::StreamState(saving);
Stream(_stateBuffer);
}
void RefreshStateBuffer() override
{
_stateBuffer = 0x10 | (IsLightFound() ? 0x40 : 0x00) | (IsPressed(Zapper::Buttons::Fire) ? 0x80 : 0x00);
}
public:
VsZapper(shared_ptr<Console> console, uint8_t port) : Zapper(console, port)
{
}
uint8_t ReadRAM(uint16_t addr) override
{
if(IsCurrentPort(addr)) {
StrobeProcessRead();
uint8_t returnValue = _stateBuffer & 0x01;
_stateBuffer >>= 1;
return returnValue;
}
return 0;
}
void WriteRAM(uint16_t addr, uint8_t value) override
{
StrobeProcessWrite(value);
}
};