2020-09-24 02:14:42 +00:00
|
|
|
//
|
|
|
|
// 65816.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 23/09/2020.
|
|
|
|
// Copyright © 2020 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2020-09-24 02:14:42 +00:00
|
|
|
|
2020-10-16 01:09:22 +00:00
|
|
|
#include <cassert>
|
2021-07-02 03:15:32 +00:00
|
|
|
#include <cstddef>
|
2020-09-24 02:14:42 +00:00
|
|
|
#include <cstdint>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-04-28 19:10:08 +00:00
|
|
|
#include "../../Numeric/RegisterSizes.hpp"
|
2020-09-28 02:20:58 +00:00
|
|
|
#include "../../ClockReceiver/ClockReceiver.hpp"
|
2020-10-06 02:23:33 +00:00
|
|
|
#include "../6502Esque/6502Esque.hpp"
|
2020-10-06 20:25:30 +00:00
|
|
|
#include "../6502Esque/Implementation/LazyFlags.hpp"
|
2020-09-25 22:00:02 +00:00
|
|
|
|
2023-05-10 21:02:18 +00:00
|
|
|
namespace CPU::WDC65816 {
|
2020-09-24 02:14:42 +00:00
|
|
|
|
2020-09-29 01:35:46 +00:00
|
|
|
using BusOperation = CPU::MOS6502Esque::BusOperation;
|
|
|
|
using Register = CPU::MOS6502Esque::Register;
|
2020-10-06 20:25:30 +00:00
|
|
|
using Flag = CPU::MOS6502Esque::Flag;
|
2020-09-29 01:35:46 +00:00
|
|
|
|
2020-10-17 01:05:42 +00:00
|
|
|
enum ExtendedBusOutput {
|
|
|
|
Emulation = (1 << 0),
|
|
|
|
MemorySize = (1 << 1),
|
|
|
|
IndexSize = (1 << 2),
|
|
|
|
MemoryLock = (1 << 3),
|
|
|
|
};
|
|
|
|
|
2020-09-24 02:14:42 +00:00
|
|
|
#include "Implementation/65816Storage.hpp"
|
|
|
|
|
2020-09-29 01:35:46 +00:00
|
|
|
class ProcessorBase: protected ProcessorStorage {
|
2024-12-05 03:29:08 +00:00
|
|
|
public:
|
|
|
|
inline void set_power_on(bool);
|
|
|
|
inline void set_irq_line(bool);
|
|
|
|
inline void set_nmi_line(bool);
|
|
|
|
inline void set_reset_line(bool);
|
|
|
|
inline void set_abort_line(bool);
|
|
|
|
inline bool get_is_resetting() const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Returns the current state of all lines not ordinarily pushed to the BusHandler,
|
|
|
|
as listed in the ExtendedBusOutput enum.
|
|
|
|
*/
|
|
|
|
inline int get_extended_bus_output();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Provided for symmetry with the 6502; a 65816 is never jammed.
|
|
|
|
*/
|
|
|
|
inline bool is_jammed() const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
FOR TESTING PURPOSES ONLY: forces the processor into a state where
|
|
|
|
the next thing it intends to do is fetch a new opcode.
|
|
|
|
*/
|
|
|
|
inline void restart_operation_fetch();
|
|
|
|
|
|
|
|
void set_value_of(Register r, uint16_t value);
|
|
|
|
uint16_t value_of(Register r) const;
|
2020-09-29 01:35:46 +00:00
|
|
|
};
|
2020-09-24 02:14:42 +00:00
|
|
|
|
2020-10-15 22:42:38 +00:00
|
|
|
template <typename BusHandler, bool uses_ready_line> class Processor: public ProcessorBase {
|
2024-12-05 03:29:08 +00:00
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
Constructs an instance of the 6502 that will use @c bus_handler for all bus communications.
|
|
|
|
*/
|
|
|
|
Processor(BusHandler &bus_handler) : bus_handler_(bus_handler) {}
|
2020-10-15 22:42:38 +00:00
|
|
|
|
2024-12-05 03:29:08 +00:00
|
|
|
/*!
|
2024-12-05 22:29:05 +00:00
|
|
|
Runs the 6502 for a number of cycles.
|
2024-12-05 03:29:08 +00:00
|
|
|
*/
|
|
|
|
void run_for(const Cycles);
|
2020-09-28 02:20:58 +00:00
|
|
|
|
2024-12-05 03:29:08 +00:00
|
|
|
/*!
|
|
|
|
Sets the current level of the RDY line.
|
2020-10-15 22:42:38 +00:00
|
|
|
|
2024-12-05 03:29:08 +00:00
|
|
|
@param active @c true if the line is logically active; @c false otherwise.
|
|
|
|
*/
|
|
|
|
void set_ready_line(bool active);
|
2020-10-15 22:42:38 +00:00
|
|
|
|
2024-12-05 03:29:08 +00:00
|
|
|
private:
|
|
|
|
BusHandler &bus_handler_;
|
2020-09-24 02:14:42 +00:00
|
|
|
};
|
|
|
|
|
2020-09-28 02:20:58 +00:00
|
|
|
#include "Implementation/65816Implementation.hpp"
|
|
|
|
|
2020-09-24 02:14:42 +00:00
|
|
|
}
|