athens: clean up initialization.

This commit is contained in:
Maxim Poliakovski 2024-04-15 14:12:49 +02:00
parent 14f75d834a
commit 751f964139
2 changed files with 16 additions and 8 deletions

View File

@ -1,6 +1,6 @@
/*
DingusPPC - The Experimental PowerPC Macintosh emulator
Copyright (C) 2018-22 divingkatae and maximum
Copyright (C) 2018-24 divingkatae and maximum
(theweirdo) spatium
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
@ -44,8 +44,16 @@ AthensClocks::AthensClocks(uint8_t dev_addr)
this->my_addr = dev_addr;
// set up power on values
// This initialization is not prescribed
// but let's set them to acceptable values anyway
this->regs[AthensRegs::D2] = 2;
this->regs[AthensRegs::N2] = 2;
// set P2_MUX2 on power up as follows:
// - dot clock VCO is disabled
// - dot clock = reference clock / 2
this->regs[AthensRegs::P2_MUX2] = 0x62;
}
void AthensClocks::start_transaction()
@ -72,9 +80,6 @@ bool AthensClocks::send_byte(uint8_t data)
return false; // return NACK
}
this->regs[this->reg_num] = data;
if (reg_num == 3) {
LOG_F(INFO, "Athens: dot clock frequency set to %d Hz", get_dot_freq());
}
break;
default:
LOG_F(WARNING, "Athens: too much data received!");
@ -138,5 +143,7 @@ int AthensClocks::get_dot_freq()
break;
}
LOG_F(INFO, "Athens: dot clock frequency set to %f Hz", out_freq);
return static_cast<int>(out_freq + 0.5f);
}

View File

@ -1,6 +1,6 @@
/*
DingusPPC - The Experimental PowerPC Macintosh emulator
Copyright (C) 2018-22 divingkatae and maximum
Copyright (C) 2018-24 divingkatae and maximum
(theweirdo) spatium
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
@ -31,7 +31,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#define ATHENS_NUM_REGS 8
constexpr auto ATHENS_XTAL = 31334400.0f; // external crystal oscillator frequency
/** Default external crystal oscillator frequency. */
constexpr auto ATHENS_XTAL = 31334400.0f;
namespace AthensRegs {
@ -69,7 +70,7 @@ private:
uint8_t reg_num = 0;
int pos = 0;
uint8_t regs[ATHENS_NUM_REGS];
uint8_t regs[ATHENS_NUM_REGS] = {};
};
#endif // ATHENS_H