13 , portStatusCallback(getCommandController(),
14 getName() +
"_port_status_callback",
15 "Tcl proc to call when an Sensor Kid port status is changed",
17 , acquireCallback(getCommandController(),
18 getName() +
"_acquire_callback",
19 "Tcl proc called to acquire analog data. "
20 "Input: port number (0-3). "
21 "Output: the value for that port (0-255).",
36 if ((port & 1) != 0)
return;
38 byte diff = prev ^ value;
50 mb4052_ana = getAnalog(value & 0x0C);
57 if ((diff & 0x01) && (value & 0x01)) {
59 if (mb4052_count > 0) --mb4052_count;
65 if ((port & 1) == 0) {
72 if (mb4052_count == 10) {
74 }
else if ((mb4052_count < 10) && (mb4052_count > 1)) {
75 return byte((mb4052_ana >> (mb4052_count - 2)) & 1);
84 return 0xFC | ((prev >> 5) & 0x02) | ((prev >> 7) & 0x01);
88byte SensorKid::getAnalog(
byte chi)
92 byte port = ((chi >> 1) & 2) | ((chi >> 3) & 1);
104 auto obj = acquireCallback.
execute(port);
107 if ((tmp < 0) || (tmp > 255)) {
110 result = narrow_cast<byte>(tmp);
112 }
catch (MSXException&
e) {
114 "Wrong result for callback function \"",
116 "\": ",
e.getMessage());
121void SensorKid::putPort(
byte data,
byte diff)
127 portStatusCallback.
execute(0, (data & 0x80) == 0);
131 portStatusCallback.
execute(1, (data & 0x40) == 0);
135template<
typename Archive>
138 ar.template serializeBase<MSXDevice>(*
this);
139 ar.serialize(
"prev", prev,
140 "mb4052_ana", mb4052_ana,
141 "mb4052_count", mb4052_count);
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.
CliComm & getCliComm() const
CommandController & getCommandController() const
EmuTime::param getCurrentTime() 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
std::string getName(KeyCode keyCode)
Translate key code to key name.
This file implemented 3 utility functions:
uint8_t byte
8 bit unsigned integer
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)