1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Add expansion RAM, albeit not yet into the command engine.

This commit is contained in:
Thomas Harte 2023-02-20 22:27:30 -05:00
parent 4bac782121
commit 44ac948bb2
3 changed files with 18 additions and 5 deletions

View File

@ -885,9 +885,9 @@ void Base<personality>::commit_register(int reg, uint8_t value) {
case 45:
Storage<personality>::command_context_.arguments = value;
// b6: 0 = video RAM; 1 = expansion RAM.
// b5: MXD (???)
// b4: MXS
// b6: MXC, i.e. destination for INed/OUTed video data; 0 = video RAM; 1 = expansion RAM.
// b5: MXD, destination for command engine.
// b4: MXS, source for command engine.
// b3: DIY
// b2: DIX
// b1: EQ

View File

@ -437,9 +437,14 @@ template <Personality personality> struct Base: public Storage<personality> {
return;
}
// Copy and mutate the RAM pointer.
AddressT address = ram_pointer_;
++ram_pointer_;
// Determine the relevant RAM and its mask.
uint8_t *ram = ram_.data();
AddressT mask = memory_mask(personality);
if constexpr (is_yamaha_vdp(personality)) {
// The Yamaha increments only 14 bits of the address in TMS-compatible modes.
if(this->underlying_mode_ < ScreenMode::YamahaText80) {
@ -452,6 +457,12 @@ template <Personality personality> struct Base: public Storage<personality> {
// them as if linear.
address = (address >> 1) | (address << 16);
}
// Also check whether expansion RAM is the true target here.
if(Storage<personality>::command_context_.arguments & 0x40) {
ram = Storage<personality>::expansion_ram_.data();
mask = AddressT(Storage<personality>::expansion_ram_.size() - 1);
}
}
switch(queued_access_) {
@ -490,10 +501,10 @@ template <Personality personality> struct Base: public Storage<personality> {
break;
}
}
ram_[address & memory_mask(personality)] = read_ahead_buffer_;
ram[address & mask] = read_ahead_buffer_;
break;
case MemoryAccess::Read:
read_ahead_buffer_ = ram_[address & memory_mask(personality)];
read_ahead_buffer_ = ram[address & mask];
break;
}
queued_access_ = MemoryAccess::None;

View File

@ -32,6 +32,8 @@ template <> struct Storage<Personality::TMS9918A> {
template <Personality personality> struct Storage<personality, std::enable_if_t<is_yamaha_vdp(personality)>> {
using AddressT = uint32_t;
std::array<uint8_t, 65536> expansion_ram_;
int selected_status_ = 0;
int indirect_register_ = 0;