1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00
CLK/Machines/Apple/AppleIIgs/ADB.hpp
Thomas Harte c8beb59172 Attempts properly to track ADB bus activity.
Output is not yet a valid ADB stream. Work to do.
2021-01-25 17:43:22 -05:00

83 lines
1.8 KiB
C++

//
// ADB.hpp
// Clock Signal
//
// Created by Thomas Harte on 31/10/2020.
// Copyright © 2020 Thomas Harte. All rights reserved.
//
#ifndef Apple_IIgs_ADB_hpp
#define Apple_IIgs_ADB_hpp
#include <cstdint>
#include <vector>
#include "../../../InstructionSets/M50740/Executor.hpp"
namespace Apple {
namespace IIgs {
namespace ADB {
class GLU: public InstructionSet::M50740::PortHandler {
public:
GLU();
// Behaviour varies slightly between the controller shipped with ROM01 machines
// and that shipped with ROM03 machines; use this to set the desired behaviour.
void set_is_rom03(bool);
uint8_t get_keyboard_data();
uint8_t get_mouse_data();
uint8_t get_modifier_status();
uint8_t get_any_key_down();
uint8_t get_data();
uint8_t get_status();
void set_command(uint8_t);
void set_status(uint8_t);
void clear_key_strobe();
void set_microcontroller_rom(const std::vector<uint8_t> &rom);
void run_for(Cycles cycles);
private:
bool is_rom03_ = false;
std::vector<uint8_t> next_command_;
std::vector<uint8_t> pending_response_;
void abort();
void reset_microcontroller();
void flush_keyboard_buffer();
void set_modes(uint8_t modes);
uint8_t modes_ = 0;
void set_device_srq(int mask);
int device_srq_ = 0;
void set_configuration_bytes(uint8_t *);
uint8_t read_microcontroller_address(uint16_t);
InstructionSet::M50740::Executor executor_;
void run_ports_for(Cycles) override;
void set_port_output(int port, uint8_t value) override;
uint8_t get_port_input(int port) override;
uint8_t registers_[16];
uint8_t register_address_;
uint8_t ports_[4];
// TODO: this should be per peripheral. But I'm putting it here for now as an exploratory step.
bool adb_level_ = true;
Cycles low_period_, total_period_;
};
}
}
}
#endif /* Apple_IIgs_ADB_hpp */