1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-30 22:56:03 +00:00

Clarifies word addressing.

This commit is contained in:
Thomas Harte 2021-09-16 08:24:52 -04:00
parent 8aac2bd029
commit 6572efe2a7
4 changed files with 27 additions and 17 deletions

View File

@ -59,6 +59,6 @@ uint16_t Blitter::get_status() {
}
bool Blitter::advance() {
ram_[(pointer_[3] >> 1) & ram_mask_] = 0xffff;
ram_[pointer_[3] & ram_mask_] = 0xffff;
return false;
}

View File

@ -32,11 +32,11 @@ template <DMAFlag... Flags> struct DMAMask: Mask<DMAFlag, Flags...> {};
}
Chipset::Chipset(uint16_t *ram, size_t size) :
blitter_(*this, ram, size),
bitplanes_(*this, ram, size),
copper_(*this, ram, size),
disk_(*this, ram, size),
Chipset::Chipset(uint16_t *ram, size_t word_size) :
blitter_(*this, ram, word_size),
bitplanes_(*this, ram, word_size),
copper_(*this, ram, word_size),
disk_(*this, ram, word_size),
crt_(908, 4, Outputs::Display::Type::PAL50, Outputs::Display::InputDataType::Red4Green4Blue4) {
}
@ -231,7 +231,9 @@ template <int cycle> void Chipset::output() {
}
if(pixels_) {
// TODO: this is obviously nonsense.
// TODO: this is obviously nonsense. Probably do a table-based
// planar-to-chunky up front into 8-bit pockets, and just shift that.
pixels_[0] = palette_[
((current_bitplanes_[0]&1) << 0) |
((current_bitplanes_[1]&1) << 1) |
@ -253,13 +255,13 @@ template <int cycle> void Chipset::output() {
((current_bitplanes_[3]&4) << 1) |
((current_bitplanes_[4]&4) << 2)
];
pixels_[3] = palette_[
pixels_[3] = 0;/*palette_[
((current_bitplanes_[0]&8) >> 3) |
((current_bitplanes_[1]&8) >> 2) |
((current_bitplanes_[2]&8) >> 1) |
((current_bitplanes_[3]&8) << 0) |
((current_bitplanes_[4]&8) << 1)
];
];*/
current_bitplanes_ >>= 4;
pixels_ += 4;
@ -457,9 +459,6 @@ void Chipset::post_bitplanes(const BitplaneData &data) {
// TODO: should probably store for potential delay?
current_bitplanes_ = data;
if(data[0] || data[1]) {
printf("");
}
// current_bitplanes_[0] = 0xaaaa;
// current_bitplanes_[1] = 0x3333;
// current_bitplanes_[2] = 0x4444;
@ -958,4 +957,3 @@ void Chipset::set_display_type(Outputs::Display::DisplayType type) {
Outputs::Display::DisplayType Chipset::get_display_type() const {
return crt_.get_display_type();
}

View File

@ -55,7 +55,7 @@ enum class DMAFlag: uint16_t {
class Chipset {
public:
Chipset(uint16_t *ram, size_t size);
Chipset(uint16_t *ram, size_t word_size);
struct Changes {
int hsyncs = 0;

View File

@ -19,8 +19,8 @@ class Chipset;
class DMADeviceBase {
public:
DMADeviceBase(Chipset &chipset, uint16_t *ram, size_t size) :
chipset_(chipset), ram_(ram), ram_mask_(uint32_t((size - 1) >> 1)) {}
DMADeviceBase(Chipset &chipset, uint16_t *ram, size_t word_size) :
chipset_(chipset), ram_(ram), ram_mask_(uint32_t(word_size - 1)) {}
protected:
Chipset &chipset_;
@ -36,11 +36,23 @@ template <size_t num_addresses> class DMADevice: public DMADeviceBase {
template <int id, int shift> void set_pointer(uint16_t value) {
static_assert(id < num_addresses);
static_assert(shift == 0 || shift == 16);
pointer_[id] = (pointer_[id] & (0xffff'0000 >> shift)) | uint32_t(value << shift);
byte_pointer_[id] = (byte_pointer_[id] & (0xffff'0000 >> shift)) | uint32_t(value << shift);
pointer_[id] = byte_pointer_[id] >> 1;
}
template <int id, int shift> uint16_t get_pointer() {
// Restore the original least-significant bit.
const uint32_t source = (pointer_[id] << 1) | (byte_pointer_[id] & 1);
return uint16_t(source >> shift);
}
protected:
// These are shifted right one to provide word-indexing pointers;
// subclasses should use e.g. ram_[pointer_[0] & ram_mask_] directly.
std::array<uint32_t, num_addresses> pointer_{};
private:
std::array<uint32_t, num_addresses> byte_pointer_{};
};
}