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.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef WDC65816_hpp
|
|
|
|
#define WDC65816_hpp
|
|
|
|
|
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
|
|
|
|
2020-09-24 02:14:42 +00:00
|
|
|
namespace CPU {
|
|
|
|
namespace WDC65816 {
|
|
|
|
|
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 {
|
2020-09-28 02:20:58 +00:00
|
|
|
public:
|
2020-09-29 01:35:46 +00:00
|
|
|
inline void set_power_on(bool);
|
|
|
|
inline void set_irq_line(bool);
|
|
|
|
inline void set_nmi_line(bool);
|
2020-09-29 22:42:07 +00:00
|
|
|
inline void set_reset_line(bool);
|
2020-10-15 22:42:38 +00:00
|
|
|
inline void set_abort_line(bool);
|
2020-10-16 00:46:18 +00:00
|
|
|
inline bool get_is_resetting() const;
|
2020-09-29 01:35:46 +00:00
|
|
|
|
2020-10-17 01:05:42 +00:00
|
|
|
/*!
|
|
|
|
Returns the current state of all lines not ordinarily pushed to the BusHandler.
|
|
|
|
*/
|
|
|
|
inline int get_extended_bus_output();
|
|
|
|
|
|
|
|
/*!
|
|
|
|
Provided for symmetry with the 6502; a 65816 is never jammed.
|
|
|
|
*/
|
2020-09-29 01:35:46 +00:00
|
|
|
inline bool is_jammed() const;
|
2020-10-17 01:05:42 +00:00
|
|
|
|
|
|
|
void set_value_of_register(Register r, uint16_t value);
|
2020-09-29 01:35:46 +00:00
|
|
|
uint16_t get_value_of_register(Register r) const;
|
|
|
|
};
|
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 {
|
2020-09-29 01:35:46 +00:00
|
|
|
public:
|
2020-10-15 22:42:38 +00:00
|
|
|
/*!
|
|
|
|
Constructs an instance of the 6502 that will use @c bus_handler for all bus communications.
|
|
|
|
*/
|
2020-09-29 01:35:46 +00:00
|
|
|
Processor(BusHandler &bus_handler) : bus_handler_(bus_handler) {}
|
2020-10-15 22:42:38 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
Runs the 6502 for a supplied number of cycles.
|
|
|
|
|
|
|
|
@param cycles The number of cycles to run the 6502 for.
|
|
|
|
*/
|
2020-09-28 02:20:58 +00:00
|
|
|
void run_for(const Cycles cycles);
|
|
|
|
|
2020-10-15 22:42:38 +00:00
|
|
|
/*!
|
|
|
|
Sets the current level of the RDY line.
|
|
|
|
|
|
|
|
@param active @c true if the line is logically active; @c false otherwise.
|
|
|
|
*/
|
|
|
|
void set_ready_line(bool active);
|
|
|
|
|
2020-09-28 02:20:58 +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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* WDC65816_hpp */
|