mirror of
https://github.com/flyinghead/flycast.git
synced 2026-11-08 17:12:25 -10:00
Replace naomi:WCCFSlave by naomi:WCCFNode to set node number for projectors and satellites. Handle socket to port 59200 locally to allow connecting from the same IP and bypass wccfd completely.
113 lines
2.6 KiB
C++
113 lines
2.6 KiB
C++
/*
|
|
Copyright 2021 flyinghead
|
|
|
|
This file is part of Flycast.
|
|
|
|
Flycast is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Flycast is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "net_handshake.h"
|
|
#include "cfg/option.h"
|
|
#include "ggpo.h"
|
|
#include "naomi_network.h"
|
|
#include "null_modem.h"
|
|
#include "hw/naomi/naomi_flashrom.h"
|
|
|
|
NetworkHandshake *NetworkHandshake::instance;
|
|
|
|
class GGPONetworkHandshake : public NetworkHandshake
|
|
{
|
|
public:
|
|
std::future<bool> start() override {
|
|
return ggpo::startNetwork();
|
|
}
|
|
|
|
void stop() override {
|
|
ggpo::stopSession();
|
|
}
|
|
|
|
bool canStartNow() override { return false; }
|
|
void startNow() override {}
|
|
};
|
|
|
|
class NaomiNetworkHandshake : public NetworkHandshake
|
|
{
|
|
public:
|
|
NaomiNetworkHandshake() {
|
|
auto max = naomiNetworkMaxNodes();
|
|
naomiNetwork.setMaxSlots(max.first, max.second);
|
|
}
|
|
std::future<bool> start() override {
|
|
return naomiNetwork.startNetworkAsync();
|
|
}
|
|
|
|
void stop() override {
|
|
naomiNetwork.shutdown();
|
|
}
|
|
|
|
bool canStartNow() override {
|
|
return config::ActAsServer;
|
|
}
|
|
|
|
void startNow() override {
|
|
naomiNetwork.startNow();
|
|
}
|
|
};
|
|
|
|
void NetworkHandshake::init()
|
|
{
|
|
if (settings.platform.isArcade())
|
|
setNaomiNetworkConfig(-1, 0);
|
|
|
|
if (config::GGPOEnable) {
|
|
instance = new GGPONetworkHandshake();
|
|
}
|
|
else if (naomiNetworkSupported()) {
|
|
instance = new NaomiNetworkHandshake();
|
|
}
|
|
else if (config::BattleCableEnable)
|
|
{
|
|
if (settings.content.gameId == "MAXIMUM SPEED")
|
|
configure_maxspeed_flash(true, config::ActAsServer);
|
|
else if (settings.content.gameId.substr(0, 4) == "WCCF")
|
|
setNaomiNetworkConfig(config::ActAsServer ? 0 : 1, 8);
|
|
instance = new BattleCableHandshake();
|
|
}
|
|
else
|
|
{
|
|
#ifndef LIBRETRO
|
|
if (settings.content.gameId.substr(0, 4) == "WCCF")
|
|
setNaomiNetworkConfig(config::loadInt("naomi", "WCCFNode", -1), 8);
|
|
#endif
|
|
instance = nullptr;
|
|
}
|
|
}
|
|
|
|
void NetworkHandshake::term()
|
|
{
|
|
if (instance != nullptr)
|
|
{
|
|
instance->stop();
|
|
delete instance;
|
|
instance = nullptr;
|
|
}
|
|
}
|
|
|
|
bool naomiNetworkSupported() {
|
|
return naomiNetworkMaxNodes().first > 1;
|
|
}
|
|
|
|
u16 defaultNaomiServerPort() {
|
|
return NaomiNetwork::SERVER_PORT;
|
|
}
|