2021-07-22 22:43:07 +00:00
|
|
|
//
|
|
|
|
// Blitter.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 22/07/2021.
|
|
|
|
// Copyright © 2021 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
2024-01-17 04:34:46 +00:00
|
|
|
#pragma once
|
2021-07-22 22:43:07 +00:00
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include <cstdint>
|
2022-08-06 18:40:12 +00:00
|
|
|
#include <string>
|
2022-08-06 13:51:20 +00:00
|
|
|
#include <vector>
|
2021-07-22 22:43:07 +00:00
|
|
|
|
|
|
|
#include "../../ClockReceiver/ClockReceiver.hpp"
|
2022-08-19 20:38:15 +00:00
|
|
|
#include "BlitterSequencer.hpp"
|
2021-09-15 00:51:32 +00:00
|
|
|
#include "DMADevice.hpp"
|
2021-07-22 22:43:07 +00:00
|
|
|
|
|
|
|
namespace Amiga {
|
|
|
|
|
2022-08-06 13:51:20 +00:00
|
|
|
/*!
|
|
|
|
If @c record_bus is @c true then all bus interactions will be recorded
|
|
|
|
and can subsequently be retrieved. This is included for testing purposes.
|
|
|
|
*/
|
|
|
|
template <bool record_bus = false> class Blitter: public DMADevice<4, 4> {
|
2021-07-22 22:43:07 +00:00
|
|
|
public:
|
2021-09-15 00:51:32 +00:00
|
|
|
using DMADevice::DMADevice;
|
2021-07-22 22:43:07 +00:00
|
|
|
|
2022-08-19 20:38:15 +00:00
|
|
|
template <int id, int shift> void set_pointer(uint16_t value) {
|
|
|
|
DMADevice<4, 4>::set_pointer<id, shift>(value);
|
|
|
|
}
|
|
|
|
|
2021-07-22 22:43:07 +00:00
|
|
|
// Various setters; it's assumed that address decoding is handled externally.
|
|
|
|
//
|
|
|
|
// In all cases where a channel is identified numerically, it's taken that
|
|
|
|
// 0 = A, 1 = B, 2 = C, 3 = D.
|
|
|
|
void set_control(int index, uint16_t value);
|
|
|
|
void set_first_word_mask(uint16_t value);
|
|
|
|
void set_last_word_mask(uint16_t value);
|
2021-08-10 11:17:01 +00:00
|
|
|
|
2021-07-22 22:43:07 +00:00
|
|
|
void set_size(uint16_t value);
|
|
|
|
void set_minterms(uint16_t value);
|
2021-11-24 22:25:32 +00:00
|
|
|
// void set_vertical_size(uint16_t value);
|
|
|
|
// void set_horizontal_size(uint16_t value);
|
2021-07-22 22:43:07 +00:00
|
|
|
void set_data(int channel, uint16_t value);
|
|
|
|
|
|
|
|
uint16_t get_status();
|
|
|
|
|
2022-08-15 15:10:17 +00:00
|
|
|
template <bool complete_immediately> bool advance_dma();
|
2021-07-22 22:43:07 +00:00
|
|
|
|
2022-08-06 13:51:20 +00:00
|
|
|
struct Transaction {
|
|
|
|
enum class Type {
|
|
|
|
SkippedSlot,
|
|
|
|
ReadA,
|
|
|
|
ReadB,
|
|
|
|
ReadC,
|
|
|
|
AddToPipeline,
|
|
|
|
WriteFromPipeline
|
2022-08-06 18:40:12 +00:00
|
|
|
} type = Type::SkippedSlot;
|
2022-08-06 13:51:20 +00:00
|
|
|
|
|
|
|
uint32_t address = 0;
|
|
|
|
uint16_t value = 0;
|
|
|
|
|
2024-02-17 02:47:23 +00:00
|
|
|
Transaction() = default;
|
2022-08-06 13:51:20 +00:00
|
|
|
Transaction(Type type) : type(type) {}
|
|
|
|
Transaction(Type type, uint32_t address, uint16_t value) : type(type), address(address), value(value) {}
|
2022-08-06 18:40:12 +00:00
|
|
|
|
|
|
|
std::string to_string() const {
|
|
|
|
std::string result;
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case Type::SkippedSlot: result = "SkippedSlot"; break;
|
|
|
|
case Type::ReadA: result = "ReadA"; break;
|
|
|
|
case Type::ReadB: result = "ReadB"; break;
|
|
|
|
case Type::ReadC: result = "ReadC"; break;
|
|
|
|
case Type::AddToPipeline: result = "AddToPipeline"; break;
|
|
|
|
case Type::WriteFromPipeline: result = "WriteFromPipeline"; break;
|
|
|
|
}
|
|
|
|
|
|
|
|
result += " address:" + std::to_string(address) + " value:" + std::to_string(value);
|
|
|
|
return result;
|
|
|
|
}
|
2022-08-06 13:51:20 +00:00
|
|
|
};
|
|
|
|
std::vector<Transaction> get_and_reset_transactions();
|
|
|
|
|
2021-07-22 22:43:07 +00:00
|
|
|
private:
|
2021-08-10 11:17:01 +00:00
|
|
|
int width_ = 0, height_ = 0;
|
2021-09-23 22:38:37 +00:00
|
|
|
int shifts_[2]{};
|
2021-09-26 23:18:12 +00:00
|
|
|
uint16_t a_mask_[2] = {0xffff, 0xffff};
|
|
|
|
|
2021-09-23 22:38:37 +00:00
|
|
|
bool line_mode_ = false;
|
2021-09-26 23:18:12 +00:00
|
|
|
bool one_dot_ = false;
|
|
|
|
int line_direction_ = 0;
|
|
|
|
int line_sign_ = 1;
|
|
|
|
|
2021-09-23 22:38:37 +00:00
|
|
|
uint32_t direction_ = 1;
|
2021-09-29 02:11:58 +00:00
|
|
|
bool inclusive_fill_ = false;
|
|
|
|
bool exclusive_fill_ = false;
|
|
|
|
bool fill_carry_ = false;
|
2021-09-26 23:18:12 +00:00
|
|
|
|
2021-09-23 22:38:37 +00:00
|
|
|
uint8_t minterms_ = 0;
|
2021-09-24 02:05:59 +00:00
|
|
|
uint32_t a32_ = 0, b32_ = 0;
|
2021-10-27 03:02:28 +00:00
|
|
|
uint16_t a_data_ = 0, b_data_ = 0, c_data_ = 0;
|
2021-09-21 03:08:26 +00:00
|
|
|
|
2021-10-29 01:12:46 +00:00
|
|
|
bool not_zero_flag_ = false;
|
2022-07-29 20:15:18 +00:00
|
|
|
|
|
|
|
BlitterSequencer sequencer_;
|
|
|
|
uint32_t write_address_ = 0xffff'ffff;
|
|
|
|
uint16_t write_value_ = 0;
|
|
|
|
enum WritePhase {
|
2022-07-29 20:33:46 +00:00
|
|
|
Starting, Full
|
2022-07-29 20:15:18 +00:00
|
|
|
} write_phase_;
|
|
|
|
int y_, x_;
|
|
|
|
uint16_t transient_a_mask_;
|
2022-07-31 00:34:37 +00:00
|
|
|
bool busy_ = false;
|
|
|
|
int loop_index_ = -1;
|
2022-07-31 01:35:26 +00:00
|
|
|
|
2022-08-07 23:15:03 +00:00
|
|
|
int error_ = 0;
|
|
|
|
bool draw_ = false;
|
2022-08-07 23:19:00 +00:00
|
|
|
bool has_c_data_ = false;
|
2022-08-07 23:15:03 +00:00
|
|
|
|
2022-07-31 01:35:26 +00:00
|
|
|
void add_modulos();
|
2022-08-06 13:51:20 +00:00
|
|
|
std::vector<Transaction> transactions_;
|
2021-07-22 22:43:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|