amic: reorganize registers in blocks.

This commit is contained in:
Maxim Poliakovski 2021-10-16 15:07:53 +02:00
parent 2f725fe3e4
commit c7544d9c2f

View File

@ -66,10 +66,18 @@ uint32_t AMIC::read(uint32_t reg_start, uint32_t offset, int size)
{ {
uint32_t phase_val; uint32_t phase_val;
if (offset < 0x2000) { // subdevices registers
switch(offset >> 12) {
case 0: // VIA1 registers
case 1:
return this->viacuda->read(offset >> 9); return this->viacuda->read(offset >> 9);
} case 4: // SCC registers
LOG_F(WARNING, "AMIC: read attempt from unimplemented SCC register");
return 0;
case 0x10: // SCSI registers
LOG_F(WARNING, "AMIC: read attempt from unimplemented SCSI register");
return 0;
case 0x14: // Sound registers
switch (offset) { switch (offset) {
case AMICReg::Snd_Stat_0: case AMICReg::Snd_Stat_0:
case AMICReg::Snd_Stat_1: case AMICReg::Snd_Stat_1:
@ -89,6 +97,10 @@ uint32_t AMIC::read(uint32_t reg_start, uint32_t offset, int size)
return this->snd_out_ctrl; return this->snd_out_ctrl;
case AMICReg::Snd_Out_DMA: case AMICReg::Snd_Out_DMA:
return this->snd_out_dma->read_stat(); return this->snd_out_dma->read_stat();
}
}
switch(offset) {
case AMICReg::Diag_Reg: case AMICReg::Diag_Reg:
return 0xFFU; // this value allows the machine to boot normally return 0xFFU; // this value allows the machine to boot normally
case AMICReg::SCSI_DMA_Ctrl: case AMICReg::SCSI_DMA_Ctrl:
@ -103,11 +115,13 @@ void AMIC::write(uint32_t reg_start, uint32_t offset, uint32_t value, int size)
{ {
uint32_t mask; uint32_t mask;
if (offset < 0x2000) { // subdevices registers
switch(offset >> 12) {
case 0: // VIA1 registers
case 1:
this->viacuda->write(offset >> 9, value); this->viacuda->write(offset >> 9, value);
return; return;
} case 0x14: // Sound registers
switch(offset) { switch(offset) {
case AMICReg::Snd_Ctrl_0: case AMICReg::Snd_Ctrl_0:
case AMICReg::Snd_Ctrl_1: case AMICReg::Snd_Ctrl_1:
@ -121,7 +135,7 @@ void AMIC::write(uint32_t reg_start, uint32_t offset, uint32_t value, int size)
((this->imm_snd_regs[1] & 0xF) << 8) | this->imm_snd_regs[2] ((this->imm_snd_regs[1] & 0xF) << 8) | this->imm_snd_regs[2]
); );
} }
break; return;
case AMICReg::Snd_Buf_Size_Hi: case AMICReg::Snd_Buf_Size_Hi:
case AMICReg::Snd_Buf_Size_Lo: case AMICReg::Snd_Buf_Size_Lo:
mask = 0xFF00U >> (8 * (offset & 1)); mask = 0xFF00U >> (8 * (offset & 1));
@ -129,7 +143,7 @@ void AMIC::write(uint32_t reg_start, uint32_t offset, uint32_t value, int size)
((value & 0xFF) << (8 * ((offset & 1) ^1))); ((value & 0xFF) << (8 * ((offset & 1) ^1)));
this->snd_buf_size &= ~3; // sound buffer size is always a multiple of 4 this->snd_buf_size &= ~3; // sound buffer size is always a multiple of 4
LOG_F(9, "AMIC: Sound buffer size set to 0x%X", this->snd_buf_size); LOG_F(9, "AMIC: Sound buffer size set to 0x%X", this->snd_buf_size);
break; return;
case AMICReg::Snd_Out_Ctrl: case AMICReg::Snd_Out_Ctrl:
LOG_F(9, "AMIC Sound Out Ctrl updated, val=%x", value); LOG_F(9, "AMIC Sound Out Ctrl updated, val=%x", value);
if ((value & 1) != (this->snd_out_ctrl & 1)) { if ((value & 1) != (this->snd_out_ctrl & 1)) {
@ -146,13 +160,17 @@ void AMIC::write(uint32_t reg_start, uint32_t offset, uint32_t value, int size)
} }
} }
this->snd_out_ctrl = value; this->snd_out_ctrl = value;
break; return;
case AMICReg::Snd_In_Ctrl: case AMICReg::Snd_In_Ctrl:
LOG_F(INFO, "AMIC Sound In Ctrl updated, val=%x", value); LOG_F(INFO, "AMIC Sound In Ctrl updated, val=%x", value);
break; return;
case AMICReg::Snd_Out_DMA: case AMICReg::Snd_Out_DMA:
this->snd_out_dma->write_dma_out_ctrl(value); this->snd_out_dma->write_dma_out_ctrl(value);
break; return;
}
}
switch(offset) {
case AMICReg::VIA2_Slot_IER: case AMICReg::VIA2_Slot_IER:
LOG_F(INFO, "AMIC VIA2 Slot Interrupt Enable Register updated, val=%x", value); LOG_F(INFO, "AMIC VIA2 Slot Interrupt Enable Register updated, val=%x", value);
break; break;