2016-10-12 02:20:13 +00:00
|
|
|
//
|
|
|
|
// Oric.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 11/10/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef Oric_hpp
|
|
|
|
#define Oric_hpp
|
|
|
|
|
|
|
|
#include "../ConfigurationTarget.hpp"
|
|
|
|
#include "../CRTMachine.hpp"
|
|
|
|
#include "../Typer.hpp"
|
|
|
|
|
2017-05-15 02:08:15 +00:00
|
|
|
#include "../../Processors/6502/6502.hpp"
|
2016-11-04 02:14:40 +00:00
|
|
|
#include "../../Components/6522/6522.hpp"
|
|
|
|
#include "../../Components/AY38910/AY38910.hpp"
|
2016-11-08 02:57:58 +00:00
|
|
|
#include "../../Storage/Tape/Parsers/Oric.hpp"
|
2016-11-04 02:14:40 +00:00
|
|
|
|
2016-10-12 23:20:23 +00:00
|
|
|
#include "Video.hpp"
|
2016-11-22 14:22:00 +00:00
|
|
|
#include "Microdisc.hpp"
|
2016-10-12 23:20:23 +00:00
|
|
|
|
2016-11-04 02:14:40 +00:00
|
|
|
#include "../../Storage/Tape/Tape.hpp"
|
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
2016-10-15 21:45:39 +00:00
|
|
|
#include <memory>
|
2016-10-12 02:20:13 +00:00
|
|
|
|
|
|
|
namespace Oric {
|
|
|
|
|
2016-10-15 01:18:03 +00:00
|
|
|
enum Key: uint16_t {
|
|
|
|
Key3 = 0x0000 | 0x80, KeyX = 0x0000 | 0x40, Key1 = 0x0000 | 0x20,
|
|
|
|
KeyV = 0x0000 | 0x08, Key5 = 0x0000 | 0x04, KeyN = 0x0000 | 0x02, Key7 = 0x0000 | 0x01,
|
|
|
|
KeyD = 0x0100 | 0x80, KeyQ = 0x0100 | 0x40, KeyEscape = 0x0100 | 0x20,
|
|
|
|
KeyF = 0x0100 | 0x08, KeyR = 0x0100 | 0x04, KeyT = 0x0100 | 0x02, KeyJ = 0x0100 | 0x01,
|
|
|
|
KeyC = 0x0200 | 0x80, Key2 = 0x0200 | 0x40, KeyZ = 0x0200 | 0x20, KeyControl = 0x0200 | 0x10,
|
|
|
|
Key4 = 0x0200 | 0x08, KeyB = 0x0200 | 0x04, Key6 = 0x0200 | 0x02, KeyM = 0x0200 | 0x01,
|
|
|
|
KeyQuote = 0x0300 | 0x80, KeyBackSlash = 0x0300 | 0x40,
|
|
|
|
KeyMinus = 0x0300 | 0x08, KeySemiColon = 0x0300 | 0x04, Key9 = 0x0300 | 0x02, KeyK = 0x0300 | 0x01,
|
|
|
|
KeyRight = 0x0400 | 0x80, KeyDown = 0x0400 | 0x40, KeyLeft = 0x0400 | 0x20, KeyLeftShift = 0x0400 | 0x10,
|
|
|
|
KeyUp = 0x0400 | 0x08, KeyFullStop = 0x0400 | 0x04, KeyComma = 0x0400 | 0x02, KeySpace = 0x0400 | 0x01,
|
|
|
|
KeyOpenSquare = 0x0500 | 0x80, KeyCloseSquare = 0x0500 | 0x40, KeyDelete = 0x0500 | 0x20, KeyFunction = 0x0500 | 0x10,
|
|
|
|
KeyP = 0x0500 | 0x08, KeyO = 0x0500 | 0x04, KeyI = 0x0500 | 0x02, KeyU = 0x0500 | 0x01,
|
|
|
|
KeyW = 0x0600 | 0x80, KeyS = 0x0600 | 0x40, KeyA = 0x0600 | 0x20,
|
|
|
|
KeyE = 0x0600 | 0x08, KeyG = 0x0600 | 0x04, KeyH = 0x0600 | 0x02, KeyY = 0x0600 | 0x01,
|
|
|
|
KeyEquals = 0x0700 | 0x80, KeyReturn = 0x0700 | 0x20, KeyRightShift = 0x0700 | 0x10,
|
|
|
|
KeyForwardSlash = 0x0700 | 0x08, Key0 = 0x0700 | 0x04, KeyL = 0x0700 | 0x02, Key8 = 0x0700 | 0x01,
|
|
|
|
|
2016-11-05 18:47:09 +00:00
|
|
|
KeyNMI = 0xfffd,
|
2016-10-14 00:50:55 +00:00
|
|
|
};
|
|
|
|
|
2016-11-15 02:39:16 +00:00
|
|
|
enum ROM {
|
2016-12-10 03:17:10 +00:00
|
|
|
BASIC10, BASIC11, Microdisc, Colour
|
2016-11-15 02:39:16 +00:00
|
|
|
};
|
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
class Machine:
|
2017-05-15 02:08:15 +00:00
|
|
|
public CPU::MOS6502::Processor<Machine>,
|
2016-10-12 02:20:13 +00:00
|
|
|
public CRTMachine::Machine,
|
2016-10-14 00:50:55 +00:00
|
|
|
public ConfigurationTarget::Machine,
|
2016-10-16 01:21:18 +00:00
|
|
|
public MOS::MOS6522IRQDelegate::Delegate,
|
2016-11-04 02:14:40 +00:00
|
|
|
public Utility::TypeRecipient,
|
2016-11-25 12:15:48 +00:00
|
|
|
public Storage::Tape::BinaryTapePlayer::Delegate,
|
|
|
|
public Microdisc::Delegate {
|
2016-10-12 02:20:13 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Machine();
|
|
|
|
|
2016-11-15 02:39:16 +00:00
|
|
|
void set_rom(ROM rom, const std::vector<uint8_t> &data);
|
2016-11-05 18:47:09 +00:00
|
|
|
void set_key_state(uint16_t key, bool isPressed);
|
2016-10-15 01:18:03 +00:00
|
|
|
void clear_all_keys();
|
2016-10-12 22:51:02 +00:00
|
|
|
|
2016-11-03 11:59:30 +00:00
|
|
|
void set_use_fast_tape_hack(bool activate);
|
2016-12-10 18:55:56 +00:00
|
|
|
void set_output_device(Outputs::CRT::OutputDevice output_device);
|
2016-11-03 11:59:30 +00:00
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
// to satisfy ConfigurationTarget::Machine
|
|
|
|
void configure_as_target(const StaticAnalyser::Target &target);
|
|
|
|
|
2017-05-15 02:08:15 +00:00
|
|
|
// to satisfy CPU::MOS6502::Processor
|
|
|
|
unsigned int perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value);
|
2017-05-15 11:38:59 +00:00
|
|
|
void flush();
|
2016-10-12 02:20:13 +00:00
|
|
|
|
|
|
|
// to satisfy CRTMachine::Machine
|
|
|
|
virtual void setup_output(float aspect_ratio);
|
|
|
|
virtual void close_output();
|
2016-10-31 02:51:08 +00:00
|
|
|
virtual std::shared_ptr<Outputs::CRT::CRT> get_crt();
|
|
|
|
virtual std::shared_ptr<Outputs::Speaker> get_speaker();
|
2017-07-23 02:17:29 +00:00
|
|
|
virtual void run_for(const Cycles &cyclesß);
|
2016-10-12 02:20:13 +00:00
|
|
|
|
2016-10-14 00:50:55 +00:00
|
|
|
// to satisfy MOS::MOS6522IRQDelegate::Delegate
|
|
|
|
void mos6522_did_change_interrupt_status(void *mos6522);
|
|
|
|
|
2016-10-16 01:21:18 +00:00
|
|
|
// to satisfy Storage::Tape::BinaryTapePlayer::Delegate
|
|
|
|
void tape_did_change_input(Storage::Tape::BinaryTapePlayer *tape_player);
|
|
|
|
|
2016-11-05 18:47:09 +00:00
|
|
|
// for Utility::TypeRecipient::Delegate
|
|
|
|
uint16_t *sequence_for_character(Utility::Typer *typer, char character);
|
2016-11-04 02:14:40 +00:00
|
|
|
|
2016-11-25 12:15:48 +00:00
|
|
|
// for Microdisc::Delegate
|
|
|
|
void microdisc_did_change_paging_flags(class Microdisc *microdisc);
|
2016-12-01 12:41:52 +00:00
|
|
|
void wd1770_did_change_output(WD::WD1770 *wd1770);
|
2016-11-25 12:15:48 +00:00
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
private:
|
2016-10-12 22:51:02 +00:00
|
|
|
// RAM and ROM
|
2016-12-10 03:17:10 +00:00
|
|
|
std::vector<uint8_t> basic11_rom_, basic10_rom_, microdisc_rom_, colour_rom_;
|
2016-11-22 14:22:00 +00:00
|
|
|
uint8_t ram_[65536], rom_[16384];
|
|
|
|
int cycles_since_video_update_;
|
2016-10-12 23:20:23 +00:00
|
|
|
inline void update_video();
|
2016-10-12 22:51:02 +00:00
|
|
|
|
2016-11-15 03:05:53 +00:00
|
|
|
// ROM bookkeeping
|
2016-11-22 14:22:00 +00:00
|
|
|
bool is_using_basic11_;
|
|
|
|
uint16_t tape_get_byte_address_, scan_keyboard_address_, tape_speed_address_;
|
|
|
|
int keyboard_read_count_;
|
2016-11-15 03:05:53 +00:00
|
|
|
|
2016-10-12 02:20:13 +00:00
|
|
|
// Outputs
|
2016-11-22 14:22:00 +00:00
|
|
|
std::unique_ptr<VideoOutput> video_output_;
|
2016-10-14 00:50:55 +00:00
|
|
|
|
2016-10-16 01:21:18 +00:00
|
|
|
// Keyboard
|
2016-10-15 01:18:03 +00:00
|
|
|
class Keyboard {
|
|
|
|
public:
|
2016-10-15 01:44:15 +00:00
|
|
|
uint8_t row;
|
2016-10-15 01:18:03 +00:00
|
|
|
uint8_t rows[8];
|
|
|
|
};
|
2016-11-22 14:22:00 +00:00
|
|
|
int typer_delay_;
|
2016-10-16 01:21:18 +00:00
|
|
|
|
2016-11-03 02:30:53 +00:00
|
|
|
// The tape
|
|
|
|
class TapePlayer: public Storage::Tape::BinaryTapePlayer {
|
|
|
|
public:
|
|
|
|
TapePlayer();
|
|
|
|
uint8_t get_next_byte(bool fast);
|
|
|
|
|
|
|
|
private:
|
2016-11-22 14:22:00 +00:00
|
|
|
Storage::Tape::Oric::Parser parser_;
|
2016-11-03 02:30:53 +00:00
|
|
|
};
|
2016-11-22 14:22:00 +00:00
|
|
|
bool use_fast_tape_hack_;
|
2016-11-03 02:30:53 +00:00
|
|
|
|
2016-10-16 01:32:59 +00:00
|
|
|
// VIA (which owns the tape and the AY)
|
2016-10-15 01:18:03 +00:00
|
|
|
class VIA: public MOS::MOS6522<VIA>, public MOS::MOS6522IRQDelegate {
|
|
|
|
public:
|
2016-10-31 02:51:08 +00:00
|
|
|
VIA();
|
2016-10-15 01:18:03 +00:00
|
|
|
using MOS6522IRQDelegate::set_interrupt_status;
|
|
|
|
|
2016-10-21 00:53:17 +00:00
|
|
|
void set_control_line_output(Port port, Line line, bool value);
|
|
|
|
void set_port_output(Port port, uint8_t value, uint8_t direction_mask);
|
|
|
|
uint8_t get_port_input(Port port);
|
2016-10-31 02:51:08 +00:00
|
|
|
inline void run_for_cycles(unsigned int number_of_cycles);
|
2016-10-15 21:45:39 +00:00
|
|
|
|
|
|
|
std::shared_ptr<GI::AY38910> ay8910;
|
2016-11-08 02:57:58 +00:00
|
|
|
std::unique_ptr<TapePlayer> tape;
|
2016-10-15 01:18:03 +00:00
|
|
|
std::shared_ptr<Keyboard> keyboard;
|
2016-10-15 01:35:15 +00:00
|
|
|
|
2017-05-15 11:38:59 +00:00
|
|
|
void flush();
|
2016-10-16 01:04:21 +00:00
|
|
|
|
2016-10-15 01:35:15 +00:00
|
|
|
private:
|
2016-10-21 00:53:17 +00:00
|
|
|
void update_ay();
|
2016-11-22 14:22:00 +00:00
|
|
|
bool ay_bdir_, ay_bc1_;
|
|
|
|
unsigned int cycles_since_ay_update_;
|
2016-10-15 01:18:03 +00:00
|
|
|
};
|
2016-11-22 14:22:00 +00:00
|
|
|
VIA via_;
|
|
|
|
std::shared_ptr<Keyboard> keyboard_;
|
|
|
|
|
|
|
|
// the Microdisc, if in use
|
|
|
|
class Microdisc microdisc_;
|
|
|
|
bool microdisc_is_enabled_;
|
2016-11-25 12:15:48 +00:00
|
|
|
uint16_t ram_top_;
|
|
|
|
uint8_t *paged_rom_;
|
|
|
|
|
|
|
|
inline void set_interrupt_line();
|
2016-10-12 02:20:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif /* Oric_hpp */
|