2017-11-19 23:08:23 -05:00
|
|
|
#pragma once
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "SystemActionManager.h"
|
2018-07-07 20:50:31 -04:00
|
|
|
#include "Console.h"
|
2017-11-19 23:08:23 -05:00
|
|
|
|
|
|
|
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
|
|
|
|
2018-07-07 20:50:31 -04:00
|
|
|
bool _isDualSystem = false;
|
|
|
|
uint8_t _needInsertCoin[4] = { 0, 0, 0, 0 };
|
|
|
|
bool _needServiceButton[2] = { false, false };
|
2017-11-19 23:08:23 -05:00
|
|
|
|
|
|
|
void ProcessInsertCoin(uint8_t port)
|
|
|
|
{
|
|
|
|
if(_needInsertCoin[port] > 0) {
|
|
|
|
_needInsertCoin[port]--;
|
2018-07-07 20:50:31 -04:00
|
|
|
|
|
|
|
switch(port) {
|
|
|
|
case 0: SetBit(VsSystemActionManager::VsButtons::InsertCoin1); break;
|
|
|
|
case 1: SetBit(VsSystemActionManager::VsButtons::InsertCoin2); break;
|
|
|
|
case 2: SetBit(VsSystemActionManager::VsButtons::InsertCoin3); break;
|
|
|
|
case 3: SetBit(VsSystemActionManager::VsButtons::InsertCoin4); break;
|
|
|
|
}
|
2017-11-19 23:08:23 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
string GetKeyNames() override
|
|
|
|
{
|
2018-07-07 20:50:31 -04:00
|
|
|
return _isDualSystem ? "RP12S34ST" : "RP12S";
|
2017-11-19 23:08:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2018-07-07 20:50:31 -04:00
|
|
|
enum VsButtons { InsertCoin1 = 2, InsertCoin2, ServiceButton, InsertCoin3, InsertCoin4, ServiceButton2 };
|
2017-11-19 23:08:23 -05:00
|
|
|
|
|
|
|
VsSystemActionManager(std::shared_ptr<Console> console) : SystemActionManager(console)
|
|
|
|
{
|
2018-07-07 20:50:31 -04:00
|
|
|
_isDualSystem = console->IsDualSystem();
|
2017-11-19 23:08:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2018-07-07 20:50:31 -04:00
|
|
|
ProcessInsertCoin(2);
|
|
|
|
ProcessInsertCoin(3);
|
2017-11-19 23:08:23 -05:00
|
|
|
|
2018-07-07 20:50:31 -04:00
|
|
|
if(_needServiceButton[0]) {
|
2017-11-19 23:08:23 -05:00
|
|
|
SetBit(VsSystemActionManager::VsButtons::ServiceButton);
|
|
|
|
}
|
2018-07-07 20:50:31 -04:00
|
|
|
if(_needServiceButton[1]) {
|
|
|
|
SetBit(VsSystemActionManager::VsButtons::ServiceButton2);
|
|
|
|
}
|
2017-11-19 23:08:23 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void InsertCoin(uint8_t port)
|
|
|
|
{
|
2018-07-07 20:50:31 -04:00
|
|
|
if(port < 4) {
|
2020-01-25 13:40:24 -05:00
|
|
|
_console->Pause();
|
2018-07-07 20:50:31 -04:00
|
|
|
_needInsertCoin[port] = VsSystemActionManager::InsertCoinFrameCount;
|
|
|
|
MessageManager::DisplayMessage("VS System", "CoinInsertedSlot", std::to_string(port + 1));
|
2020-01-25 13:40:24 -05:00
|
|
|
_console->Resume();
|
2018-07-07 20:50:31 -04:00
|
|
|
}
|
2017-11-19 23:08:23 -05:00
|
|
|
}
|
|
|
|
|
2018-07-07 20:50:31 -04:00
|
|
|
void SetServiceButtonState(int consoleId, bool pressed)
|
2017-11-19 23:08:23 -05:00
|
|
|
{
|
2020-01-25 13:40:24 -05:00
|
|
|
_console->Pause();
|
2018-07-07 20:50:31 -04:00
|
|
|
_needServiceButton[consoleId] = pressed;
|
2020-01-25 13:40:24 -05:00
|
|
|
_console->Resume();
|
2017-11-19 23:08:23 -05:00
|
|
|
}
|
|
|
|
};
|