2020-11-01 01:00:15 +00:00
|
|
|
//
|
|
|
|
// ADB.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 31/10/2020.
|
|
|
|
// Copyright © 2020 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2020-11-01 01:00:15 +00:00
|
|
|
|
|
|
|
#include <cstdint>
|
2020-11-10 00:05:48 +00:00
|
|
|
#include <vector>
|
2021-01-18 21:59:49 +00:00
|
|
|
#include "../../../InstructionSets/M50740/Executor.hpp"
|
2021-02-13 02:50:24 +00:00
|
|
|
|
2021-02-11 02:24:31 +00:00
|
|
|
#include "../ADB/Bus.hpp"
|
2021-02-13 02:50:24 +00:00
|
|
|
#include "../ADB/Mouse.hpp"
|
2021-02-14 04:16:45 +00:00
|
|
|
#include "../ADB/Keyboard.hpp"
|
2020-11-01 01:00:15 +00:00
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace Apple::IIgs::ADB {
|
2020-11-01 01:00:15 +00:00
|
|
|
|
2021-01-24 23:07:05 +00:00
|
|
|
class GLU: public InstructionSet::M50740::PortHandler {
|
2020-11-01 01:00:15 +00:00
|
|
|
public:
|
2021-01-24 23:07:05 +00:00
|
|
|
GLU();
|
|
|
|
|
2020-11-01 01:00:15 +00:00
|
|
|
uint8_t get_keyboard_data();
|
|
|
|
uint8_t get_mouse_data();
|
|
|
|
uint8_t get_modifier_status();
|
2020-11-05 02:35:11 +00:00
|
|
|
uint8_t get_any_key_down();
|
2020-11-01 01:00:15 +00:00
|
|
|
|
|
|
|
uint8_t get_data();
|
|
|
|
uint8_t get_status();
|
|
|
|
|
|
|
|
void set_command(uint8_t);
|
|
|
|
void set_status(uint8_t);
|
2020-11-05 02:35:11 +00:00
|
|
|
void clear_key_strobe();
|
2020-11-10 00:05:48 +00:00
|
|
|
|
2021-01-18 21:59:49 +00:00
|
|
|
void set_microcontroller_rom(const std::vector<uint8_t> &rom);
|
|
|
|
|
2021-01-24 03:55:12 +00:00
|
|
|
void run_for(Cycles cycles);
|
|
|
|
|
2021-02-15 02:15:31 +00:00
|
|
|
bool get_command_button() const;
|
|
|
|
bool get_option_button() const;
|
|
|
|
|
2021-02-15 03:20:58 +00:00
|
|
|
void set_vertical_blank(bool);
|
2021-02-16 01:49:16 +00:00
|
|
|
bool get_vertical_blank() {
|
|
|
|
return vertical_blank_;
|
|
|
|
}
|
2021-02-15 03:20:58 +00:00
|
|
|
|
2021-02-15 20:00:12 +00:00
|
|
|
Apple::ADB::Keyboard &keyboard() {
|
|
|
|
return keyboard_;
|
|
|
|
}
|
2021-02-16 01:49:16 +00:00
|
|
|
Inputs::Mouse &get_mouse() {
|
|
|
|
return mouse_;
|
|
|
|
}
|
2021-02-15 20:00:12 +00:00
|
|
|
|
2020-11-10 00:05:48 +00:00
|
|
|
private:
|
2021-01-18 21:59:49 +00:00
|
|
|
InstructionSet::M50740::Executor executor_;
|
2021-01-24 23:07:05 +00:00
|
|
|
|
2021-01-25 22:43:22 +00:00
|
|
|
void run_ports_for(Cycles) override;
|
2021-01-24 23:07:05 +00:00
|
|
|
void set_port_output(int port, uint8_t value) override;
|
|
|
|
uint8_t get_port_input(int port) override;
|
|
|
|
|
2021-02-19 03:48:53 +00:00
|
|
|
uint8_t registers_[16]{};
|
2021-02-13 22:38:42 +00:00
|
|
|
|
2021-01-24 23:07:05 +00:00
|
|
|
uint8_t register_address_;
|
2021-01-30 22:53:27 +00:00
|
|
|
uint8_t register_latch_ = 0xff;
|
2021-02-13 22:38:42 +00:00
|
|
|
bool register_strobe_ = false;
|
2021-01-30 22:53:27 +00:00
|
|
|
|
|
|
|
uint8_t status_ = 0x00;
|
2021-01-25 22:43:22 +00:00
|
|
|
|
2021-02-11 02:24:31 +00:00
|
|
|
Apple::ADB::Bus bus_;
|
|
|
|
size_t controller_id_;
|
|
|
|
|
2021-02-15 02:15:31 +00:00
|
|
|
uint8_t modifier_state_ = 0;
|
|
|
|
|
2021-02-16 01:49:16 +00:00
|
|
|
bool vertical_blank_ = false;
|
|
|
|
|
2021-02-20 03:48:15 +00:00
|
|
|
int visible_mouse_register_ = 2;
|
|
|
|
|
2021-02-14 04:16:45 +00:00
|
|
|
// For now, attach only a keyboard and mouse.
|
2021-02-13 02:50:24 +00:00
|
|
|
Apple::ADB::Mouse mouse_;
|
2021-02-14 04:16:45 +00:00
|
|
|
Apple::ADB::Keyboard keyboard_;
|
2020-11-01 01:00:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|