cleanup: remove cpu ctrl files, move tests

This commit is contained in:
notaz 2009-05-22 18:33:46 +03:00
parent 9020645032
commit a6c41a382b
18 changed files with 7 additions and 3097 deletions

View File

@ -9,8 +9,7 @@ CC = $(PREFIX)/bin/arm-open2x-linux-gcc
STRIP = $(PREFIX)/bin/arm-open2x-linux-strip
OBJS = main.o cpu.o memory.u video.o input.o sound.o gp2x.o gui.o \
cheats.o zip.o cpu_threaded.z cpu_speed.o cpuctrl.o \
gp2xminilib.o font.o display.o speedtest.o cmdline.o daemon.o \
cheats.o zip.o cpu_threaded.z cpuctrl_mmsp2.o \
arm_stub.o video_blend.o flush_cache.o
BIN = gpsp.gpe

View File

@ -1,256 +0,0 @@
/* commandline.c for GP2X Version 2.0
Copyright (C) 2006 god_at_hell
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cpuctrl.h"
#include "gp2xminilib.h"
#include "cpuctrl.h"
void fallback(int argc, char *argv[])
{
//beginning commandline-utilizing
if (argc == 3)
{
if (atoi(argv[1]) == 0)
{
if(atoi(argv[2]) > 36){gp2x_deinit();exit(1);}
if(atoi(argv[2]) < -20){gp2x_deinit();exit(1);}
set_add_FLCDCLK(atoi(argv[2]));
}
else
{
if(atoi(argv[2]) > 10){gp2x_deinit();exit(1);}
if(atoi(argv[2]) < -5){gp2x_deinit();exit(1);}
set_add_ULCDCLK(atoi(argv[2]));
}
}
if (argc == 4)
{
if(atoi(argv[3]) > 320){gp2x_deinit();exit(1);}
if(atoi(argv[3]) < 33){gp2x_deinit();exit(1);}
if (atoi(argv[1]) == 0)
{
if(atoi(argv[2]) > 36){gp2x_deinit();exit(1);}
if(atoi(argv[2]) < -20){gp2x_deinit();exit(1);}
set_add_FLCDCLK(atoi(argv[2]));
}
else
{
if(atoi(argv[2]) > 10){gp2x_deinit();exit(1);}
if(atoi(argv[2]) < -5){gp2x_deinit();exit(1);}
set_add_ULCDCLK(atoi(argv[2]));
}
set_FCLK(atoi(argv[3]));
}
if (argc == 5)
{
if(atoi(argv[3]) > 320){gp2x_deinit();exit(1);}
if(atoi(argv[3]) < 33){gp2x_deinit();exit(1);}
if(atof(argv[4]) > 10){gp2x_deinit();exit(1);}
if(atof(argv[4]) < 0.02){gp2x_deinit();exit(1);}
if (atoi(argv[1]) == 0)
{
if(atoi(argv[2]) > 36){gp2x_deinit();exit(1);}
if(atoi(argv[2]) < -20){gp2x_deinit();exit(1);}
set_add_FLCDCLK(atoi(argv[2]));
}
else
{
if(atoi(argv[2]) > 10){gp2x_deinit();exit(1);}
if(atoi(argv[2]) < -5){gp2x_deinit();exit(1);}
set_add_ULCDCLK(atoi(argv[2]));
}
set_FCLK(atoi(argv[3]));
set_gamma(atof(argv[4]));
}
}
void cmdhelp()
{
printf ("\ngpSP2X v0.9003 Beta by Exophase/ZodTTD\r\n");
printf ("cpu_speed by god_at_hell\r\n");
printf ("Usage: cpu_speed.gpe [option1] [value1] [option2]...\r\n");
printf ("Options:\r\n");
printf (" RAM-Options\r\n");
printf (" -----------\r\n");
printf (" --cas CAS Latency. Delay in clock cycles between the registration \n\t\tof a READ command and the first bit of output data. \n\t\tValid values are 2 and 3 cycles.\r\n");
printf (" --trc ACTIVE to ACTIVE /AUTOREFRESH command delay. Defines ACTIVE \n\t\tto ACTIVE/auto refresh command period delay. \n\t\tValid values are from 1 to 16 cycles.\r\n");
printf (" --tras ACTIVE to PRECHARGE delay. Defines the delay between the ACTIVE \n\t\tand PRECHARGE commands. \n\t\tValid values are from 1 to 16 cycles.\r\n");
printf (" --twr Write recovery time in cycles.\n\t\tValid values are from 1 to 16 cycles.\r\n");
printf (" --tmrd LOAD MODE REGISTER command cycle time.\n\t\tValid values are from 1 to 16 cycles.\r\n");
printf (" --trfc AUTO REFRESH command period in cycles.\n\t\tValid values are from 1 to 16 cycles.\r\n");
printf (" --trp PRECHARGE command period in cycles.\n\t\tValid values are from 1 to 16 cycles.\r\n");
printf (" --trcd RAS to CAS Delay in cycles.\n\t\tValid values are from 1 to 16 cycles.\r\n");
printf (" --refperd Refresh Period. Defines maximum time period between \n\t\tAUTOREFRESH commands.\n\t\tValid values are from 1 to 65535 (default ~ 250) cycles.\r\n");
printf (" --ramdiv Divider for the Memory-Clock which is 1/2 of the CPU-Clock. \n\t\tValid values are from 1 to 8.\r\n");
printf ("\n CPU-Options\r\n");
printf (" -----------\r\n");
printf (" --cpuclk Sets the CPU-Frequency in Mhz. \n\t\tValid values are from 33 to 340.\r\n");
printf (" --cpudiv Divider for the CPU-Clock. \n\t\tValid values are from 1 to 8.\r\n");
printf ("\n Display-Options\r\n");
printf ("----------------\r\n");
printf (" --fpll Sets clockgenerator to fpll (for firmware 1.0 - 1.0.1).\r\n");
printf (" --upll Sets clockgenerator to upll (for the rest).\r\n");
printf (" --timing Timing Prescaler to eliminate flickering. \n\t\tValid values are: -20 to 36 with fpll.\n\t\t\t\t -6 to 10 with upll.\r\n");
printf (" --gamma Regulates the gamma. \n\t\tValid values are from 0.0001 to 15.0000.\r\n");
printf ("\n Daemon-Mode \r\n");
printf ("----------------\r\n");
printf ("Usage: cpu_speed.gpe --daemon [option1] [value1] [option2]...\r\n");
printf ("Shutdown: cpu_speed.gpe --kill[-daemon]\r\n");
printf ("Options:\r\n");
printf (" --min Sets the minimum CPU-Frequency in Mhz. \n\t\tValid values are from 33 to 340.\r\n");
printf (" --max Sets the maximum CPU-Frequency in Mhz. \n\t\tValid values are from 33 to 340.\r\n");
printf (" --start Sets the CPU-Frequency in Mhz. \n\t\tValid values are from 33 to 340.\r\n");
printf (" --step Sets the CPU-Frequency step in Mhz. \n\t\tValid values are from 1 to 340.\r\n");
printf (" --hotkey Sets the hotkey. (Default: LR) \n\t\tValid values are a combination of LRXYZAB+-S/@ or ``None''\n\t\t (+- are volume, S is Start, / is Select, @ is Stick).\r\n");
printf (" --incr Sets the increment key. (Default: +) \n\t\tValid values are a combination of LRXYZAB+-S/@ or ``None''\n\t\t (+- are volume, S is Start, / is Select, @ is Stick).\r\n");
printf (" --decr Sets the decrement key. (Default: -) \n\t\tValid values are a combination of LRXYZAB+-S/@ or ``None''\n\t\t (+- are volume, S is Start, / is Select, @ is Stick).\r\n");
printf (" --no-hotkey Alias for --hotkey None.\r\n");
printf (" --no-incr Alias for --incr None.\r\n");
printf (" --no-decr Alias for --decr None.\r\n");
printf (" --foreground Do not switch to daemon mode. (Useful for debugging)\r\n");
printf (" --background Switch to daemon mode. (Default)\r\n");
printf (" --display Enable on screen display. COMING SOON!\r\n");
printf (" --no-display Disable on screen display.\r\n");
printf ("\nNOTE:\nThe old commandline-settings are working ... read more about this in the readme\n\n");
}
void cmdline(int argc, char *argv[])
{
short i,n;
short varis = 11;
char clockgen = get_Clkgen();
char var[11][9]={"--cas","--trc","--tras","--twr","--tmrd","--trfc","--trp","--trcd","--ramdiv","--cpuclk","--cpudiv"};
short val[varis];
for(n=0;n<varis;n++) //initialize the variable-array
{
val[n] = -1;
}
short timing = -100;
int refperd = -1;
float gamma = -1.;
for(i=1; i<argc; i++)
{
if(strcmp(argv[i], "--fpll") == 0) clockgen = 0;
if(strcmp(argv[i], "--upll") == 0) clockgen = 1;
for(n=0; n<varis; n++)
{
if(strcmp(argv[i], var[n]) == 0)
{
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",var[n]);gp2x_deinit();exit(1);}
val[n] = atoi(argv[i+1]);
}
}
if(strcmp(argv[i], "--refperd") == 0)
{
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
refperd = atoi(argv[i+1]);
}
if(strcmp(argv[i], "--gamma") == 0)
{
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
gamma = atof(argv[i+1]);
}
if(strcmp(argv[i], "--timing") == 0)
{
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
timing = atoi(argv[i+1]);
}
}
if(clockgen == 0)
{
if(timing > -21)
{
if(timing < 37) set_add_FLCDCLK(timing);
}
else set_add_FLCDCLK(get_LCDClk(clockgen));
}
if(clockgen == 1)
{
if(timing > -7)
{
if(timing < 11) set_add_ULCDCLK(timing);
}
else set_add_ULCDCLK(get_LCDClk(clockgen));
}
if(refperd-1 > -1)
{
if(refperd-1 < 0xffff) set_REFPERD(refperd-1);
}
if(gamma > 0.)
{
if(gamma < 15.) set_gamma(gamma);
}
if(val[0]-2 > -1)
{
if(val[0]-2 < 2) set_CAS(val[0]-2);
}
if(val[1]-1 > -1)
{
if(val[1]-1 < 16) set_tRC(val[1]-1);
}
if(val[2]-1 > -1)
{
if(val[2]-1 < 16) set_tRAS(val[2]-1);
}
if(val[3]-1 > -1)
{
if(val[3]-1 < 16) set_tWR(val[3]-1);
}
if(val[4]-1 > -1)
{
if(val[4]-1 < 16) set_tMRD(val[4]-1);
}
if(val[5]-1 > -1)
{
if(val[5]-1 < 16) set_tRFC(val[5]-1);
}
if(val[6]-1 > -1)
{
if(val[6] < 16) set_tRP(val[6]-1);
}
if(val[7]-1 > -1)
{
if(val[7]-1 < 16) set_tRCD(val[7]-1);
}
if(val[8]-1 > -1)
{
if(val[8]-1 < 8) set_DCLK_Div(val[8]-1);
}
if(val[9] > 32)
{
if(val[9] < 341) set_FCLK(val[9]);
}
if(val[10]-1 > -1)
{
if(val[10]-1 < 8) set_920_Div(val[10]-1);
}
}

View File

@ -1,3 +0,0 @@
void fallback(int argc, char *argv[]);
void cmdhelp();
void cmdline(int argc, char *argv[]);

File diff suppressed because it is too large Load Diff

View File

@ -1,72 +0,0 @@
#if !defined(_CPUCTRL_)
#define _CPUCTRL_
void cpuctrl_init(); // call this at first
void save_system_regs(); // save some registers
void load_system_regs();
void set_FCLK(unsigned MHZ); // adjust the clock frequency (in Mhz units)
void set_add_ULCDCLK(int addclock);
void set_add_FLCDCLK(int addclock);
unsigned get_FCLK();
unsigned get_freq_UCLK();
unsigned get_freq_ACLK();
unsigned get_freq_920_CLK();
unsigned get_freq_940_CLK();
unsigned get_freq_DCLK();
unsigned get_LCDClk();
char get_Clkgen();
unsigned get_state940();
void set_920_Div(unsigned short div); /* 0 to 7 divider (freq=FCLK/(1+div)) */
unsigned short get_920_Div();
void set_940_Div(unsigned short div); /* 0 to 7 divider (freq=FCLK/(1+div)) */
unsigned short get_940_Div();
void set_DCLK_Div(unsigned short div); /* 0 to 7 divider (freq=FCLK/(1+div)) */
unsigned short get_DCLK_Div();
unsigned short Disable_Int_920();
unsigned short Disable_Int_940();
void Enable_Int_920(unsigned short flag);
void Enable_Int_940(unsigned short flag);
void Disable_940(); // 940t down
extern volatile unsigned *arm940code; // memory address of 940t code
void Load_940_code(unsigned *code,int size); // enable 940t, load 940t code and clock 940t off
void clock_940_off(); // 940t stops
void clock_940_on(); // 940t running
//Memory Timings
unsigned get_CAS(); //CAS Latency
unsigned get_tRC(); //ACTIVE to ACTIVE /AUTOREFRESH command delay
unsigned get_tRAS(); //ACTIVE to PRECHARGE delay
unsigned get_tWR(); //Write recovery time
unsigned get_tMRD(); //LOAD MODE REGISTER command cycle time
unsigned get_tRFC(); //AUTO REFRESH command period
unsigned get_tRP(); //PRECHARGE command period
unsigned get_tRCD(); //RAS to CAS Delay
unsigned get_REFPERD();//Refresh Period
void set_CAS();
void set_tRC();
void set_tRAS();
void set_tWR();
void set_tMRD();
void set_tRFC();
void set_tRP();
void set_tRCD();
void set_REFPERD();
void set_gamma(float gamma);
unsigned get_YBNKLVL();
void set_YBNKLVL(unsigned short val);
#endif

View File

@ -25,16 +25,16 @@
// CPU CONTROL
/****************************************************************************************************************************************/
#include <sys/mman.h>
//#include <sys/mman.h>
#include <math.h>
#include <stdio.h>
#include "gp2xminilib.h"
//#include "gp2xminilib.h"
#define SYS_CLK_FREQ 7372800
//from minimal library rlyeh
extern unsigned long gp2x_dev[4];
//extern unsigned long gp2x_dev[4];
extern unsigned short *gp2x_memregs;
// system registers
@ -117,6 +117,7 @@ unsigned get_FCLK()
return MEM_REG[0x910>>1];
}
#if 0
void set_add_FLCDCLK(int addclock)
{
//Set LCD controller to use FPLL
@ -320,6 +321,7 @@ void clock_940_on()
{
MEM_REG[0x904>>1]|=1;
}
#endif
//--------------

View File

@ -1,671 +0,0 @@
/* daemon.c for GP2X Version 2.0
Copyright (C) 2006 jannis harder
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
#include "gp2xminilib.h"
#include "cpuctrl.h"
#include "display.h"
#include "daemon.h"
extern unsigned COLORFONDO; // background-color
extern unsigned WHITE;
extern unsigned TEXTBACK;
extern unsigned char cad[256];
extern unsigned short *gp2x_memregs;
extern pthread_t gp2x_sound_thread;
int start_daemon(
unsigned int minimal_cpu_speed, unsigned int maximal_cpu_speed, unsigned int start_cpu_speed, int cpu_speed_step,
unsigned long hotkey, unsigned long incrementkey, unsigned long decrementkey,
int speed_display, int foreground,
unsigned long delay)
{
pid_t pid, sid;
if(!foreground) {
kill_running_daemon();
FILE * pidfile = fopen("/tmp/cpu_daemon.pid","w");
if(!pidfile) {
printf("couldn't write pidfile\r\n");
exit(-2);
}
pid = fork();
if(pid > 0) {
fprintf(pidfile,"%i\n",pid);
fclose(pidfile);
}
if(pid != 0)
return pid;
fclose(pidfile);
umask(0);
sid = setsid();
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
}
if(foreground)
printf("daemon ready\r\n");
nano_setup(); // loading the full minilib would be overkill and i guess some games/emus wouldn't like it
unsigned int current_cpu_speed = start_cpu_speed;
while(1) {
usleep(delay);
unsigned long keystate = gp2x_joystick_read();
unsigned int last_cpu_speed = 0;
while(
(hotkey && (keystate & hotkey) == hotkey) ||
((!hotkey) && (
(incrementkey && (keystate & incrementkey) == incrementkey) ||
(decrementkey && (keystate & decrementkey) == decrementkey)
))
) {
if(foreground && !last_cpu_speed)
printf("cpu daemon activated!\r\n");
if(incrementkey && (keystate & incrementkey) == incrementkey) {
current_cpu_speed += cpu_speed_step;
while((keystate & incrementkey) == incrementkey) usleep(100000),keystate = gp2x_joystick_read();
}
else if(decrementkey && (keystate & decrementkey) == decrementkey) {
current_cpu_speed -= cpu_speed_step;
while((keystate & decrementkey) == decrementkey) usleep(100000),keystate = gp2x_joystick_read();
}
if(current_cpu_speed < minimal_cpu_speed)
current_cpu_speed = minimal_cpu_speed;
if(current_cpu_speed > maximal_cpu_speed)
current_cpu_speed = maximal_cpu_speed;
if(last_cpu_speed != current_cpu_speed) {
set_FCLK(current_cpu_speed);
}
last_cpu_speed = current_cpu_speed;
keystate = gp2x_joystick_read();
}
}
}
int kill_running_daemon() {
FILE * pidfile = fopen("/tmp/cpu_daemon.pid","r");
char pid_buffer[14];
pid_buffer[0] = 'k';
pid_buffer[1] = 'i';
pid_buffer[2] = 'l';
pid_buffer[3] = 'l';
pid_buffer[4] = ' ';
pid_buffer[5] = 0;
if(pidfile) {
printf("found pidfile\r\n");
fgets(&(pid_buffer[5]),10,pidfile);
fclose(pidfile);
int return_code = system(pid_buffer);
if(return_code)
printf("daemon wasn't running\r\n");
else
printf("killed old daemon\r\n");
unlink("/tmp/cpu_daemon.pid");
return 1;
}
return 0;
}
void nano_setup() {
if(!gp2x_sound_thread) {
gp2x_memregs=(unsigned short *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, open("/dev/mem", O_RDWR), 0xc0000000);
cpuctrl_init();
}
}
void cmd_daemon(int argc, char *argv[]) {
int cpu_div = get_920_Div();
int sysfreq=get_freq_920_CLK();
sysfreq*=cpu_div+1;
int cpufreq=sysfreq/1000000;
unsigned int minimal_value = 33;
unsigned int maximal_value = 260;
unsigned int start_value = cpufreq;
unsigned int step = 10;
unsigned long hotkey = GP2X_L | GP2X_R;
unsigned long downkey = GP2X_VOL_UP;
unsigned long upkey = GP2X_VOL_DOWN;
int foreground = 0;
int display = 1;
float delay = 1;
int i;
for( i = 2; i < argc; i++) {
if(!strcmp(argv[i],"--min")) {
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
minimal_value = atoi(argv[i+1]);
if(minimal_value < 33)
minimal_value = 33;
}
else if(!strcmp(argv[i],"--max")) {
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
maximal_value = atoi(argv[i+1]);
if(maximal_value > 340)
maximal_value = 340;
}
else if(!strcmp(argv[i],"--start")) {
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
start_value = atoi(argv[i+1]);
}
else if(!strcmp(argv[i],"--step")) {
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
step = atoi(argv[i+1]);
}
else if(!strcmp(argv[i],"--hotkey")) {
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
hotkey = parse_key_sequence(argv[i+1]);
}
else if(!strcmp(argv[i],"--incr")) {
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
upkey = parse_key_sequence(argv[i+1]);
}
else if(!strcmp(argv[i],"--decr")) {
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
downkey = parse_key_sequence(argv[i+1]);
}
else if(!strcmp(argv[i],"--delay")) {
if(i+1 == argc){printf ("%s is missing it's parameter\r\n",argv[i]);gp2x_deinit();exit(1);}
delay = atof(argv[i+1]);
}
else if(!strcmp(argv[i],"--no-incr")) {
upkey = 0;
}
else if(!strcmp(argv[i],"--no-decr")) {
downkey = 0;
}
else if(!strcmp(argv[i],"--no-hotkey")) {
hotkey = 0;
}
else if(!strcmp(argv[i],"--foreground")) {
foreground = 1;
}
else if(!strcmp(argv[i],"--background")) {
foreground = 0;
}
else if(!strcmp(argv[i],"--display")) {
display = 1;
}
else if(!strcmp(argv[i],"--no-display")) {
display = 0;
}
}
if((hotkey & downkey) == downkey)
printf("warning: hotkey includes decrement keypress!\r\n");
if((hotkey & upkey) == upkey)
printf("warning: hotkey includes increment keypress!\r\n");
int pid = start_daemon(minimal_value, maximal_value, start_value, step, hotkey, upkey, downkey, display, foreground, delay* 1000000);
if(pid < 0) {
printf("couldn't start daemon\r\n");
exit(1);
}
else if(pid > 0) {
printf("daemon started\r\n");
exit(0);
}
}
unsigned long parse_key_sequence(char *key_sequence) {
unsigned long hotkey = 0;
if(!strcmp(key_sequence,"None"))
return 0;
char *mask = key_sequence;
while(*mask) {
switch(*mask) {
case 'l':
case 'L':
hotkey |= GP2X_L;
break;
case 'r':
case 'R':
hotkey |= GP2X_R;
break;
case 'a':
case 'A':
hotkey |= GP2X_A;
break;
case 'b':
case 'B':
hotkey |= GP2X_B;
break;
case 'x':
case 'X':
hotkey |= GP2X_X;
break;
case 'y':
case 'Y':
hotkey |= GP2X_Y;
break;
case '+':
hotkey |= GP2X_VOL_DOWN;
break;
case '-':
hotkey |= GP2X_VOL_UP;
break;
case 'S':
case 's':
hotkey |= GP2X_START;
break;
case '/':
hotkey |= GP2X_SELECT;
break;
case '@':
hotkey |= GP2X_PUSH;
break;
case '\n':
break;
default:
printf("unknown key %c\r\n",*mask);
}
mask++;
}
return hotkey;
}
int daemonsettings[8];
void cleardisp();
void formatkey(char * base, unsigned long keyseq) {
if(!keyseq)
strcat(base,"None");
if(keyseq & GP2X_L)
strcat(base,"L");
if(keyseq & GP2X_R)
strcat(base,"R");
if(keyseq & GP2X_A)
strcat(base,"A");
if(keyseq & GP2X_B)
strcat(base,"B");
if(keyseq & GP2X_X)
strcat(base,"X");
if(keyseq & GP2X_Y)
strcat(base,"Y");
if(keyseq & GP2X_VOL_DOWN)
strcat(base,"+");
if(keyseq & GP2X_VOL_UP)
strcat(base,"-");
if(keyseq & GP2X_START)
strcat(base,"S");
if(keyseq & GP2X_SELECT)
strcat(base,"/");
if(keyseq & GP2X_PUSH)
strcat(base,"@");
}
#define VALID_KEYS ((GP2X_L) | (GP2X_R) | (GP2X_X) | (GP2X_Y) | (GP2X_A) | (GP2X_B) | (GP2X_START) | (GP2X_SELECT) | (GP2X_VOL_UP) | (GP2X_VOL_DOWN) | (GP2X_PUSH) )
int running;
void daemon_itemhelp(int menuitem)
{
switch(menuitem) {
case 0:
v_putcad(26,8,0xffffff,COLORFONDO,"Choose a");
v_putcad(26,9,0xffffff,COLORFONDO,"minimal");
v_putcad(26,10,0xffffff,COLORFONDO,"clockspeed");
v_putcad(26,11,0xffffff,COLORFONDO,"with R/L or");
v_putcad(26,12,0xffffff,COLORFONDO,"Vol UP/Down.");
v_putcad(26,14,0xffffff,COLORFONDO,"Valid speeds");
v_putcad(26,15,0xffffff,COLORFONDO,"are:");
v_putcad(26,16,0xffffff,COLORFONDO,"33 to 340Mhz");
break;
case 1:
v_putcad(26,8,0xffffff,COLORFONDO,"Choose a");
v_putcad(26,9,0xffffff,COLORFONDO,"maximal");
v_putcad(26,10,0xffffff,COLORFONDO,"clockspeed");
v_putcad(26,11,0xffffff,COLORFONDO,"with R/L or");
v_putcad(26,12,0xffffff,COLORFONDO,"Vol UP/Down.");
v_putcad(26,14,0xffffff,COLORFONDO,"Valid speeds");
v_putcad(26,15,0xffffff,COLORFONDO,"are:");
v_putcad(26,16,0xffffff,COLORFONDO,"33 to 340Mhz");
break;
case 2:
v_putcad(26,8,0xffffff,COLORFONDO,"Choose a step");
v_putcad(26,9,0xffffff,COLORFONDO,"width for");
v_putcad(26,10,0xffffff,COLORFONDO,"changing the");
v_putcad(26,11,0xffffff,COLORFONDO,"clockspeed.");
v_putcad(26,13,0xffffff,COLORFONDO,"Use R/L or");
v_putcad(26,14,0xffffff,COLORFONDO,"Vol UP/Down.");
break;
case 3:
v_putcad(26,8,0xffffff,COLORFONDO,"Choose a");
v_putcad(26,9,0xffffff,COLORFONDO,"delay between");
v_putcad(26,10,0xffffff,COLORFONDO,"each hotkey");
v_putcad(26,11,0xffffff,COLORFONDO,"check");
v_putcad(26,13,0xffffff,COLORFONDO,"Use R/L or");
v_putcad(26,14,0xffffff,COLORFONDO,"Vol UP/Down.");
break;
case 4:
v_putcad(26,8,0xffffff,COLORFONDO,"Choose a");
v_putcad(26,9,0xffffff,COLORFONDO,"hotkey.");
v_putcad(26,10,0xffffff,COLORFONDO,"Add or delete");
v_putcad(26,11,0xffffff,COLORFONDO,"a button by");
v_putcad(26,12,0xffffff,COLORFONDO,"pressing it.");
v_putcad(26,14,0x0000DD,COLORFONDO,"Joystick is");
v_putcad(26,15,0x0000DD,COLORFONDO,"not allowed.");
break;
case 5:
v_putcad(26,8,0xffffff,COLORFONDO,"Choose a");
v_putcad(26,9,0xffffff,COLORFONDO,"key for");
v_putcad(26,10,0xffffff,COLORFONDO,"incrementing");
v_putcad(26,11,0xffffff,COLORFONDO,"the clkspeed.");
v_putcad(26,12,0xffffff,COLORFONDO,"Add or delete");
v_putcad(26,13,0xffffff,COLORFONDO,"a button by");
v_putcad(26,14,0xffffff,COLORFONDO,"pressing it.");
v_putcad(26,16,0x0000DD,COLORFONDO,"Joystick is");
v_putcad(26,17,0x0000DD,COLORFONDO,"not allowed.");
break;
case 6:
v_putcad(26,8,0xffffff,COLORFONDO,"Choose a");
v_putcad(26,9,0xffffff,COLORFONDO,"key for");
v_putcad(26,10,0xffffff,COLORFONDO,"decrementing");
v_putcad(26,11,0xffffff,COLORFONDO,"the clkspeed.");
v_putcad(26,12,0xffffff,COLORFONDO,"Add or delete");
v_putcad(26,13,0xffffff,COLORFONDO,"a button by");
v_putcad(26,14,0xffffff,COLORFONDO,"pressing it.");
v_putcad(26,16,0x0000DD,COLORFONDO,"Joystick is");
v_putcad(26,17,0x0000DD,COLORFONDO,"not allowed.");
break;
case 7:
/* v_putcad(26,8,0xffffff,COLORFONDO,"Enable or");
v_putcad(26,9,0xffffff,COLORFONDO,"disable");
v_putcad(26,10,0xffffff,COLORFONDO,"on screen");
v_putcad(26,11,0xffffff,COLORFONDO,"display.");
v_putcad(26,13,0x0000DD,COLORFONDO,"May cause");
v_putcad(26,14,0x0000DD,COLORFONDO,"conflicts");
v_putcad(26,15,0x0000DD,COLORFONDO,"with");
v_putcad(26,16,0x0000DD,COLORFONDO,"some apps!");*/
v_putcad(26,8,0x0000DD,COLORFONDO,"COMING SOON");
break;
case 8:
if(running) {
v_putcad(26,8,0xffffff,COLORFONDO,"Press B to");
v_putcad(26,9,0xffffff,COLORFONDO,"kill the");
v_putcad(26,10,0xffffff,COLORFONDO,"running");
v_putcad(26,11,0xffffff,COLORFONDO,"daemon");
v_putcad(26,12,0xffffff,COLORFONDO,"process.");
}
else {
v_putcad(26,8,0xffffff,COLORFONDO,"Press B to");
v_putcad(26,9,0xffffff,COLORFONDO,"start the ");
v_putcad(26,10,0xffffff,COLORFONDO,"daemon in the");
v_putcad(26,11,0xffffff,COLORFONDO, "background.");
}
break;
}
}
void daemonmenu() {
int menupoint = 0;
running = !access("/tmp/cpu_daemon.pid",R_OK);
unsigned long gp2x_nKeys;
while(1) {
if(daemonsettings[0] < 33)
daemonsettings[0] = 33;
if(daemonsettings[1] > 340)
daemonsettings[1] = 340;
if(daemonsettings[1] < daemonsettings[0])
daemonsettings[1] = daemonsettings[0];
if(daemonsettings[0] > daemonsettings[1])
daemonsettings[0] = daemonsettings[1];
if(daemonsettings[2] < 1)
daemonsettings[2] = 1;
if(daemonsettings[3] < 1)
daemonsettings[3] = 1;
//if(daemonsettings[7] == 10 || daemonsettings[7] == -10)
// daemonsettings[7] = 1;
//if(daemonsettings[7] == 11 || daemonsettings[7] == -9)
daemonsettings[7] = 0;
cleardisp();
v_putcad(13,2,WHITE,COLORFONDO,"Daemon Setup");
v_putcad(2,5,0xffff00,COLORFONDO,"CPU Clockspeed:");
sprintf(cad,"From: %huMhz",daemonsettings[0]);
v_putcad(2,7,0xffff,COLORFONDO,cad);
if(menupoint == 0)
v_putcad(2,7,0xffff,TEXTBACK,cad);
sprintf(cad,"To: %huMhz",daemonsettings[1]);
v_putcad(2,8,0xffff,COLORFONDO,cad);
if(menupoint == 1)
v_putcad(2,8,0xffff,TEXTBACK,cad);
sprintf(cad,"Step: %huMhz",daemonsettings[2]);
v_putcad(2,9,0xffff,COLORFONDO,cad);
if(menupoint == 2)
v_putcad(2,9,0xffff,TEXTBACK,cad);
v_putcad(2,11,0xffff00,COLORFONDO,"Buttons:");
sprintf(cad,"Delay: %0.1fsec",daemonsettings[3]/10.0f);
v_putcad(2,13,0xffff,COLORFONDO,cad);
if(menupoint == 3)
v_putcad(2,13,0xffff,TEXTBACK,cad);
sprintf(cad,"Hotkey: ");
formatkey(cad,daemonsettings[4]);
v_putcad(2,15,0xffff,COLORFONDO,cad);
if(menupoint == 4)
v_putcad(2,15,0xffff,TEXTBACK,cad);
sprintf(cad,"IncrKey: ");
formatkey(cad,daemonsettings[5]);
v_putcad(2,16,0xffff,COLORFONDO,cad);
if(menupoint == 5)
v_putcad(2,16,0xffff,TEXTBACK,cad);
sprintf(cad,"DecrKey: ");
formatkey(cad,daemonsettings[6]);
v_putcad(2,17,0xffff,COLORFONDO,cad);
if(menupoint == 6)
v_putcad(2,17,0xffff,TEXTBACK,cad);
if(menupoint >= 4 && menupoint <=6)
v_putcad(2,26,WHITE,COLORFONDO,"---------- Stick:UP/DOWN");
v_putcad(2,19,0xffff00,COLORFONDO,"Misc:");
v_putcad(2,21,0xffff,COLORFONDO,(daemonsettings[7] ? "On Screen Display: On" : "On Screen Display: Off"));
if(menupoint == 7)
v_putcad(2,21,0xffff,TEXTBACK,(daemonsettings[7] ? "On Screen Display: On" : "On Screen Display: Off"));
v_putcad(2,23,0xffff,COLORFONDO,(running ? "Kill Running Daemon" : "Start Daemon"));
if(menupoint == 8)
v_putcad(2,23,0xffff,TEXTBACK,(running ? "Kill Running Daemon" : "Start Daemon"));
daemon_itemhelp(menupoint);
gp2x_video_flip();
while(1)
{
gp2x_nKeys=gp2x_joystick_read();
if((gp2x_nKeys & GP2X_DOWN))
{
menupoint++;
if(menupoint>8) menupoint=0;
usleep(200000);
break;
}
if((gp2x_nKeys & GP2X_UP))
{
menupoint--;
if(menupoint<0) menupoint=8;
usleep(200000);
break;
}
if((menupoint >= 4) && (menupoint <= 6) && (gp2x_nKeys & VALID_KEYS))
{
daemonsettings[menupoint] ^= (gp2x_nKeys & VALID_KEYS);
usleep(200000);
break;
}
if(menupoint < 8 &&(gp2x_nKeys & GP2X_R))
{
daemonsettings[menupoint] += 10;
usleep(200000);
break;
}
if(menupoint < 4 && (gp2x_nKeys & GP2X_VOL_UP))
{
daemonsettings[menupoint] -= 1;
usleep(200000);
break;
}
if(menupoint < 4 && (gp2x_nKeys & GP2X_VOL_DOWN))
{
daemonsettings[menupoint] += 1;
usleep(200000);
break;
}
if(menupoint < 8 && (gp2x_nKeys & GP2X_L))
{
daemonsettings[menupoint] -= 10;
usleep(200000);
break;
}
if(menupoint == 8 && (gp2x_nKeys & GP2X_B))
{
if(running)
kill_running_daemon();
else {
int cpu_div = get_920_Div();
int sysfreq=get_freq_920_CLK();
sysfreq*=cpu_div+1;
int cpufreq=sysfreq/1000000;
start_daemon_by_settings();
}
usleep(200000);
running = !access("/tmp/cpu_daemon.pid",R_OK);
break;
}
if((gp2x_nKeys & GP2X_START))
{
while(1)
{
gp2x_nKeys=gp2x_joystick_read();
if(!(gp2x_nKeys & GP2X_START)) break;
}
if(running) { // update values!
start_daemon_by_settings();
}
return;
}
}
}
}
void start_daemon_by_settings() {
int cpu_div = get_920_Div();
int sysfreq=get_freq_920_CLK();
sysfreq*=cpu_div+1;
int cpufreq=sysfreq/1000000;
start_daemon(daemonsettings[0], daemonsettings[1], cpufreq, daemonsettings[2], daemonsettings[4], daemonsettings[5],
daemonsettings[6], daemonsettings[7], 0, daemonsettings[3] * 100000);
}

View File

@ -1,18 +0,0 @@
int start_daemon(
unsigned int minimal_cpu_speed, unsigned int maximal_cpu_speed, unsigned int start_cpu_speed, int cpu_speed_step,
unsigned long hotkey, unsigned long incrementkey, unsigned long decrmentkey,
int speed_display, int foreground,
unsigned long delay);
int kill_running_daemon();
void nano_setup();
void cmd_daemon(int argc, char *argv[]);
unsigned long parse_key_sequence(char *key_sequence);
void daemonmenu();
void formatkey(char * base, unsigned long keyseq);
void start_daemon_by_settings();

View File

@ -1,139 +0,0 @@
/* display.c for GP2X (CPU/LCD/RAM-Tuner Version 2.0)
Copyright (C) 2006 god_at_hell
original CPU-Overclocker (c) by Hermes/PS2Reality
parts (c) Rlyehs Work
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <math.h>
#include <unistd.h>
#include "gp2xminilib.h"
#include "cpuctrl.h"
#define WIDTH 320
#define HEIGHT 240
//unsigned TEXTBACK=0x900000; // text-background-color
extern unsigned char msx[]; // define la fuente externa usada para dibujar letras y numeros
void ClearScreen(unsigned val) // se usa para 'borrar' la pantalla virtual con un color
{
int n;
unsigned char *c;
unsigned short col;
c=&val;
col=gp2x_video_color15(c[0],c[1],c[2],0);
for(n=0;n<320*240;n++)
{
gp2x_screen15[n]=col;
}
}
void DrawBox(unsigned val)
{
int n;
unsigned char *c;
unsigned short col;
c=&val;
col=gp2x_video_color15(c[0],c[1],c[2],0);
for(n=320*27+2;n<320*28-1;n++)
{
gp2x_screen15[n]=col;
gp2x_screen15[n+320*209]=col;
}
for(n=320*29+4;n<320*30-3;n++)
{
gp2x_screen15[n]=col;
gp2x_screen15[n+320*169]=col;
gp2x_screen15[n+320*205]=col;
}
for(n=320*28;n<320*237;n=n+320)
{
gp2x_screen15[n+2]=col;
gp2x_screen15[n-2]=col;
}
for(n=320*30;n<320*235;n=n+320)
{
gp2x_screen15[n+4]=col;
gp2x_screen15[n-4]=col;
}
for(n=320*30;n<320*199;n=n+320)
{
gp2x_screen15[n-120]=col;
}
for(n=320*55-120;n<320*55-4;n++)
{
gp2x_screen15[n]=col;
}
}
void v_putchar( unsigned x, unsigned y, unsigned color, unsigned textback, unsigned char ch) // rutina usada para dibujar caracteres (coordenadas de 8x8)
{
int i,j,v;
unsigned char *font;
unsigned char *c;
unsigned short col,col2;
if(x>=WIDTH || y>=HEIGHT) return;
c=&color;
col=gp2x_video_color15(c[0],c[1],c[2],0);
c=&textback;
col2=gp2x_video_color15(c[0],c[1],c[2],0);
v=(y*320*8);
font = &msx[ (int)ch * 8];
for (i=0; i < 8; i++, font++)
{
for (j=0; j < 8; j++)
{
if ((*font & (128 >> j)))
{
gp2x_screen15[v+(((x<<3)+j))]=col;
}
else gp2x_screen15[v+(((x<<3)+j))]=col2;
}
v+=WIDTH;
}
}
// display array of chars
void v_putcad(int x,int y,unsigned color,unsigned textback,char *cad) // dibuja una cadena de texto
{
while(cad[0]!=0) {v_putchar(x,y,color,textback,cad[0]);cad++;x++;}
}
void gp2x_sound_frame(void *unused, unsigned char *stream, int samples)
{
int n;
short *pu;
pu=stream;
for(n=0;n<(samples);n++)
{
*pu++=0;*pu++=0;
}
}

View File

@ -1,5 +0,0 @@
void ClearScreen(unsigned val);
void DrawBox(unsigned val);
void v_putchar( unsigned x, unsigned y, unsigned color, unsigned textback, unsigned char ch);
void v_putcad(int x,int y,unsigned color,unsigned textback,char *cad);
void gp2x_sound_frame(void *unused, unsigned char *stream, int samples);

View File

@ -1,143 +0,0 @@
/*
_____ ___ ____
____| | ____| PSX2 OpenSource Project
| ___| |____ (C)2001, Gustavo Scotti (gustavo@scotti.com)
------------------------------------------------------------------------
font.c
EE UGLY DEBUG ON SCREEN - FONT BASE
This is mostly based on Duke's work
*/
//#include <tamtypes.h>
unsigned char msx[]=
"\x00\x00\x00\x00\x00\x00\x00\x00\x3c\x42\xa5\x81\xa5\x99\x42\x3c"
"\x3c\x7e\xdb\xff\xff\xdb\x66\x3c\x6c\xfe\xfe\xfe\x7c\x38\x10\x00"
"\x10\x38\x7c\xfe\x7c\x38\x10\x00\x10\x38\x54\xfe\x54\x10\x38\x00"
"\x10\x38\x7c\xfe\xfe\x10\x38\x00\x00\x00\x00\x30\x30\x00\x00\x00"
"\xff\xff\xff\xe7\xe7\xff\xff\xff\x38\x44\x82\x82\x82\x44\x38\x00"
"\xc7\xbb\x7d\x7d\x7d\xbb\xc7\xff\x0f\x03\x05\x79\x88\x88\x88\x70"
"\x38\x44\x44\x44\x38\x10\x7c\x10\x30\x28\x24\x24\x28\x20\xe0\xc0"
"\x3c\x24\x3c\x24\x24\xe4\xdc\x18\x10\x54\x38\xee\x38\x54\x10\x00"
"\x10\x10\x10\x7c\x10\x10\x10\x10\x10\x10\x10\xff\x00\x00\x00\x00"
"\x00\x00\x00\xff\x10\x10\x10\x10\x10\x10\x10\xf0\x10\x10\x10\x10"
"\x10\x10\x10\x1f\x10\x10\x10\x10\x10\x10\x10\xff\x10\x10\x10\x10"
"\x10\x10\x10\x10\x10\x10\x10\x10\x00\x00\x00\xff\x00\x00\x00\x00"
"\x00\x00\x00\x1f\x10\x10\x10\x10\x00\x00\x00\xf0\x10\x10\x10\x10"
"\x10\x10\x10\x1f\x00\x00\x00\x00\x10\x10\x10\xf0\x00\x00\x00\x00"
"\x81\x42\x24\x18\x18\x24\x42\x81\x01\x02\x04\x08\x10\x20\x40\x80"
"\x80\x40\x20\x10\x08\x04\x02\x01\x00\x10\x10\xff\x10\x10\x00\x00"
"\x00\x00\x00\x00\x00\x00\x00\x00\x20\x20\x20\x20\x00\x00\x20\x00"
"\x50\x50\x50\x00\x00\x00\x00\x00\x50\x50\xf8\x50\xf8\x50\x50\x00"
"\x20\x78\xa0\x70\x28\xf0\x20\x00\xc0\xc8\x10\x20\x40\x98\x18\x00"
"\x40\xa0\x40\xa8\x90\x98\x60\x00\x10\x20\x40\x00\x00\x00\x00\x00"
"\x10\x20\x40\x40\x40\x20\x10\x00\x40\x20\x10\x10\x10\x20\x40\x00"
"\x20\xa8\x70\x20\x70\xa8\x20\x00\x00\x20\x20\xf8\x20\x20\x00\x00"
"\x00\x00\x00\x00\x00\x20\x20\x40\x00\x00\x00\x78\x00\x00\x00\x00"
"\x00\x00\x00\x00\x00\x60\x60\x00\x00\x00\x08\x10\x20\x40\x80\x00"
"\x70\x88\x98\xa8\xc8\x88\x70\x00\x20\x60\xa0\x20\x20\x20\xf8\x00"
"\x70\x88\x08\x10\x60\x80\xf8\x00\x70\x88\x08\x30\x08\x88\x70\x00"
"\x10\x30\x50\x90\xf8\x10\x10\x00\xf8\x80\xe0\x10\x08\x10\xe0\x00"
"\x30\x40\x80\xf0\x88\x88\x70\x00\xf8\x88\x10\x20\x20\x20\x20\x00"
"\x70\x88\x88\x70\x88\x88\x70\x00\x70\x88\x88\x78\x08\x10\x60\x00"
"\x00\x00\x20\x00\x00\x20\x00\x00\x00\x00\x20\x00\x00\x20\x20\x40"
"\x18\x30\x60\xc0\x60\x30\x18\x00\x00\x00\xf8\x00\xf8\x00\x00\x00"
"\xc0\x60\x30\x18\x30\x60\xc0\x00\x70\x88\x08\x10\x20\x00\x20\x00"
"\x70\x88\x08\x68\xa8\xa8\x70\x00\x20\x50\x88\x88\xf8\x88\x88\x00"
"\xf0\x48\x48\x70\x48\x48\xf0\x00\x30\x48\x80\x80\x80\x48\x30\x00"
"\xe0\x50\x48\x48\x48\x50\xe0\x00\xf8\x80\x80\xf0\x80\x80\xf8\x00"
"\xf8\x80\x80\xf0\x80\x80\x80\x00\x70\x88\x80\xb8\x88\x88\x70\x00"
"\x88\x88\x88\xf8\x88\x88\x88\x00\x70\x20\x20\x20\x20\x20\x70\x00"
"\x38\x10\x10\x10\x90\x90\x60\x00\x88\x90\xa0\xc0\xa0\x90\x88\x00"
"\x80\x80\x80\x80\x80\x80\xf8\x00\x88\xd8\xa8\xa8\x88\x88\x88\x00"
"\x88\xc8\xc8\xa8\x98\x98\x88\x00\x70\x88\x88\x88\x88\x88\x70\x00"
"\xf0\x88\x88\xf0\x80\x80\x80\x00\x70\x88\x88\x88\xa8\x90\x68\x00"
"\xf0\x88\x88\xf0\xa0\x90\x88\x00\x70\x88\x80\x70\x08\x88\x70\x00"
"\xf8\x20\x20\x20\x20\x20\x20\x00\x88\x88\x88\x88\x88\x88\x70\x00"
"\x88\x88\x88\x88\x50\x50\x20\x00\x88\x88\x88\xa8\xa8\xd8\x88\x00"
"\x88\x88\x50\x20\x50\x88\x88\x00\x88\x88\x88\x70\x20\x20\x20\x00"
"\xf8\x08\x10\x20\x40\x80\xf8\x00\x70\x40\x40\x40\x40\x40\x70\x00"
"\x00\x00\x80\x40\x20\x10\x08\x00\x70\x10\x10\x10\x10\x10\x70\x00"
"\x20\x50\x88\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf8\x00"
"\x40\x20\x10\x00\x00\x00\x00\x00\x00\x00\x70\x08\x78\x88\x78\x00"
"\x80\x80\xb0\xc8\x88\xc8\xb0\x00\x00\x00\x70\x88\x80\x88\x70\x00"
"\x08\x08\x68\x98\x88\x98\x68\x00\x00\x00\x70\x88\xf8\x80\x70\x00"
"\x10\x28\x20\xf8\x20\x20\x20\x00\x00\x00\x68\x98\x98\x68\x08\x70"
"\x80\x80\xf0\x88\x88\x88\x88\x00\x20\x00\x60\x20\x20\x20\x70\x00"
"\x10\x00\x30\x10\x10\x10\x90\x60\x40\x40\x48\x50\x60\x50\x48\x00"
"\x60\x20\x20\x20\x20\x20\x70\x00\x00\x00\xd0\xa8\xa8\xa8\xa8\x00"
"\x00\x00\xb0\xc8\x88\x88\x88\x00\x00\x00\x70\x88\x88\x88\x70\x00"
"\x00\x00\xb0\xc8\xc8\xb0\x80\x80\x00\x00\x68\x98\x98\x68\x08\x08"
"\x00\x00\xb0\xc8\x80\x80\x80\x00\x00\x00\x78\x80\xf0\x08\xf0\x00"
"\x40\x40\xf0\x40\x40\x48\x30\x00\x00\x00\x90\x90\x90\x90\x68\x00"
"\x00\x00\x88\x88\x88\x50\x20\x00\x00\x00\x88\xa8\xa8\xa8\x50\x00"
"\x00\x00\x88\x50\x20\x50\x88\x00\x00\x00\x88\x88\x98\x68\x08\x70"
"\x00\x00\xf8\x10\x20\x40\xf8\x00\x18\x20\x20\x40\x20\x20\x18\x00"
"\x20\x20\x20\x00\x20\x20\x20\x00\xc0\x20\x20\x10\x20\x20\xc0\x00"
"\x40\xa8\x10\x00\x00\x00\x00\x00\x00\x00\x20\x50\xf8\x00\x00\x00"
"\x70\x88\x80\x80\x88\x70\x20\x60\x90\x00\x00\x90\x90\x90\x68\x00"
"\x10\x20\x70\x88\xf8\x80\x70\x00\x20\x50\x70\x08\x78\x88\x78\x00"
"\x48\x00\x70\x08\x78\x88\x78\x00\x20\x10\x70\x08\x78\x88\x78\x00"
"\x20\x00\x70\x08\x78\x88\x78\x00\x00\x70\x80\x80\x80\x70\x10\x60"
"\x20\x50\x70\x88\xf8\x80\x70\x00\x50\x00\x70\x88\xf8\x80\x70\x00"
"\x20\x10\x70\x88\xf8\x80\x70\x00\x50\x00\x00\x60\x20\x20\x70\x00"
"\x20\x50\x00\x60\x20\x20\x70\x00\x40\x20\x00\x60\x20\x20\x70\x00"
"\x50\x00\x20\x50\x88\xf8\x88\x00\x20\x00\x20\x50\x88\xf8\x88\x00"
"\x10\x20\xf8\x80\xf0\x80\xf8\x00\x00\x00\x6c\x12\x7e\x90\x6e\x00"
"\x3e\x50\x90\x9c\xf0\x90\x9e\x00\x60\x90\x00\x60\x90\x90\x60\x00"
"\x90\x00\x00\x60\x90\x90\x60\x00\x40\x20\x00\x60\x90\x90\x60\x00"
"\x40\xa0\x00\xa0\xa0\xa0\x50\x00\x40\x20\x00\xa0\xa0\xa0\x50\x00"
"\x90\x00\x90\x90\xb0\x50\x10\xe0\x50\x00\x70\x88\x88\x88\x70\x00"
"\x50\x00\x88\x88\x88\x88\x70\x00\x20\x20\x78\x80\x80\x78\x20\x20"
"\x18\x24\x20\xf8\x20\xe2\x5c\x00\x88\x50\x20\xf8\x20\xf8\x20\x00"
"\xc0\xa0\xa0\xc8\x9c\x88\x88\x8c\x18\x20\x20\xf8\x20\x20\x20\x40"
"\x10\x20\x70\x08\x78\x88\x78\x00\x10\x20\x00\x60\x20\x20\x70\x00"
"\x20\x40\x00\x60\x90\x90\x60\x00\x20\x40\x00\x90\x90\x90\x68\x00"
"\x50\xa0\x00\xa0\xd0\x90\x90\x00\x28\x50\x00\xc8\xa8\x98\x88\x00"
"\x00\x70\x08\x78\x88\x78\x00\xf8\x00\x60\x90\x90\x90\x60\x00\xf0"
"\x20\x00\x20\x40\x80\x88\x70\x00\x00\x00\x00\xf8\x80\x80\x00\x00"
"\x00\x00\x00\xf8\x08\x08\x00\x00\x84\x88\x90\xa8\x54\x84\x08\x1c"
"\x84\x88\x90\xa8\x58\xa8\x3c\x08\x20\x00\x00\x20\x20\x20\x20\x00"
"\x00\x00\x24\x48\x90\x48\x24\x00\x00\x00\x90\x48\x24\x48\x90\x00"
"\x28\x50\x20\x50\x88\xf8\x88\x00\x28\x50\x70\x08\x78\x88\x78\x00"
"\x28\x50\x00\x70\x20\x20\x70\x00\x28\x50\x00\x20\x20\x20\x70\x00"
"\x28\x50\x00\x70\x88\x88\x70\x00\x50\xa0\x00\x60\x90\x90\x60\x00"
"\x28\x50\x00\x88\x88\x88\x70\x00\x50\xa0\x00\xa0\xa0\xa0\x50\x00"
"\xfc\x48\x48\x48\xe8\x08\x50\x20\x00\x50\x00\x50\x50\x50\x10\x20"
"\xc0\x44\xc8\x54\xec\x54\x9e\x04\x10\xa8\x40\x00\x00\x00\x00\x00"
"\x00\x20\x50\x88\x50\x20\x00\x00\x88\x10\x20\x40\x80\x28\x00\x00"
"\x7c\xa8\xa8\x68\x28\x28\x28\x00\x38\x40\x30\x48\x48\x30\x08\x70"
"\x00\x00\x00\x00\x00\x00\xff\xff\xf0\xf0\xf0\xf0\x0f\x0f\x0f\x0f"
"\x00\x00\xff\xff\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00"
"\x00\x00\x00\x3c\x3c\x00\x00\x00\xff\xff\xff\xff\xff\xff\x00\x00"
"\xc0\xc0\xc0\xc0\xc0\xc0\xc0\xc0\x0f\x0f\x0f\x0f\xf0\xf0\xf0\xf0"
"\xfc\xfc\xfc\xfc\xfc\xfc\xfc\xfc\x03\x03\x03\x03\x03\x03\x03\x03"
"\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x3f\x11\x22\x44\x88\x11\x22\x44\x88"
"\x88\x44\x22\x11\x88\x44\x22\x11\xfe\x7c\x38\x10\x00\x00\x00\x00"
"\x00\x00\x00\x00\x10\x38\x7c\xfe\x80\xc0\xe0\xf0\xe0\xc0\x80\x00"
"\x01\x03\x07\x0f\x07\x03\x01\x00\xff\x7e\x3c\x18\x18\x3c\x7e\xff"
"\x81\xc3\xe7\xff\xff\xe7\xc3\x81\xf0\xf0\xf0\xf0\x00\x00\x00\x00"
"\x00\x00\x00\x00\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x00\x00\x00\x00"
"\x00\x00\x00\x00\xf0\xf0\xf0\xf0\x33\x33\xcc\xcc\x33\x33\xcc\xcc"
"\x00\x20\x20\x50\x50\x88\xf8\x00\x20\x20\x70\x20\x70\x20\x20\x00"
"\x00\x00\x00\x50\x88\xa8\x50\x00\xff\xff\xff\xff\xff\xff\xff\xff"
"\x00\x00\x00\x00\xff\xff\xff\xff\xf0\xf0\xf0\xf0\xf0\xf0\xf0\xf0"
"\x0f\x0f\x0f\x0f\x0f\x0f\x0f\x0f\xff\xff\xff\xff\x00\x00\x00\x00"
"\x00\x00\x68\x90\x90\x90\x68\x00\x30\x48\x48\x70\x48\x48\x70\xc0"
"\xf8\x88\x80\x80\x80\x80\x80\x00\xf8\x50\x50\x50\x50\x50\x98\x00"
"\xf8\x88\x40\x20\x40\x88\xf8\x00\x00\x00\x78\x90\x90\x90\x60\x00"
"\x00\x50\x50\x50\x50\x68\x80\x80\x00\x50\xa0\x20\x20\x20\x20\x00"
"\xf8\x20\x70\xa8\xa8\x70\x20\xf8\x20\x50\x88\xf8\x88\x50\x20\x00"
"\x70\x88\x88\x88\x50\x50\xd8\x00\x30\x40\x40\x20\x50\x50\x50\x20"
"\x00\x00\x00\x50\xa8\xa8\x50\x00\x08\x70\xa8\xa8\xa8\x70\x80\x00"
"\x38\x40\x80\xf8\x80\x40\x38\x00\x70\x88\x88\x88\x88\x88\x88\x00"
"\x00\xf8\x00\xf8\x00\xf8\x00\x00\x20\x20\xf8\x20\x20\x00\xf8\x00"
"\xc0\x30\x08\x30\xc0\x00\xf8\x00\x18\x60\x80\x60\x18\x00\xf8\x00"
"\x10\x28\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\xa0\x40"
"\x00\x20\x00\xf8\x00\x20\x00\x00\x00\x50\xa0\x00\x50\xa0\x00\x00"
"\x00\x18\x24\x24\x18\x00\x00\x00\x00\x30\x78\x78\x30\x00\x00\x00"
"\x00\x00\x00\x00\x30\x00\x00\x00\x3e\x20\x20\x20\xa0\x60\x20\x00"
"\xa0\x50\x50\x50\x00\x00\x00\x00\x40\xa0\x20\x40\xe0\x00\x00\x00"
"\x00\x38\x38\x38\x38\x38\x38\x00\x00\x00\x00\x00\x00\x00\x00";

View File

@ -34,7 +34,7 @@ u32 gpsp_gp2x_dev = 0;
volatile u16 *gpsp_gp2x_memregs;
volatile u32 *gpsp_gp2x_memregl;
extern unsigned short *gp2x_memregs;
unsigned short *gp2x_memregs;
static volatile u16 *MEM_REG;

View File

@ -1,242 +0,0 @@
/*
GP2X minimal library v0.5 by rlyeh, 2005.
+ GP2X video library with double buffering.
+ GP2X soundring buffer library with double buffering.
+ GP2X joystick library.
Thanks to Squidge, Robster, snaff and NK, for the help & previous work! :-)
What's new
==========
0.5: patched sound for real stereo (using NK's solution); better init code.
0.4: lots of cleanups; sound is threaded now, double buffered too; 8 bpp video support; better exiting code.
0.3: shorter library; improved joystick diagonal detection.
0.2: better code layout; public release.
0.1: beta release
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <linux/fb.h>
#include <pthread.h>
#include "gp2xminilib.h"
extern void gp2x_sound_frame(void *blah, void *bufferg, int samples);
unsigned long gp2x_dev[4]={0,0,0,0}, gp2x_physvram[4];
unsigned short *gp2x_memregs, *gp2x_screen15, *gp2x_logvram15[2], gp2x_sound_buffer[4+(44100*2)*4]; //*2=stereo, *4=max buffers
volatile unsigned short gp2x_palette[512][2];
unsigned char *gp2x_screen8, *gp2x_logvram8[2];
pthread_t gp2x_sound_thread=0, gp2x_sound_thread_exit=0;
void gp2x_video_flip(void)
{
unsigned long address=gp2x_physvram[gp2x_physvram[3]];
gp2x_screen15=gp2x_logvram15[gp2x_physvram[3]^=1];
gp2x_screen8 =gp2x_logvram8 [gp2x_physvram[3] ];
gp2x_memregs[0x290E>>1]=(unsigned short)(address & 0xffff);
gp2x_memregs[0x2910>>1]=(unsigned short)(address >> 16);
gp2x_memregs[0x2912>>1]=(unsigned short)(address & 0xffff);
gp2x_memregs[0x2914>>1]=(unsigned short)(address >> 16);
}
void gp2x_video_setpalette(void)
{int i;
gp2x_memregs[0x2958>>1]=0;
for(i=0; i<512; i++) gp2x_memregs[0x295A>>1]=gp2x_palette[i][0], gp2x_memregs[0x295A>>1]=gp2x_palette[i][1];
}
unsigned long gp2x_joystick_read(void)
{
unsigned long value=(gp2x_memregs[0x1198>>1] & 0x00FF);
if(value==0xFD) value=0xFA;
if(value==0xF7) value=0xEB;
if(value==0xDF) value=0xAF;
if(value==0x7F) value=0xBE;
return ~((gp2x_memregs[0x1184>>1] & 0xFF00) | value | (gp2x_memregs[0x1186>>1] << 16));
}
#if 0
void *gp2x_sound_play(void *blah)
{
struct timespec ts;
int flip=0;
ts.tv_sec=0, ts.tv_nsec=gp2x_sound_buffer[2];
while(! gp2x_sound_thread_exit)
{
gp2x_sound_frame(blah, (void *)(&gp2x_sound_buffer[4+flip]), gp2x_sound_buffer[0]);
write(gp2x_dev[3], (void *)(&gp2x_sound_buffer[4+flip]), gp2x_sound_buffer[1]);
flip^=gp2x_sound_buffer[1];
//nanosleep(&ts, NULL);
}
return NULL;
}
#endif
void gp2x_deinit(void)
{int i;
if(gp2x_sound_thread) { gp2x_sound_thread_exit=1; for(i=0;i<1000000;i++); }
gp2x_memregs[0x28DA>>1]=0x4AB;
gp2x_memregs[0x290C>>1]=640;
close(gp2x_dev[0]);
close(gp2x_dev[1]);
close(gp2x_dev[2]);
//close(gp2x_dev[3]);
//fcloseall();
}
void gp2x_init(int bpp, int rate, int bits, int stereo, int Hz)
{
struct fb_fix_screeninfo fixed_info;
if(!gp2x_dev[0]) gp2x_dev[0] = open("/dev/fb0", O_RDWR);
if(!gp2x_dev[1]) gp2x_dev[1] = open("/dev/fb1", O_RDWR);
if(!gp2x_dev[2]) gp2x_dev[2] = open("/dev/mem", O_RDWR);
//if(!gp2x_dev[3]) gp2x_dev[3] = open("/dev/dsp", O_WRONLY);
gp2x_memregs=(unsigned short *)mmap(0, 0x10000, PROT_READ|PROT_WRITE, MAP_SHARED, gp2x_dev[2], 0xc0000000);
if(!gp2x_sound_thread) { gp2x_memregs[0x0F16>>1] = 0x830a; sleep(1);
gp2x_memregs[0x0F58>>1] = 0x100c; sleep(1); }
ioctl (gp2x_dev[0], FBIOGET_FSCREENINFO, &fixed_info);
gp2x_screen15=gp2x_logvram15[0]=(unsigned short *)mmap(0, 320*240*2, PROT_WRITE, MAP_SHARED, gp2x_dev[0], 0);
gp2x_screen8=gp2x_logvram8[0]=(unsigned char *)gp2x_logvram15[0];
gp2x_physvram[0]=fixed_info.smem_start;
ioctl (gp2x_dev[1], FBIOGET_FSCREENINFO, &fixed_info);
gp2x_logvram15[1]=(unsigned short *)mmap(0, 320*240*2, PROT_WRITE, MAP_SHARED, gp2x_dev[1], 0);
gp2x_logvram8[1]=(unsigned char *)gp2x_logvram15[1];
gp2x_physvram[1]=fixed_info.smem_start;
gp2x_memregs[0x28DA>>1]=(((bpp+1)/8)<<9)|0xAB; /*8/15/16/24bpp...*/
gp2x_memregs[0x290C>>1]=320*((bpp+1)/8); /*line width in bytes*/
ioctl(gp2x_dev[3], SNDCTL_DSP_SPEED, &rate);
ioctl(gp2x_dev[3], SNDCTL_DSP_SETFMT, &bits);
ioctl(gp2x_dev[3], SNDCTL_DSP_STEREO, &stereo);
gp2x_sound_buffer[1]=(gp2x_sound_buffer[0]=(rate/Hz)) << (stereo + (bits==16));
gp2x_sound_buffer[2]=(1000000/Hz);
if(!gp2x_sound_thread) { gp2x_sound_thread = 1; //pthread_create( &gp2x_sound_thread, NULL, gp2x_sound_play, NULL);
atexit(gp2x_deinit); }
}
/*
EXAMPLE
=======
now supply your own function for 16 bits, stereo:
void gp2x_sound_frame(void *blah, void *bufferg, int samples)
{
signed short *buffer=(signed short *)bufferg;
while(samples--)
{
*buffer++=0; //Left channel
*buffer++=0; //Right channel
}
}
or 16 bits mono:
void gp2x_sound_frame(void *blah, void *bufferg, int samples)
{
signed short *buffer=(signed short *)bufferg;
while(samples--)
{
*buffer++=0; //Central channel
}
}
now the main program...
hicolor example:
int main(int argc, char *argv[])
{
//this sets video to hicolor (16 bpp)
//it also sets sound to 44100,16bits,stereo and syncs audio to 50 Hz (PAL timing)
//Warning: GP2X does not support 8bit sound sampling! (at least within Linux)
gp2x_init(16,44100,16,1,50);
while(1)
{
unsigned long pad=gp2x_joystick_read();
unsigned short color=gp2x_video_color15(255,255,255,0);
if(pad & GP2X_L) if(pad & GP2X_R) exit();
if(pad & GP2X_A) color=gp2x_color15(255,255,255,0); //white
else color=gp2x_color15(255,0,0,0); //red
gp2x_screen15[160+120*320]=color; //x=160, y=120
gp2x_video_flip();
}
}
palettized example:
int main(int argc, char *argv[])
{
//this sets video to palette mode (8 bpp)
//it also sets sound to 11025,16bits,stereo and syncs audio to 60 Hz (NSTC timing)
//Warning: GP2X does not support 8bit sound sampling! (at least within Linux)
gp2x_init(8,11025,16,1,60);
gp2x_video_color8(0,0,0,0); //color #0 is black for us
gp2x_video_color8(1,255,255,255); //color #1 is white for us
gp2x_video_color8(2,255,0,0); //color #2 is red for us
gp2x_video_setpalette();
while(1)
{
unsigned long pad=gp2x_joystick_read();
unsigned char color;
if(pad & GP2X_L) if(pad & GP2X_R) exit();
if(pad & GP2X_A) color=1; //white
else color=2; //red
gp2x_screen8[160+120*320]=color; //x=160, y=120
gp2x_video_flip();
}
}
*/

View File

@ -1,58 +0,0 @@
/*
GP2X minimal library v0.5 by rlyeh, 2005.
+ GP2X video library with double buffering.
+ GP2X soundring buffer library with double buffering.
+ GP2X joystick library.
Thanks to Squidge, Robster, snaff and NK, for the help & previous work! :-)
What's new
==========
0.5: patched sound for real stereo (using NK's solution); better init code.
0.4: lots of cleanups; sound is threaded now, double buffered too; 8 bpp video support; better exiting code.
0.3: shorter library; improved joystick diagonal detection.
0.2: better code layout; public release.
0.1: beta release
*/
/* .h by Hermes/PS2Reality*/
#if !defined(GP2XMINILIB)
#define GP2XMINILIB
enum { GP2X_UP=0x1, GP2X_LEFT=0x4, GP2X_DOWN=0x10, GP2X_RIGHT=0x40,
GP2X_START=1<<8, GP2X_SELECT=1<<9, GP2X_L=1<<10, GP2X_R=1<<11,
GP2X_A=1<<12, GP2X_B=1<<13, GP2X_X=1<<14, GP2X_Y=1<<15,
GP2X_VOL_UP=1<<22, GP2X_VOL_DOWN=1<<23, GP2X_PUSH=1<<27, };
#define gp2x_video_color15(R,G,B,A) (((R&0xF8)<<8)|((G&0xF8)<<3)|((B&0xF8)>>3)|(A<<5))
#define gp2x_video_color8 (C,R,G,B) gp2x_palette[C][0]=(G<<8)|B,gp2x_palette[C][1]=R;
extern unsigned short *gp2x_memregs, *gp2x_screen15, *gp2x_logvram15[2], gp2x_sound_buffer[4+(44100*2)*4]; //*2=stereo, *4=max buffers
extern unsigned long gp2x_dev[4];
void gp2x_video_flip(void);
void gp2x_video_setpalette(void);
unsigned long gp2x_joystick_read(void);
void *gp2x_sound_play(void *blah);
void gp2x_deinit(void);
void gp2x_init(int bpp, int rate, int bits, int stereo, int Hz);
#endif

View File

@ -1,205 +0,0 @@
/* speedtest.c for GP2X (CPU/LCD/RAM-Tuner Version 2.0)
Copyright (C) 2006 god_at_hell
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <math.h>
#include <unistd.h>
#include "display.h"
#include "cpuctrl.h"
#include "gp2xminilib.h"
void prim()
{
//FILE *primout;
unsigned char cad[256];
char p = 0;
int primnumber;
int l = 1;
float g = 0;
int i = 3;
while(i != 500000)
{
int m = 2;
float temp = sqrt(i);
float ifloat = (float)i;
if(temp == (int)temp)
{
m = i;
p = 1;
}
while(m < temp)
{
g = ifloat/m;
if (g == (int)g)
{
m = i;
p = 1;
}
m++;
}
if (p == 0)
{
l += 1;
primnumber = i;
sprintf(cad,"%u is primnumber",i);
v_putcad(1,13,0xffffff,0xB00000,cad);
//primout = fopen("/mnt/sd/primnumber.txt", "a");
//fprintf(primout,"%u: %u\n", l, i);
//fclose(primout);
//execl("sync",NULL);
gp2x_video_flip();
}
p = 0;
i++;
}
}
void ant()
{
int i,n;
unsigned char cad[256];
short direction = 0; //clockwise ... 0 = Up, 1 = Right
unsigned short col1, col2;
col1=gp2x_video_color15(0,0,0,0);
col2=gp2x_video_color15(0xFF,0xFF,0xFF,0);
short antx = 200;
short anty = 140;
for(i = 0; i < 9000; i++)
{
for(n = 0; n < 500000; n++);
if(gp2x_screen15[(320*anty) + antx]==col1)
{
for(n = 0; n < 3; n++)
{
int m = 0;
for(m = 0; m < 3; m++)
{
gp2x_screen15[320*(anty+n)+antx+m] = col2;
}
}
sprintf(cad,"%u steps left ",8999-i);
v_putcad(1,3,0x000000,0xffffff,cad);
gp2x_video_flip();
for(n = 0; n < 3; n++)
{
int m = 0;
for(m = 0; m < 3; m++)
{
gp2x_screen15[320*(anty+n)+antx+m] = col2;
}
}
sprintf(cad,"%u steps left ",8999-i);
v_putcad(1,3,0x000000,0xffffff,cad);
gp2x_video_flip();
if(direction == 0) antx-=3;
if(direction == 1) anty-=3;
if(direction == 2) antx+=3;
if(direction == 3) anty+=3;
direction--;
if(direction < 0) direction=3;
}
if(gp2x_screen15[(320*anty) + antx]==col2)
{
for(n = 0; n < 3; n++)
{
int m = 0;
for(m = 0; m < 3; m++)
{
gp2x_screen15[320*(anty+n)+antx+m] = col1;
}
}
sprintf(cad,"%u steps left ",8999-i);
v_putcad(1,3,0x000000,0xffffff,cad);
gp2x_video_flip();
for(n = 0; n < 3; n++)
{
int m = 0;
for(m = 0; m < 3; m++)
{
gp2x_screen15[320*(anty+n)+antx+m] = col1;
}
}
sprintf(cad,"%u steps left ",8999-i);
v_putcad(1,3,0x000000,0xffffff,cad);
gp2x_video_flip();
if(direction == 0) antx+=3;
if(direction == 1) anty+=3;
if(direction == 2) antx-=3;
if(direction == 3) anty-=3;
direction++;
if(direction > 3) direction=0;
}
}
}
void speedtest(short test)
{
unsigned BACKGROUND;
if(test == 0) BACKGROUND=0xB00000;
if(test == 1) BACKGROUND=0xFFFFFF;
short start = 240;
short cpuspeed = start;
unsigned char cad[256];
FILE *speed;
do
{
speed = fopen("/mnt/sd/speed.txt", "w");
ClearScreen(BACKGROUND);
if(test == 0) v_putcad(1,1,0x00ff00,BACKGROUND,"Prim-Speedtest");
if(test == 1) v_putcad(1,1,0x006600,BACKGROUND,"Ant-Speedtest");
v_putcad(1,6,0xffffff,BACKGROUND,"Testing Speed");
if(cpuspeed > start)
{
sprintf(cad,"%uMhz checked",cpuspeed-5);
v_putcad(1,9,0xffffff,BACKGROUND,cad);
}
gp2x_video_flip();
ClearScreen(BACKGROUND);
if(test == 0) v_putcad(1,1,0x00ff00,BACKGROUND,"Prim-Speedtest");
if(test == 1) v_putcad(1,1,0x006600,BACKGROUND,"Ant-Speedtest");
v_putcad(1,6,0xffffff,BACKGROUND,"Testing Speed");
if(cpuspeed > start)
{
sprintf(cad,"%uMhz checked",cpuspeed-5);
if(test == 0) v_putcad(1,9,0xffffff,BACKGROUND,cad);
if(test == 1) v_putcad(1,9,0x000000,BACKGROUND,cad);
}
gp2x_video_flip();
fprintf (speed,"set CPU-Frequency = %uMHz\r\n",cpuspeed);
set_FCLK(cpuspeed);
if(test == 0) prim();
if(test == 1) ant();
fprintf(speed,"%uMhz checked\n\n", cpuspeed);
cpuspeed = cpuspeed + 5;
fclose(speed);
execl("sync",NULL);
}
while(1);
}

View File

@ -1,3 +0,0 @@
void prim();
void ant();
void speedtest(short test);