mirror of
https://github.com/bsnes-emu/bsnes.git
synced 2025-02-23 22:52:34 +01:00
byuu says: Changelog: - fc/controller: added ControllerPort class; removed Peripherals class - md/controller/gamepad: removed X,Y,Z buttons since this isn't a 6-button controller - ms/controller: added ControllerPort class (not used in Game Gear mode); removed Peripherals class - pce/controller: added ControllerPort class; removed Peripherals class - processor/spc700: idle(address) is part of SMP class again, contains flag to detect mov (x)+ edge case - sfc/controller/super-scope,justifier: use CPU frequency instead of hard-coding NTSC frequency - sfc/cpu: move 4x8-bit SMP ports to SMP class - sfc/smp: move APU RAM to DSP class - sfc/smp: improved emulation of TEST registers bits 4-7 [information from nocash] - d4,d5 is RAM wait states (1,2,5,10) - d6,d7 is ROM/IO wait states (1,2,5,10) - sfc/smp: code cleanup to new style (order from lowest to highest bits; use .bit(s) functions) - sfc/smp: $00f8,$00f9 are P4/P5 auxiliary ports; named the registers better
59 lines
1.2 KiB
C++
59 lines
1.2 KiB
C++
#include <fc/fc.hpp>
|
|
|
|
namespace Famicom {
|
|
|
|
ControllerPort controllerPort1;
|
|
ControllerPort controllerPort2;
|
|
#include "gamepad/gamepad.cpp"
|
|
|
|
Controller::Controller(uint port) : port(port) {
|
|
if(!handle()) create(Controller::Enter, 1);
|
|
}
|
|
|
|
Controller::~Controller() {
|
|
scheduler.remove(*this);
|
|
}
|
|
|
|
auto Controller::Enter() -> void {
|
|
while(true) {
|
|
scheduler.synchronize();
|
|
if(controllerPort1.device->active()) controllerPort1.device->main();
|
|
if(controllerPort2.device->active()) controllerPort2.device->main();
|
|
}
|
|
}
|
|
|
|
auto Controller::main() -> void {
|
|
step(1);
|
|
synchronize(cpu);
|
|
}
|
|
|
|
//
|
|
|
|
auto ControllerPort::connect(uint deviceID) -> void {
|
|
if(!system.loaded()) return;
|
|
delete device;
|
|
|
|
switch(deviceID) { default:
|
|
case ID::Device::None: device = new Controller(port); break;
|
|
case ID::Device::Gamepad: device = new Gamepad(port); break;
|
|
}
|
|
|
|
cpu.peripherals.reset();
|
|
if(auto device = controllerPort1.device) cpu.peripherals.append(device);
|
|
if(auto device = controllerPort2.device) cpu.peripherals.append(device);
|
|
}
|
|
|
|
auto ControllerPort::power(uint port) -> void {
|
|
this->port = port;
|
|
}
|
|
|
|
auto ControllerPort::unload() -> void {
|
|
delete device;
|
|
device = nullptr;
|
|
}
|
|
|
|
auto ControllerPort::serialize(serializer& s) -> void {
|
|
}
|
|
|
|
}
|