mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-23 03:29:04 +00:00
Performs the trivial part of wiring up the Macintosh mouse.
SCC still to go.
This commit is contained in:
parent
109953ef49
commit
ebd59f4dd3
@ -51,6 +51,27 @@ class QuadratureMouse: public Mouse {
|
|||||||
Outputs.
|
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
|
Gets and removes a single step from the current accumulated mouse
|
||||||
movement for @c axis — axis 0 is x, axis 1 is y.
|
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.
|
negative movement, +1 if there is outstanding positive movement.
|
||||||
*/
|
*/
|
||||||
int get_step(int axis) {
|
int get_step(int axis) {
|
||||||
if(!axes_[axis]) return 0;
|
return step_[axis];
|
||||||
|
|
||||||
if(axes_[axis] > 0) {
|
|
||||||
-- axes_[axis];
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
++ axes_[axis];
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -81,6 +94,7 @@ class QuadratureMouse: public Mouse {
|
|||||||
int number_of_buttons_ = 0;
|
int number_of_buttons_ = 0;
|
||||||
std::atomic<int> button_flags_;
|
std::atomic<int> button_flags_;
|
||||||
std::atomic<int> axes_[2];
|
std::atomic<int> axes_[2];
|
||||||
|
int step_[2];
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
|
|||||||
iwm_(CLOCK_RATE),
|
iwm_(CLOCK_RATE),
|
||||||
video_(ram_, audio_, drive_speed_accumulator_),
|
video_(ram_, audio_, drive_speed_accumulator_),
|
||||||
via_(via_port_handler_),
|
via_(via_port_handler_),
|
||||||
via_port_handler_(*this, clock_, keyboard_, video_, audio_, iwm_),
|
via_port_handler_(*this, clock_, keyboard_, video_, audio_, iwm_, mouse_),
|
||||||
drives_{
|
drives_{
|
||||||
{CLOCK_RATE, model >= Analyser::Static::Macintosh::Target::Model::Mac512ke},
|
{CLOCK_RATE, model >= Analyser::Static::Macintosh::Target::Model::Mac512ke},
|
||||||
{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 {
|
class VIAPortHandler: public MOS::MOS6522::PortHandler {
|
||||||
public:
|
public:
|
||||||
VIAPortHandler(ConcreteMachine &machine, RealTimeClock &clock, Keyboard &keyboard, Video &video, DeferredAudio &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) {}
|
machine_(machine), clock_(clock), keyboard_(keyboard), video_(video), audio_(audio), iwm_(iwm), mouse_(mouse) {}
|
||||||
|
|
||||||
using Port = MOS::MOS6522::Port;
|
using Port = MOS::MOS6522::Port;
|
||||||
using Line = MOS::MOS6522::Line;
|
using Line = MOS::MOS6522::Line;
|
||||||
@ -431,10 +431,11 @@ template <Analyser::Static::Macintosh::Target::Model model> class ConcreteMachin
|
|||||||
|
|
||||||
case Port::B:
|
case Port::B:
|
||||||
return
|
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) |
|
(clock_.get_data() ? 0x02 : 0x00) |
|
||||||
(video_.is_outputting() ? 0x00 : 0x40);
|
(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_;
|
Video &video_;
|
||||||
DeferredAudio &audio_;
|
DeferredAudio &audio_;
|
||||||
IWM &iwm_;
|
IWM &iwm_;
|
||||||
|
Inputs::QuadratureMouse &mouse_;
|
||||||
};
|
};
|
||||||
|
|
||||||
CPU::MC68000::Processor<ConcreteMachine, true> mc68000_;
|
CPU::MC68000::Processor<ConcreteMachine, true> mc68000_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user