escc: unify compatible and MacRISC addressing.

This commit is contained in:
Maxim Poliakovski 2022-02-23 17:07:29 +01:00
parent f1ed56ae9a
commit c946693450
4 changed files with 18 additions and 61 deletions

View File

@ -105,8 +105,7 @@ uint32_t AMIC::read(uint32_t reg_start, uint32_t offset, int size)
case 1:
return this->viacuda->read(offset >> 9);
case 4: // SCC registers
this->escc->read_compat((offset >> 1) & 0xF);
return 0;
return this->escc->read((offset >> 1) & 0xF);
case 0xA: // MACE registers
return this->mace->read((offset >> 4) & 0xF);
case 0x10: // SCSI registers
@ -186,7 +185,7 @@ void AMIC::write(uint32_t reg_start, uint32_t offset, uint32_t value, int size)
this->viacuda->write(offset >> 9, value);
return;
case 4:
this->escc->write_compat((offset >> 1) & 0xF, value);
this->escc->write((offset >> 1) & 0xF, value);
return;
case 0xA: // MACE registers
this->mace->write((offset >> 4) & 0xF, value);

View File

@ -134,9 +134,12 @@ uint32_t HeathrowIC::read(uint32_t reg_start, uint32_t offset, int size) {
case 0x10:
res = this->mesh->read((offset >> 4) & 0xF);
break;
case 0x12: // ESCC compatible
return this->escc->read_compat((offset >> 4) & 0xF);
case 0x13: // ESCC MacRISC
case 0x12: // ESCC compatible addressing
if ((offset & 0xFF) < 16) {
return this->escc->read((offset >> 1) & 0xF);
}
// fallthrough
case 0x13: // ESCC MacRISC addressing
return this->escc->read((offset >> 4) & 0xF);
case 0x14:
res = this->screamer->snd_ctrl_read(offset - 0x14000, size);
@ -173,10 +176,13 @@ void HeathrowIC::write(uint32_t reg_start, uint32_t offset, uint32_t value, int
case 0x10:
this->mesh->write((offset >> 4) & 0xF, value);
break;
case 0x12: // ESCC compatible
this->escc->write_compat((offset >> 4) & 0xF, value);
break;
case 0x13: // ESCC MacRISC
case 0x12: // ESCC compatible addressing
if ((offset & 0xFF) < 16) {
this->escc->write((offset >> 1) & 0xF, value);
break;
}
// fallthrough
case 0x13: // ESCC MacRISC addressing
this->escc->write((offset >> 4) & 0xF, value);
break;
case 0x14:

View File

@ -67,38 +67,6 @@ void EsccController::write(uint8_t reg_offset, uint8_t value)
}
}
uint8_t EsccController::read_compat(uint8_t reg_offset)
{
switch(reg_offset) {
case Compat::EsccReg::Port_B_Cmd:
LOG_F(9, "ESCC: reading Port B register RR%d", this->reg_ptr);
this->reg_ptr = 0;
break;
case Compat::EsccReg::Port_A_Cmd:
LOG_F(9, "ESCC: reading Port A register RR%d", this->reg_ptr);
this->reg_ptr = 0;
break;
default:
LOG_F(INFO, "ESCC: reading register %d", reg_offset);
}
return 0;
}
void EsccController::write_compat(uint8_t reg_offset, uint8_t value)
{
switch(reg_offset) {
case Compat::EsccReg::Port_B_Cmd:
this->write_internal(this->ch_b.get(), value);
break;
case Compat::EsccReg::Port_A_Cmd:
this->write_internal(this->ch_a.get(), value);
break;
default:
LOG_F(INFO, "ESCC: writing 0x%X to register %d", value, reg_offset);
}
}
void EsccController::write_internal(EsccChannel *ch, uint8_t value)
{
if (this->reg_ptr) {

View File

@ -28,19 +28,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <memory>
#include <string>
/** ESCC compatible (aka Macintosh legacy) register addressing */
namespace Compat {
enum EsccReg : uint8_t {
Port_B_Cmd = 0,
Port_A_Cmd = 1,
Port_B_Data = 2,
Port_A_Data = 3,
Enh_Reg_B = 4,
Enh_Reg_A = 5,
};
};
/** ESCC MacRISC style register addressing */
/** ESCC register addresses */
enum EsccReg : uint8_t {
Port_B_Cmd = 0,
Port_B_Data = 1,
@ -50,7 +38,7 @@ enum EsccReg : uint8_t {
Enh_Reg_A = 5,
};
/** LocalTalk registers (same in both addressing schemes) */
/** LocalTalk LTPC registers */
enum LocalTalkReg : uint8_t {
Rec_Count = 8,
Start_A = 9,
@ -81,14 +69,10 @@ public:
EsccController();
~EsccController() = default;
// ESCC MacRISC registers access
// ESCC registers access
uint8_t read(uint8_t reg_offset);
void write(uint8_t reg_offset, uint8_t value);
// ESCC compatible registers access
uint8_t read_compat(uint8_t reg_offset);
void write_compat(uint8_t reg_offset, uint8_t value);
private:
void write_internal(EsccChannel* ch, uint8_t value);