-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for the Japanese HPD-200 Paddle
This makes games requiring a Paddle, such as Megumi Rescue, playable with an analog stick, or using adapters USB adapters supporting the HPD-200 Paddle. "Prefer Japan" should be selected in tools->Boot Options before load otherwise the game will expect the "Export Paddle" which is not compatible.
- Loading branch information
Showing
6 changed files
with
65 additions
and
1 deletion.
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
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Paddle::Paddle(Node::Port parent) { | ||
node = parent->append<Node::Peripheral>("Paddle"); | ||
|
||
button = node->append<Node::Input::Button>("Button"); | ||
axis = node->append<Node::Input::Axis> ("X-Axis"); | ||
|
||
// 18kHz - As measured on real hardware | ||
Thread::create(18000, {&Paddle::main, this}); | ||
} | ||
|
||
Paddle::~Paddle() { | ||
Thread::destroy(); | ||
} | ||
|
||
auto Paddle::main() -> void { | ||
secondNibble = !secondNibble; | ||
|
||
Thread::step(1); | ||
Thread::synchronize(cpu); | ||
} | ||
|
||
auto Paddle::read() -> n7 { | ||
platform->input(button); | ||
platform->input(axis); | ||
|
||
n7 data; | ||
if (secondNibble) { | ||
data.bit(0,3) = value.bit(4,7); | ||
} else { | ||
// scale {-32768 ... +32767} to {0 ... 255 } | ||
value = (axis->value() + 32768.0) * 255.0 / 65535.0; | ||
data.bit(0,3) = value.bit(0,3); | ||
} | ||
|
||
data.bit(4) = !button->value(); | ||
data.bit(5) = secondNibble; | ||
data.bit(6) = 1; | ||
|
||
return data; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
struct Paddle : Controller, Thread { | ||
Node::Input::Axis axis; | ||
Node::Input::Button button; | ||
|
||
Paddle(Node::Port); | ||
~Paddle(); | ||
|
||
auto main() -> void; | ||
auto read() -> n7 override; | ||
|
||
private: | ||
n8 value; | ||
b1 secondNibble; | ||
}; |
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