2016-06-22 23:23:08 +00:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "Zapper.h"
|
|
|
|
|
|
|
|
class VsZapper : public Zapper
|
|
|
|
{
|
|
|
|
private:
|
2016-07-30 21:27:14 +00:00
|
|
|
uint32_t _stateBuffer = 0;
|
2016-06-22 23:23:08 +00:00
|
|
|
|
|
|
|
protected:
|
2017-11-20 04:08:23 +00:00
|
|
|
void StreamState(bool saving) override
|
|
|
|
{
|
|
|
|
Zapper::StreamState(saving);
|
|
|
|
Stream(_stateBuffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
void RefreshStateBuffer() override
|
|
|
|
{
|
|
|
|
_stateBuffer = 0x10 | (IsLightFound() ? 0x40 : 0x00) | (IsPressed(Zapper::Buttons::Fire) ? 0x80 : 0x00);
|
|
|
|
}
|
2016-06-22 23:23:08 +00:00
|
|
|
|
|
|
|
public:
|
2017-11-20 04:08:23 +00:00
|
|
|
VsZapper(uint8_t port) : Zapper(port)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t ReadRAM(uint16_t addr) override
|
|
|
|
{
|
|
|
|
if(IsCurrentPort(addr)) {
|
|
|
|
uint8_t returnValue = _stateBuffer & 0x01;
|
|
|
|
_stateBuffer >>= 1;
|
|
|
|
StrobeProcessRead();
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2016-06-22 23:23:08 +00:00
|
|
|
|
2017-11-20 04:08:23 +00:00
|
|
|
void WriteRAM(uint16_t addr, uint8_t value) override
|
|
|
|
{
|
|
|
|
StrobeProcessWrite(value);
|
|
|
|
}
|
2016-06-22 23:23:08 +00:00
|
|
|
};
|