15 , portStatusCallback(getCommandController(),
16 getName() +
"_port_status_callback",
17 "Tcl proc to call when an Sensor Kid port status is changed",
19 , acquireCallback(getCommandController(),
20 getName() +
"_acquire_callback",
21 "Tcl proc called to acquire analog data. "
22 "Input: port number (0-3). "
23 "Output: the value for that port (0-255).",
38 if ((port & 1) != 0)
return;
40 byte diff = prev ^ value;
52 mb4052_ana = getAnalog(value & 0x0C);
59 if ((diff & 0x01) && (value & 0x01)) {
61 if (mb4052_count > 0) --mb4052_count;
67 if ((port & 1) == 0) {
74 if (mb4052_count == 10) {
76 }
else if ((mb4052_count < 10) && (mb4052_count > 1)) {
77 return byte((mb4052_ana >> (mb4052_count - 2)) & 1);
86 return 0xFC | ((prev >> 5) & 0x02) | ((prev >> 7) & 0x01);
90byte SensorKid::getAnalog(
byte chi)
const
94 byte port = ((chi >> 1) & 2) | ((chi >> 3) & 1);
106 auto obj = acquireCallback.
execute(port);
109 if ((tmp < 0) || (tmp > 255)) {
112 result = narrow_cast<byte>(tmp);
114 }
catch (MSXException& e) {
116 "Wrong result for callback function \"",
118 "\": ",
e.getMessage());
123void SensorKid::putPort(
byte data,
byte diff)
const
129 portStatusCallback.
execute(0, (data & 0x80) == 0);
133 portStatusCallback.
execute(1, (data & 0x40) == 0);
137template<
typename Archive>
140 ar.template serializeBase<MSXDevice>(*
this);
141 ar.serialize(
"prev", prev,
142 "mb4052_ana", mb4052_ana,
143 "mb4052_count", mb4052_count);
#define REGISTER_MSXDEVICE(CLASS, NAME)
std::string_view getFullName() const
void printWarning(std::string_view message)
virtual Interpreter & getInterpreter()=0
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
CommandController & getCommandController() const
EmuTime::param getCurrentTime() const
MSXCliComm & getCliComm() const
byte readIO(word port, EmuTime::param time) override
Read a byte from an IO port at a certain time from this device.
void reset(EmuTime::param time) override
This method is called on reset.
void serialize(Archive &ar, unsigned version)
void writeIO(word port, byte value, EmuTime::param time) override
Write a byte to a given IO port at a certain time to this device.
SensorKid(const DeviceConfig &config)
TclObject execute() const
StringSetting & getSetting() const
int getInt(Interpreter &interp) const
This file implemented 3 utility functions:
uint8_t byte
8 bit unsigned integer
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)