forked from emu-russia/breaknes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,75 @@ | ||
// NES Controller simulator | ||
#include "pch.h" | ||
|
||
namespace IO | ||
{ | ||
NESController::NESController() | ||
{ | ||
states[(size_t)NESControllerState::Up].actuator_name = "Up"; | ||
states[(size_t)NESControllerState::Up].value = 0; | ||
states[(size_t)NESControllerState::Down].actuator_name = "Down"; | ||
states[(size_t)NESControllerState::Down].value = 0; | ||
states[(size_t)NESControllerState::Left].actuator_name = "Left"; | ||
states[(size_t)NESControllerState::Left].value = 0; | ||
states[(size_t)NESControllerState::Right].actuator_name = "Right"; | ||
states[(size_t)NESControllerState::Right].value = 0; | ||
states[(size_t)NESControllerState::Select].actuator_name = "Select"; | ||
states[(size_t)NESControllerState::Select].value = 0; | ||
states[(size_t)NESControllerState::Start].actuator_name = "Start"; | ||
states[(size_t)NESControllerState::Start].value = 0; | ||
states[(size_t)NESControllerState::B].actuator_name = "B"; | ||
states[(size_t)NESControllerState::B].value = 0; | ||
states[(size_t)NESControllerState::A].actuator_name = "A"; | ||
states[(size_t)NESControllerState::A].value = 0; | ||
} | ||
|
||
NESController::~NESController() | ||
{ | ||
} | ||
|
||
uint32_t NESController::GetID() | ||
{ | ||
return DeviceID::NESController; | ||
} | ||
|
||
std::string NESController::GetName() | ||
{ | ||
return "NES Controller"; | ||
} | ||
|
||
int NESController::GetIOStates() | ||
{ | ||
return (int)NESControllerState::Max; | ||
} | ||
|
||
std::string NESController::GetIOStateName(size_t io_state) | ||
{ | ||
if (io_state < (size_t)NESControllerState::Max) { | ||
return states[io_state].actuator_name; | ||
} | ||
else { | ||
return ""; | ||
} | ||
} | ||
|
||
void NESController::SetState(size_t io_state, uint32_t value) | ||
{ | ||
if (io_state < (size_t)NESControllerState::Max) { | ||
states[io_state].value = value; | ||
} | ||
} | ||
|
||
uint32_t NESController::GetState(size_t io_state) | ||
{ | ||
if (io_state < (size_t)NESControllerState::Max) { | ||
return states[io_state].value; | ||
} | ||
else { | ||
return 0; | ||
} | ||
} | ||
|
||
void NESController::sim(BaseLogic::TriState inputs[], BaseLogic::TriState outputs[]) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,35 @@ | ||
// NES Controller simulator | ||
#pragma once | ||
|
||
namespace IO | ||
{ | ||
enum class NESControllerState | ||
{ | ||
Up = 0, | ||
Down, | ||
Left, | ||
Right, | ||
Select, | ||
Start, | ||
B, | ||
A, | ||
Max, | ||
}; | ||
|
||
class NESController : public IODevice | ||
{ | ||
public: | ||
NESController(); | ||
virtual ~NESController(); | ||
|
||
virtual uint32_t GetID() override; | ||
virtual std::string GetName() override; | ||
virtual int GetIOStates() override; | ||
virtual std::string GetIOStateName(size_t io_state) override; | ||
|
||
virtual void SetState(size_t io_state, uint32_t value) override; | ||
virtual uint32_t GetState(size_t io_state) override; | ||
|
||
virtual void sim(BaseLogic::TriState inputs[], BaseLogic::TriState outputs[]) override; | ||
}; | ||
} |