mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 23:52:26 +00:00
Merge pull request #596 from TomHarte/MSXLogging
Eliminates dangling uses of `printf`.
This commit is contained in:
commit
42d8d187b3
@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
#include "MultiMachine.hpp"
|
||||
#include "../../../Outputs/Log.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -74,14 +75,12 @@ bool MultiMachine::would_collapse(const std::vector<std::unique_ptr<DynamicMachi
|
||||
|
||||
void MultiMachine::multi_crt_did_run_machines() {
|
||||
std::lock_guard<decltype(machines_mutex_)> machines_lock(machines_mutex_);
|
||||
#ifdef DEBUG
|
||||
#ifndef NDEBUG
|
||||
for(const auto &machine: machines_) {
|
||||
CRTMachine::Machine *crt = machine->crt_machine();
|
||||
printf("%0.2f ", crt->get_confidence());
|
||||
crt->print_type();
|
||||
printf("; ");
|
||||
LOGNBR(PADHEX(2) << crt->get_confidence() << " " << crt->debug_type() << "; ");
|
||||
}
|
||||
printf("\n");
|
||||
LOGNBR(std::endl);
|
||||
#endif
|
||||
|
||||
DynamicMachine *front = machines_.front().get();
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "Tape.hpp"
|
||||
#include "Target.hpp"
|
||||
#include "../../../Storage/Cartridge/Encodings/CommodoreROM.hpp"
|
||||
#include "../../../Outputs/Log.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
@ -91,7 +92,7 @@ Analyser::Static::TargetList Analyser::Static::Commodore::GetTargets(const Media
|
||||
// make a first guess based on loading address
|
||||
switch(files.front().starting_address) {
|
||||
default:
|
||||
printf("Starting address %04x?\n", files.front().starting_address);
|
||||
LOG("Unrecognised loading address for Commodore program: " << PADHEX(4) << files.front().starting_address);
|
||||
case 0x1001:
|
||||
target->memory_model = Target::MemoryModel::Unexpanded;
|
||||
break;
|
||||
|
@ -123,9 +123,9 @@ template <class T> class MOS6522: public MOS6522Base {
|
||||
inline void reevaluate_interrupts();
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#include "Implementation/6522Implementation.hpp"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _522_hpp */
|
||||
|
@ -6,6 +6,11 @@
|
||||
// Copyright 2017 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "../../../Outputs/Log.hpp"
|
||||
|
||||
namespace MOS {
|
||||
namespace MOS6522 {
|
||||
|
||||
template <typename T> void MOS6522<T>::set_register(int address, uint8_t value) {
|
||||
address &= 0xf;
|
||||
switch(address) {
|
||||
@ -61,20 +66,19 @@ template <typename T> void MOS6522<T>::set_register(int address, uint8_t value)
|
||||
registers_.auxiliary_control = value;
|
||||
break;
|
||||
case 0xc:
|
||||
// printf("Peripheral control %02x\n", value);
|
||||
registers_.peripheral_control = value;
|
||||
|
||||
// TODO: simplify below; trying to avoid improper logging of unimplemented warnings in input mode
|
||||
if(value & 0x08) {
|
||||
switch(value & 0x0e) {
|
||||
default: printf("Unimplemented control line mode %d\n", (value >> 1)&7); break;
|
||||
default: LOG("Unimplemented control line mode " << int((value >> 1)&7)); break;
|
||||
case 0x0c: bus_handler_.set_control_line_output(Port::A, Line::Two, false); break;
|
||||
case 0x0e: bus_handler_.set_control_line_output(Port::A, Line::Two, true); break;
|
||||
}
|
||||
}
|
||||
if(value & 0x80) {
|
||||
switch(value & 0xe0) {
|
||||
default: printf("Unimplemented control line mode %d\n", (value >> 5)&7); break;
|
||||
default: LOG("Unimplemented control line mode " << int((value >> 5)&7)); break;
|
||||
case 0xc0: bus_handler_.set_control_line_output(Port::B, Line::Two, false); break;
|
||||
case 0xe0: bus_handler_.set_control_line_output(Port::B, Line::Two, true); break;
|
||||
}
|
||||
@ -157,3 +161,6 @@ template <typename T> void MOS6522<T>::reevaluate_interrupts() {
|
||||
bus_handler_.set_interrupt_status(new_interrupt_status);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include "../../Outputs/Log.hpp"
|
||||
|
||||
using namespace TI::TMS;
|
||||
|
||||
@ -591,7 +592,6 @@ void TMS9918::set_register(int address, uint8_t value) {
|
||||
case 8:
|
||||
if(is_sega_vdp(personality_)) {
|
||||
master_system_.horizontal_scroll = low_write_;
|
||||
// printf("Set to %d at %d, %d\n", low_write_, row_, column_);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -608,7 +608,7 @@ void TMS9918::set_register(int address, uint8_t value) {
|
||||
break;
|
||||
|
||||
default:
|
||||
// printf("Unknown TMS write: %d to %d\n", low_write_, value);
|
||||
LOG("Unknown TMS write: " << int(low_write_) << " to " << int(value));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
|
@ -42,7 +42,7 @@ class Machine {
|
||||
|
||||
/// @returns The confidence that this machine is running content it understands.
|
||||
virtual float get_confidence() { return 0.5f; }
|
||||
virtual void print_type() {}
|
||||
virtual std::string debug_type() { return ""; }
|
||||
|
||||
/// Runs the machine for @c duration seconds.
|
||||
virtual void run_for(Time::Seconds duration) {
|
||||
|
@ -170,7 +170,6 @@ void SerialPortVIA::set_port_output(MOS::MOS6522::Port port, uint8_t value, uint
|
||||
attention_acknowledge_level_ = !(value&0x10);
|
||||
data_level_output_ = (value&0x02);
|
||||
|
||||
// printf("[C1540] %s output is %s\n", StringForLine(::Commodore::Serial::Line::Clock), value ? "high" : "low");
|
||||
serialPort->set_output(::Commodore::Serial::Line::Clock, static_cast<::Commodore::Serial::LineLevel>(!(value&0x08)));
|
||||
update_data_line();
|
||||
}
|
||||
@ -178,8 +177,6 @@ void SerialPortVIA::set_port_output(MOS::MOS6522::Port port, uint8_t value, uint
|
||||
}
|
||||
|
||||
void SerialPortVIA::set_serial_line_state(::Commodore::Serial::Line line, bool value) {
|
||||
// printf("[C1540] %s input is %s\n", StringForLine(line), value ? "high" : "low");
|
||||
|
||||
switch(line) {
|
||||
default: break;
|
||||
case ::Commodore::Serial::Line::Data: port_b_ = (port_b_ & ~0x01) | (value ? 0x00 : 0x01); break;
|
||||
@ -200,7 +197,6 @@ void SerialPortVIA::set_serial_port(const std::shared_ptr<::Commodore::Serial::P
|
||||
void SerialPortVIA::update_data_line() {
|
||||
std::shared_ptr<::Commodore::Serial::Port> serialPort = serial_port_.lock();
|
||||
if(serialPort) {
|
||||
// printf("[C1540] %s output is %s\n", StringForLine(::Commodore::Serial::Line::Data), (!data_level_output_ && (attention_level_input_ != attention_acknowledge_level_)) ? "high" : "low");
|
||||
// "ATN (Attention) is an input on pin 3 of P2 and P3 that is sensed at PB7 and CA1 of UC3 after being inverted by UA1"
|
||||
serialPort->set_output(::Commodore::Serial::Line::Data,
|
||||
static_cast<::Commodore::Serial::LineLevel>(!data_level_output_ && (attention_level_input_ != attention_acknowledge_level_)));
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "SerialBus.hpp"
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
using namespace Commodore::Serial;
|
||||
|
||||
@ -49,8 +50,6 @@ void Bus::set_line_output_did_change(Line line) {
|
||||
}
|
||||
}
|
||||
|
||||
// printf("[Bus] %s is %s\n", StringForLine(line), new_line_level ? "high" : "low");
|
||||
|
||||
// post an update only if one occurred
|
||||
if(new_line_level != line_levels_[line]) {
|
||||
line_levels_[line] = new_line_level;
|
||||
@ -69,7 +68,7 @@ void Bus::set_line_output_did_change(Line line) {
|
||||
void DebugPort::set_input(Line line, LineLevel value) {
|
||||
input_levels_[line] = value;
|
||||
|
||||
printf("[Bus] %s is %s\n", StringForLine(line), value ? "high" : "low");
|
||||
std::cout << "[Bus] " << StringForLine(line) << " is " << (value ? "high" : "low");
|
||||
if(!incoming_count_) {
|
||||
incoming_count_ = (!input_levels_[Line::Clock] && !input_levels_[Line::Data]) ? 8 : 0;
|
||||
} else {
|
||||
@ -77,6 +76,6 @@ void DebugPort::set_input(Line line, LineLevel value) {
|
||||
incoming_byte_ = (incoming_byte_ >> 1) | (input_levels_[Line::Data] ? 0x80 : 0x00);
|
||||
}
|
||||
incoming_count_--;
|
||||
if(incoming_count_ == 0) printf("[Bus] Observed %02x\n", incoming_byte_);
|
||||
if(incoming_count_ == 0) std::cout << "[Bus] Observed value " << std::hex << int(incoming_byte_);
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "../../../Components/6522/6522.hpp"
|
||||
|
||||
#include "../../../ClockReceiver/ForceInline.hpp"
|
||||
#include "../../../Outputs/Log.hpp"
|
||||
|
||||
#include "../../../Storage/Tape/Parsers/Commodore.hpp"
|
||||
|
||||
@ -526,12 +527,12 @@ class ConcreteMachine:
|
||||
const uint16_t tape_buffer_pointer = static_cast<uint16_t>(ram_[0xb2]) | static_cast<uint16_t>(ram_[0xb3] << 8);
|
||||
header->serialise(&ram_[tape_buffer_pointer], 0x8000 - tape_buffer_pointer);
|
||||
hold_tape_ = true;
|
||||
printf("Found header\n");
|
||||
LOG("Vic-20: Found header");
|
||||
} else {
|
||||
// no header found, so pretend this hack never interceded
|
||||
tape_->get_tape()->set_offset(tape_position);
|
||||
hold_tape_ = false;
|
||||
printf("Didn't find header\n");
|
||||
LOG("Vic-20: Didn't find header");
|
||||
}
|
||||
|
||||
// clear status and the verify flag
|
||||
@ -572,11 +573,11 @@ class ConcreteMachine:
|
||||
m6502_.set_value_of_register(CPU::MOS6502::Register::ProgramCounter, 0xfccf);
|
||||
*value = 0xea; // i.e. NOP implied
|
||||
hold_tape_ = true;
|
||||
printf("Found data\n");
|
||||
LOG("Vic-20: Found data");
|
||||
} else {
|
||||
tape_->get_tape()->set_offset(tape_position);
|
||||
hold_tape_ = false;
|
||||
printf("Didn't find data\n");
|
||||
LOG("Vic-20: Didn't find data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,6 @@ class ASCII16kbROMSlotHandler: public ROMSlotHandler {
|
||||
map_(map), slot_(slot) {}
|
||||
|
||||
void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override {
|
||||
// printf("A16 %04x ", address);
|
||||
switch(address >> 11) {
|
||||
default:
|
||||
if(pc_is_outside_bios) confidence_counter_.add_miss();
|
||||
@ -40,8 +39,8 @@ class ASCII16kbROMSlotHandler: public ROMSlotHandler {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void print_type() override {
|
||||
printf("A16");
|
||||
virtual std::string debug_type() override {
|
||||
return "A16";
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -20,7 +20,6 @@ class ASCII8kbROMSlotHandler: public ROMSlotHandler {
|
||||
map_(map), slot_(slot) {}
|
||||
|
||||
void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override {
|
||||
// printf("A8 %04x ", address);
|
||||
switch(address >> 11) {
|
||||
default:
|
||||
if(pc_is_outside_bios) confidence_counter_.add_miss();
|
||||
@ -52,8 +51,8 @@ class ASCII8kbROMSlotHandler: public ROMSlotHandler {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void print_type() override {
|
||||
printf("A8");
|
||||
virtual std::string debug_type() override {
|
||||
return "A8";
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -20,7 +20,6 @@ class KonamiROMSlotHandler: public ROMSlotHandler {
|
||||
map_(map), slot_(slot) {}
|
||||
|
||||
void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override {
|
||||
// printf("K %04x[%c]\n", address, pc_is_outside_bios ? '.' : '+');
|
||||
switch(address >> 13) {
|
||||
default:
|
||||
if(pc_is_outside_bios) confidence_counter_.add_miss();
|
||||
@ -46,8 +45,8 @@ class KonamiROMSlotHandler: public ROMSlotHandler {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void print_type() override {
|
||||
printf("K");
|
||||
virtual std::string debug_type() override {
|
||||
return "K";
|
||||
}
|
||||
private:
|
||||
MSX::MemoryMap &map_;
|
||||
|
@ -21,7 +21,6 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler {
|
||||
map_(map), slot_(slot), scc_(scc) {}
|
||||
|
||||
void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override {
|
||||
// printf("KSCC %04x ", address);
|
||||
switch(address >> 11) {
|
||||
default:
|
||||
if(pc_is_outside_bios) confidence_counter_.add_miss();
|
||||
@ -76,8 +75,8 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler {
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
virtual void print_type() override {
|
||||
printf("KSCC");
|
||||
virtual std::string debug_type() override {
|
||||
return "KSCC";
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "../MediaTarget.hpp"
|
||||
#include "../KeyboardMachine.hpp"
|
||||
|
||||
#include "../../Outputs/Log.hpp"
|
||||
#include "../../Outputs/Speaker/Implementation/CompoundSource.hpp"
|
||||
#include "../../Outputs/Speaker/Implementation/LowpassSpeaker.hpp"
|
||||
#include "../../Outputs/Speaker/Implementation/SampleSource.hpp"
|
||||
@ -295,10 +296,11 @@ class ConcreteMachine:
|
||||
return 0.5f;
|
||||
}
|
||||
|
||||
void print_type() override {
|
||||
std::string debug_type() override {
|
||||
if(memory_slots_[1].handler) {
|
||||
memory_slots_[1].handler->print_type();
|
||||
return "MSX:" + memory_slots_[1].handler->debug_type();
|
||||
}
|
||||
return "MSX";
|
||||
}
|
||||
|
||||
bool insert_media(const Analyser::Static::Media &media) override {
|
||||
@ -719,14 +721,14 @@ class ConcreteMachine:
|
||||
// b0-b3: keyboard line
|
||||
machine_.set_keyboard_line(value & 0xf);
|
||||
} break;
|
||||
default: printf("What what what what?\n"); break;
|
||||
default: LOG("Unrecognised: MSX set 8255 output port " << port << " to value " << PADHEX(2) << value); break;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t get_value(int port) {
|
||||
if(port == 1) {
|
||||
return machine_.read_keyboard();
|
||||
} else printf("What what?\n");
|
||||
} else LOG("MSX attempted to read from 8255 port " << port);
|
||||
return 0xff;
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
/*
|
||||
Design assumptions:
|
||||
@ -71,7 +72,8 @@ class ROMSlotHandler {
|
||||
return confidence_counter_.get_confidence();
|
||||
}
|
||||
|
||||
virtual void print_type() {
|
||||
virtual std::string debug_type() {
|
||||
return "";
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -456,7 +456,7 @@ int main(int argc, char *argv[]) {
|
||||
400, 300,
|
||||
SDL_WINDOW_OPENGL | SDL_WINDOW_RESIZABLE);
|
||||
|
||||
SDL_GLContext gl_context;
|
||||
SDL_GLContext gl_context = nullptr;
|
||||
if(window) {
|
||||
gl_context = SDL_GL_CreateContext(window);
|
||||
}
|
||||
|
@ -19,9 +19,9 @@
|
||||
|
||||
#else
|
||||
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <ios>
|
||||
#include <iomanip>
|
||||
|
||||
#define PADHEX(n) std::hex << std::setw(n) << std::right << std::setfill('0')
|
||||
#define PADDEC(n) std::dec << std::setw(n) << std::right << std::setfill('0')
|
||||
|
@ -52,7 +52,6 @@ class ConcreteAllRAMProcessor: public AllRAMProcessor, public BusHandler {
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("???\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "TZX.hpp"
|
||||
|
||||
#include "CSW.hpp"
|
||||
#include "../../../Outputs/Log.hpp"
|
||||
|
||||
using namespace Storage::Tape;
|
||||
|
||||
@ -91,7 +92,7 @@ void TZX::get_next_pulses() {
|
||||
default:
|
||||
// In TZX each chunk has a different way of stating or implying its length,
|
||||
// so there is no route past an unimplemented chunk.
|
||||
printf("!!Unknown %02x!!", chunk_id);
|
||||
LOG("Unknown TZX chunk: " << PADHEX(4) << chunk_id);
|
||||
set_is_at_end(true);
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user