1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-29 00:29:34 +00:00

Performs the trivial part of wiring up the Macintosh mouse.

SCC still to go.
This commit is contained in:
Thomas Harte 2019-06-11 19:52:37 -04:00
parent 109953ef49
commit ebd59f4dd3
2 changed files with 30 additions and 14 deletions

View File

@ -51,6 +51,27 @@ class QuadratureMouse: public Mouse {
Outputs.
*/
/*!
Removes a single step from the current accumulated mouse movement;
the step removed will henceforth be queriable via get_step.
*/
void prepare_step() {
for(int axis = 0; axis < 2; ++axis) {
const int axis_value = axes_[axis];
if(!axis_value) {
step_[axis] = 0;
} else {
if(axis_value > 0) {
-- axes_[axis];
step_[axis] = 1;
} else {
++ axes_[axis];
step_[axis] = -1;
}
}
}
}
/*!
Gets and removes a single step from the current accumulated mouse
movement for @c axis axis 0 is x, axis 1 is y.
@ -59,15 +80,7 @@ class QuadratureMouse: public Mouse {
negative movement, +1 if there is outstanding positive movement.
*/
int get_step(int axis) {
if(!axes_[axis]) return 0;
if(axes_[axis] > 0) {
-- axes_[axis];
return 1;
} else {
++ axes_[axis];
return -1;
}
return step_[axis];
}
/*!
@ -81,6 +94,7 @@ class QuadratureMouse: public Mouse {
int number_of_buttons_ = 0;
std::atomic<int> button_flags_;
std::atomic<int> axes_[2];
int step_[2];
};

View File

@ -57,7 +57,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
iwm_(CLOCK_RATE),
video_(ram_, audio_, drive_speed_accumulator_),
via_(via_port_handler_),
via_port_handler_(*this, clock_, keyboard_, video_, audio_, iwm_),
via_port_handler_(*this, clock_, keyboard_, video_, audio_, iwm_, mouse_),
drives_{
{CLOCK_RATE, model >= Analyser::Static::Macintosh::Target::Model::Mac512ke},
{CLOCK_RATE, model >= Analyser::Static::Macintosh::Target::Model::Mac512ke}
@ -370,8 +370,8 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
class VIAPortHandler: public MOS::MOS6522::PortHandler {
public:
VIAPortHandler(ConcreteMachine &machine, RealTimeClock &clock, Keyboard &keyboard, Video &video, DeferredAudio &audio, IWM &iwm) :
machine_(machine), clock_(clock), keyboard_(keyboard), video_(video), audio_(audio), iwm_(iwm) {}
VIAPortHandler(ConcreteMachine &machine, RealTimeClock &clock, Keyboard &keyboard, Video &video, DeferredAudio &audio, IWM &iwm, Inputs::QuadratureMouse &mouse) :
machine_(machine), clock_(clock), keyboard_(keyboard), video_(video), audio_(audio), iwm_(iwm), mouse_(mouse) {}
using Port = MOS::MOS6522::Port;
using Line = MOS::MOS6522::Line;
@ -431,10 +431,11 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
case Port::B:
return
0x08 | // Mouse button not down.
(mouse_.get_button_mask() & 1) ? 0x00 : 0x08 |
(mouse_.get_step(1) > 0) ? 0x00 : 0x10 |
(mouse_.get_step(0) > 0) ? 0x00 : 0x20 |
(clock_.get_data() ? 0x02 : 0x00) |
(video_.is_outputting() ? 0x00 : 0x40);
// TODO: mouse button, y2, x2
}
}
@ -466,6 +467,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
Video &video_;
DeferredAudio &audio_;
IWM &iwm_;
Inputs::QuadratureMouse &mouse_;
};
CPU::MC68000::Processor<ConcreteMachine, true> mc68000_;