el_pango
Member
Hi,
In my program, when I do the following, the console locks up:
CODE
/*****************************************************************************/
//! Change CPU frequency.
/*!
* ...on a GP2x, anyway.
* Does nothing and returns on a desktop.
* Gotten from http://wiki.gp2x.org/wiki/CPU_Frequency
*
* Don't use right now, it crashes
*/
void set_cpu_speed(int mhz)
{
int memfd;
unsigned long* memregs32;
unsigned short* memregs16;
#ifdef TARGET_GP2X
unsigned int v;
unsigned int mdiv,pdiv=3,scale=0;
memfd = open("/dev/mem", O_RDWR);
memregs32 = (unsigned long*) mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, 0xc0000000);
memregs16 = (unsigned short *)memregs32;
mhz*=1000000;
mdiv=(mhz*pdiv)/SYS_CLK_FREQ;
mdiv=((mdiv-8)<<8) & 0xff00;
pdiv=((pdiv-2)<<2) & 0xfc;
scale&=3;
v = mdiv | pdiv | scale;
unsigned int l = memregs32[0x808>>2]; // Get interupt flags
memregs32[0x808>>2] = 0xFF8FFFE7; // Turn off interrupts
memregs16[0x910>>1]=v; // Set frequentie
while(memregs16[0x0902>>1] & 1); // Wait for the frequentie to be ajused
memregs32[0x808>>2] = l; // Turn on interrupts
close(memfd);
#endif
}
Unfortunately, I don't have access to a serial cable, so I can't see any error output. Anyone know what might cause this?
This is on a MK2-F100 with firmware 2.1.1, and I'm working with HW-accelerated Allegro (0.3 with button fix). I am calling this before setting the graphics mode or calling any of Allegro's initialization functions, and I am trying to get the speed to 225, which has been known to work in other games on the same '2x.
Followup question - how does one go about setting the global gamma? I'm unable to find a doc that explains this...
In my program, when I do the following, the console locks up:
CODE
/*****************************************************************************/
//! Change CPU frequency.
/*!
* ...on a GP2x, anyway.
* Does nothing and returns on a desktop.
* Gotten from http://wiki.gp2x.org/wiki/CPU_Frequency
*
* Don't use right now, it crashes
*/
void set_cpu_speed(int mhz)
{
int memfd;
unsigned long* memregs32;
unsigned short* memregs16;
#ifdef TARGET_GP2X
unsigned int v;
unsigned int mdiv,pdiv=3,scale=0;
memfd = open("/dev/mem", O_RDWR);
memregs32 = (unsigned long*) mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, memfd, 0xc0000000);
memregs16 = (unsigned short *)memregs32;
mhz*=1000000;
mdiv=(mhz*pdiv)/SYS_CLK_FREQ;
mdiv=((mdiv-8)<<8) & 0xff00;
pdiv=((pdiv-2)<<2) & 0xfc;
scale&=3;
v = mdiv | pdiv | scale;
unsigned int l = memregs32[0x808>>2]; // Get interupt flags
memregs32[0x808>>2] = 0xFF8FFFE7; // Turn off interrupts
memregs16[0x910>>1]=v; // Set frequentie
while(memregs16[0x0902>>1] & 1); // Wait for the frequentie to be ajused
memregs32[0x808>>2] = l; // Turn on interrupts
close(memfd);
#endif
}
Unfortunately, I don't have access to a serial cable, so I can't see any error output. Anyone know what might cause this?
This is on a MK2-F100 with firmware 2.1.1, and I'm working with HW-accelerated Allegro (0.3 with button fix). I am calling this before setting the graphics mode or calling any of Allegro's initialization functions, and I am trying to get the speed to 225, which has been known to work in other games on the same '2x.
Followup question - how does one go about setting the global gamma? I'm unable to find a doc that explains this...