15 getCommandController(),
"debugoutput",
16 "name of the file the debugdevice outputs to",
17 config.getChildData(
"filename",
"stdout"))
20 reset(EmuTime::dummy());
31 const auto& newName = fileNameSetting.
getString();
32 if (newName != fileNameString) {
36 switch (port & 0x01) {
38 switch ((value & 0x30) >> 4) {
44 modeParameter = value & 0x0F;
48 modeParameter = value & 0x03;
54 (*outputstrm) <<
'\n' << std::flush;
62 outputSingleByte(value, time);
65 outputMultiByte(value);
74 void DebugDevice::outputSingleByte(
byte value, EmuTime::param time)
76 if (modeParameter & 0x01) {
77 displayByte(value, HEX);
79 if (modeParameter & 0x02) {
80 displayByte(value, BIN);
82 if (modeParameter & 0x04) {
83 displayByte(value, DEC);
85 if (modeParameter & 0x08) {
86 (*outputstrm) <<
'\'';
87 byte tmp = ((value >=
' ') && (value != 127)) ? value :
'.';
88 displayByte(tmp, ASC);
89 (*outputstrm) <<
"' ";
91 Clock<3579545> zero(EmuTime::zero());
92 (*outputstrm) <<
"emutime: " << std::dec << zero.getTicksTill(time);
93 if ((modeParameter & 0x08) && ((value <
' ') || (value == 127))) {
94 displayByte(value, ASC);
96 (*outputstrm) <<
'\n' << std::flush;
99 void DebugDevice::outputMultiByte(
byte value)
101 DisplayType dispType = [&] {
102 switch (modeParameter) {
110 displayByte(value, dispType);
113 void DebugDevice::displayByte(
byte value, DisplayType type)
117 (*outputstrm) << std::hex << std::setw(2)
119 << int(value) <<
"h " << std::flush;
123 (*outputstrm) << ((value &
mask) ?
'1' :
'0');
125 (*outputstrm) <<
"b " << std::flush;
129 (*outputstrm) << std::dec << std::setw(3)
131 << int(value) <<
' ' << std::flush;
134 (*outputstrm).put(value);
135 (*outputstrm) << std::flush;
140 void DebugDevice::openOutput(std::string_view name)
142 fileNameString = name;
144 if (name ==
"stdout") {
145 outputstrm = &std::cout;
146 }
else if (name ==
"stderr") {
147 outputstrm = &std::cerr;
151 outputstrm = &debugOut;
155 static constexpr std::initializer_list<enum_string<DebugDevice::DebugMode>> debugModeInfo = {
163 template<
typename Archive>
166 ar.template serializeBase<MSXDevice>(*
this);
167 ar.serialize(
"mode", mode,
168 "modeParameter", modeParameter);
void reset(EmuTime::param time) override
This method is called on reset.
DebugDevice(const DeviceConfig &config)
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.
zstring_view getString() const noexcept
An MSXDevice is an emulated hardware component connected to the bus of the emulated MSX.
void openofstream(std::ofstream &stream, zstring_view filename)
Open an ofstream in a platform-independent manner.
string expandTilde(string path)
Expand the '~' character to the users home directory.
This file implemented 3 utility functions:
SERIALIZE_ENUM(CassettePlayer::State, stateInfo)
REGISTER_MSXDEVICE(ChakkariCopy, "ChakkariCopy")
uint16_t word
16 bit unsigned integer
constexpr nibble mask[4][13]
#define INSTANTIATE_SERIALIZE_METHODS(CLASS)