int freq=0;
int magic=0;
int div=0;
if (clock == gp32ClockEnum)
return;
clock &= 0x7f;
gp32ClockEnum = clock;
if (clock > gp32ClockEnumMax)
gp32ClockEnumMax = clock;
switch(clock)
{
// case GPMHZ_40: GpClockSpeedChange (40000000, 0x48013, 1); break;
// case GPMHZ_59: GpClockSpeedChange (59250000, 0x47022, 1); break;
case GPMHZ_67: freq=67500000; magic=0x25002; div=1; break;
case GPMHZ_80: freq=80000000; magic=0x48012; div=1; break;
case GPMHZ_99: freq=99000000; magic=0x3a002; div=2; break;
case GPMHZ_115: freq=115500000; magic=0x45021; div=2; break;
case GPMHZ_132: freq=132000000; magic=0x24001; div=2; break;
case GPMHZ_156: freq=156000000; magic=0x2c001; div=3; break;
case GPMHZ_165: freq=165000000; magic=0x2f001; div=3; break;
case GPMHZ_180: freq=180000000; magic=0x34001; div=3; break;
default:exit(0);
}
GpClockSpeedChange(freq, magic, div);
Aprint("Clock M:%d H:%d P:%d\n", GpMClkGet(), GpHClkGet(), GpPClkGet());
unsigned int pclk = GpPClkGet();
// Repair SDK timer - it forgets to set prescaler
//pclk/(x+1) ~= 8000*40
//x= (pclk/(8000*40)) -1
unsigned int prescaler0 = (pclk/(8000*40))-1;
rTCFG0 = (rTCFG0&0xFFFFFF00)|prescaler0;
rTCFG1 = 0x30033;
// Repair GpTickCountGet
// pclk/(100x) = 16
// x = pclk/1600
rTCNTB4 = pclk/1600;
// rTCON = (0x1<<22) | (0x1<<20);
// Repair display - driven off hclk
// HMM - looks like the sdk doesn't tweak clkval and I can't find anything else. Worst case we'll get < 2x lcd framerate (49.. vs 80 hck)
// Repair sound
#ifdef STEREO
GpPcmInit(PCM_S22, PCM_8BIT);
#else
GpPcmInit(PCM_M22, PCM_8BIT);
#endif
// Repair chatboard
preInitKbd(9600, GpPClkGet());