2017-11-19 23:08:23 -05:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "SystemActionManager.h"
|
|
|
|
|
|
|
|
class VsSystemActionManager : public SystemActionManager
|
|
|
|
{
|
|
|
|
private:
|
2018-07-01 15:21:05 -04:00
|
|
|
static constexpr uint8_t InsertCoinFrameCount = 4;
|
2017-11-19 23:08:23 -05:00
|
|
|
|
|
|
|
uint8_t _needInsertCoin[2] = { 0, 0 };
|
|
|
|
bool _needServiceButton = false;
|
|
|
|
|
|
|
|
void ProcessInsertCoin(uint8_t port)
|
|
|
|
{
|
|
|
|
if(_needInsertCoin[port] > 0) {
|
|
|
|
_needInsertCoin[port]--;
|
|
|
|
SetBit(VsSystemActionManager::VsButtons::InsertCoin1 + port);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string GetKeyNames() override
|
|
|
|
{
|
|
|
|
return "RP12S";
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum VsButtons { InsertCoin1 = 2, InsertCoin2, ServiceButton };
|
|
|
|
|
|
|
|
VsSystemActionManager(std::shared_ptr<Console> console) : SystemActionManager(console)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t ReadRAM(uint16_t addr) override
|
|
|
|
{
|
|
|
|
uint8_t value = 0;
|
|
|
|
if(addr == 0x4016) {
|
|
|
|
if(IsPressed(VsSystemActionManager::VsButtons::InsertCoin1)) {
|
|
|
|
value |= 0x20;
|
|
|
|
}
|
|
|
|
if(IsPressed(VsSystemActionManager::VsButtons::InsertCoin2)) {
|
|
|
|
value |= 0x40;
|
|
|
|
}
|
|
|
|
if(IsPressed(VsSystemActionManager::VsButtons::ServiceButton)) {
|
|
|
|
value |= 0x04;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnAfterSetState() override
|
|
|
|
{
|
|
|
|
SystemActionManager::OnAfterSetState();
|
|
|
|
|
|
|
|
ProcessInsertCoin(0);
|
|
|
|
ProcessInsertCoin(1);
|
|
|
|
|
|
|
|
if(_needServiceButton) {
|
|
|
|
SetBit(VsSystemActionManager::VsButtons::ServiceButton);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void InsertCoin(uint8_t port)
|
|
|
|
{
|
|
|
|
_needInsertCoin[port] = VsSystemActionManager::InsertCoinFrameCount;
|
2018-01-08 20:11:11 -05:00
|
|
|
MessageManager::DisplayMessage("VS System", "CoinInsertedSlot", std::to_string(port + 1));
|
2017-11-19 23:08:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void SetServiceButtonState(bool pressed)
|
|
|
|
{
|
|
|
|
_needServiceButton = pressed;
|
|
|
|
}
|
|
|
|
};
|