foft
Certified Guru
I'm trying to add a menu to change clock speed in the atari800 port. However...
It seems that GpClockSpeedChange does not update the timers or sound properly. I have found some partial fixes to these, but I'm obviously still missing some important parts... BTW I do know about the RTC, but its just not accurate enough and does not solve all the issues
Timers:
These all seem to be driven off one central hardware timer. The sdk only seems to have a different prescaler when started with different clocks. I adjusted the prescaler as follows following the call to GpClockSpeedChange:
unsigned int prescaler0 = (pclk/(8000*40))-1;
rTCFG0 = (rTCFG0&0xFFFFFF00)|prescaler0;
This seems to work when I start in 166 and go to any mode. However if I start in 156 it is off by a factor of two. Does anyone know where the additional multiplier comes from?
The SDK also seems to set up rTCNTB4 as follows. In my notes I say this is for GpTickCountGet, however I'm not sure if the above change already fixed that...
rTCNTB4 = pclk/1600;
Anyway with both these changes (+chatboard reinit) the emulator then runs at the correct speed.
Sound:
This sounds horrible after changing clock speed - wrong frequency and continual short gaps. It seems this is not handled by the main processor chip itself, but is controlled by the IIS? I found that making the following changes made the sound correct, but there is masses of interference. Presumably something else needs setting up? Anyone know what and how?
if (clock==GPMHZ_165)
{
rIISMOD=0x8d;
rIISPSR=0x84;
}
if (clock==GPMHZ_132)
{
rIISMOD=0x89;
rIISPSR=0x16b;
}
Any help gratefully appreciated!
Thanks,
Mark
It seems that GpClockSpeedChange does not update the timers or sound properly. I have found some partial fixes to these, but I'm obviously still missing some important parts... BTW I do know about the RTC, but its just not accurate enough and does not solve all the issues
Timers:
These all seem to be driven off one central hardware timer. The sdk only seems to have a different prescaler when started with different clocks. I adjusted the prescaler as follows following the call to GpClockSpeedChange:
unsigned int prescaler0 = (pclk/(8000*40))-1;
rTCFG0 = (rTCFG0&0xFFFFFF00)|prescaler0;
This seems to work when I start in 166 and go to any mode. However if I start in 156 it is off by a factor of two. Does anyone know where the additional multiplier comes from?
The SDK also seems to set up rTCNTB4 as follows. In my notes I say this is for GpTickCountGet, however I'm not sure if the above change already fixed that...
rTCNTB4 = pclk/1600;
Anyway with both these changes (+chatboard reinit) the emulator then runs at the correct speed.
Sound:
This sounds horrible after changing clock speed - wrong frequency and continual short gaps. It seems this is not handled by the main processor chip itself, but is controlled by the IIS? I found that making the following changes made the sound correct, but there is masses of interference. Presumably something else needs setting up? Anyone know what and how?
if (clock==GPMHZ_165)
{
rIISMOD=0x8d;
rIISPSR=0x84;
}
if (clock==GPMHZ_132)
{
rIISMOD=0x89;
rIISPSR=0x16b;
}
Any help gratefully appreciated!
Thanks,
Mark