mirror of
https://github.com/TomHarte/CLK.git
synced 2025-04-06 10:38:16 +00:00
Clarifies word addressing.
This commit is contained in:
parent
8aac2bd029
commit
6572efe2a7
@ -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;
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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_{};
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user