This package contains the updated beta version 2.1b1
""""""""""""""""""""""""""""""""""""""""""""""""""""
New features:
- Daemon (by jix)
    This daemon allows you to change the CPU speed while playing games / emulators.
    For now the --help output and the Item Help are the only documentation about the daemon.


Here is the updated --help output:
CPU/LCD/RAM-Tweaker Ver. 2.1b1 (c) god_at_hell
--------------------------------------------
Usage: cpu_speed.gpe [option1] [value1] [option2]...
Options:
 RAM-Options
 -----------
 --cas          CAS Latency. Delay in clock cycles between the registration 
                of a READ command and the first bit of output data. 
                Valid values are 2 and 3 cycles.
 --trc          ACTIVE to ACTIVE /AUTOREFRESH command delay. Defines ACTIVE 
                to ACTIVE/auto refresh command period delay. 
                Valid values are from 1 to 16 cycles.
 --tras         ACTIVE to PRECHARGE delay. Defines the delay between the ACTIVE 
                and PRECHARGE commands. 
                Valid values are from 1 to 16 cycles.
 --twr          Write recovery time in cycles.
                Valid values are from 1 to 16 cycles.
 --tmrd         LOAD MODE REGISTER command cycle time.
                Valid values are from 1 to 16 cycles.
 --trfc         AUTO REFRESH command period in cycles.
                Valid values are from 1 to 16 cycles.
 --trp          PRECHARGE command period in cycles.
                Valid values are from 1 to 16 cycles.
 --trcd         RAS to CAS Delay in cycles.
                Valid values are from 1 to 16 cycles.
 --refperd      Refresh Period. Defines maximum time period between 
                AUTOREFRESH commands.
                Valid values are from 1 to 65535 (default ~ 250) cycles.
 --ramdiv       Divider for the Memory-Clock which is 1/2 of the CPU-Clock. 
                Valid values are from 1 to 8.

 CPU-Options
 -----------
 --cpuclk       Sets the CPU-Frequency in Mhz. 
                Valid values are from 33 to 340.
 --cpudiv       Divider for the CPU-Clock. 
                Valid values are from 1 to 8.

 Display-Options
----------------
 --fpll         Sets clockgenerator to fpll (for firmware 1.0 - 1.0.1).
 --upll         Sets clockgenerator to upll (for the rest).
 --timing       Timing Prescaler to eliminate flickering. 
                Valid values are: -20 to 36 with fpll.
                                  -6 to 10 with upll.
 --gamma        Regulates the gamma. 
                Valid values are from 0.0001 to 15.0000.

 Daemon-Mode 
----------------
Usage: cpu_speed.gpe --daemon [option1] [value1] [option2]...
Shutdown: cpu_speed.gpe --kill[-daemon]
Options:
 --min  Sets the minimum CPU-Frequency in Mhz. 
                Valid values are from 33 to 340.
 --max  Sets the maximum CPU-Frequency in Mhz. 
                Valid values are from 33 to 340.
 --start        Sets the CPU-Frequency in Mhz. 
                Valid values are from 33 to 340.
 --step Sets the CPU-Frequency step in Mhz. 
                Valid values are from 1 to 340.
 --hotkey       Sets the hotkey. (Default: LR) 
                Valid values are a combination of LRXYZAB+-S/@ or ``None''
                 (+- are volume, S is Start, / is Select, @ is Stick).
 --incr Sets the increment key. (Default: +) 
                Valid values are a combination of LRXYZAB+-S/@ or ``None''
                 (+- are volume, S is Start, / is Select, @ is Stick).
 --decr Sets the decrement key. (Default: -) 
                Valid values are a combination of LRXYZAB+-S/@ or ``None''
                 (+- are volume, S is Start, / is Select, @ is Stick).
 --no-hotkey    Alias for --hotkey None.
 --no-incr      Alias for --incr None.
 --no-decr      Alias for --decr None.
 --foreground   Do not switch to daemon mode. (Useful for debugging)
 --background   Switch to daemon mode. (Default)
 --display      Enable on screen display. COMING SOON!
 --no-display   Disable on screen display.

NOTE:
The old commandline-settings are working ... read more about this in the readme

--old readme starts here--

CPU/LCD/RAM Tuner V.2.0 (c) god_at_hell
=======================================

This little program lets you change the CPU-clock, RAM- and LCD-timing to get higher framerates and reduce the flickering.


So ... it's now finished ... a new, a fresh, a better Tweaker :).

There are many new features wich are listed below by the "What's new" chapter of this Readme. This document
should help you with the program, but i can not forsee all questions, so ... if you have one left send me
a PM in the GP32X.com or GP2X.de forum OR write something in the specific thread.

If you find any bugs in the program ... let me know. If you find a spelling-mistake in this readme .. sorry, i'm now and then
i tend to many mistakes :).


First of all ... the credits:
=============================
The most parts of the program are rewritten, so most of it is now my own code, but many much of cpuctrl.c is
still based on Hermes/PS2Reality's code and I use Rlyeh's minilib, so much thx from my side goes to this two.
The gamma-code now is better integrated in the source, but it's still theodbots child :). Like in every Versions
I want to thank Robster to, because he helped me with my first steps, was a great help with the LCD-code and
his SDK was a very helpfull to. And there is vimacs, who was my motivation to implement the gamma-code in 1.3 and
change the whole program for this version... he's my betatesting-bitch to :D.  


Installation:
=============

Just copy the "cpu_speed.gpe" to a folder on your sd-card.


Usage:
======

If you start the Tweaker, you'll see a BIOS-like menuscreen. The tweaker reads the settings of your GP2X, so every value
you now encounter is the value wich is set ... however i was to lazy write a function to read out the gamma-value, so gamma
is 1.00 every time the GP2X has to read the system-setting.

With the Stick you can pick out one of the three sumenus and enter every one with a press of the B-button. If you return to
the mainmenu, the tweaker reminds the values you have set, so you don't have to enter them again if you accidently quit the
submenu. 

The most settings can be toggled with R/L. There are exceptions where you can use the Volume-Controll too, but I'll will 
refer to it. You can go back to the mainmenu by pressing the START-Button. The Submenu you last visited will be selected:
Now I'll explain the different menus:


CPU-Settings:
-------------

CPU-Clock
Here you can set the frequency of the CPU-Sourceclock to get more speed or more battery life. With R/L you can move 10Mhz for- or backwards
and with Volume UP/DOWN you can move in 1MHZ steps. The specified max-frequency is 266mhz, going there should be safe. 

CPU-Divider
This let's you choose a divider for your CPU-clock. I have to admitt ... it's a somewhat useless funktion :). If the divider is set to 2
the CPU is clocked with half the frequency you have choosen above ... with 3 only a third and so on.

Speed-Test
Here you can choose between several (two at the time) tests. After you hit B on the field !!GO!!, the choosen test clocks the cpu at 240mhz
and runs some calculations. After a given period of time the speed is marked as checked and the CPU will be clocked 5Mhz higher. The results
are written into a speed.txt file into the root-directory of your SD-card, so you can leave the GP, return later and check the speed it can run at.
This funktion is mainly a just4fun code and only usefull for retailers wich want to check several GPs. Note, that the speed you'll get can be 5-10mhz
above the speed you can use in programs like Quake or GnGeo, because this programs stress the cpu much more and stress other parts of the SOC too.

To the tests:
The first test calculates a simple turing-machine called the "Langton's Ant" (http://en.wikipedia.org/wiki/Langton%27s_ant). This shows, that
you can build a complex chaotic system whithout using a random-function. After 8000 steps a regularly sample develops out of this chaos.
The rules for the ant are symetric, but the sample is asymetric. Because the buildup was to fast, there's a for-loop in the code which reduces
the speed to a viewable one :).
The second test calculates primnumbers by brute force ... i could add a more advanced way, but i'm too lazy :P.


LCD-Settings:
-------------
This is the only submeny where changing the settings will set these the time you press the buttons.

Clockgenerator
In FPLL-mode the LCD still utilizes the same clockgenerator like the cpu-clock, but you can alter the prescaler to reduce the 
flickering. Just play around with it a little bit. In UPLL-mode the LCD gets its own clockgenerator and so the LCD-timing should be constant.
The FPLL-Mode is a leftover out of Firmware 1.0 times ... if you have something above, you should use UPLL-Mode.

LCD-Timing
This gives a prescaler to the timing code and gives you the opportunity to reduce flickering and waving-lines. It's the same like the slider
in firmware 1.4 and 2.0 ... only with a bigger interval.
Just play around with it a little bit. When your screen becomes corrupted (e.g. when you use a low cpu-clock
a high timing-setting), just press the opposite button several times ... it should get to normal.

Gamma
You can now alter the gamma-settings. Use the Volume-Buttons for finetuning. 
The actual routine uses the reciprocal value ... because i thought it would be irritating if the pictue becomes brighter for a lesser value.


RAM-Settings:
-------------
This is the only submenu where you have to scroll ... the last option is the RAM-Divider, wich is selectable if you reach the window-bottom.

This menu lets you choose several RAM-timings to get a better performance. I will not explain every item, because this would be to long.
All in short. All but the last two items are latency-values. This means less is better, but could be instable. This is because if you choose
to short delay times, the RAM can't save or read the data correctly. This is a production-factor and can be different from chip to chip ... 
you'll have to find your perfect value. The CAS-Setting is the most important timing ... gladly GPHs initial setting is the best, so you can
leave this untouched unless you want to test something. The other values can be set stricter to gain some fps in games ... See the Item-Help
in the Program for little (but mostly insignificant :) ) explanations. I tested some values with Quake and gained 4-5% more speed. This is not
much, but in programs like gngeo and mame which are havy RAM-Users, you should get a little speed-boost you should notice. The settings i used
were: tRC(6), tRAS(6), tWR(3), tMRD(5), tRFC(5), tRP(4), tRCD(4).

SEE ALSO: http://en.wikipedia.org/wiki/RAM_latency

Refresh Period
This regulates the interval in which the RAM will be refreshed with energy. For this the control-signals have to be different to the READ/WRITE-
Signals which means, that every refresh-cycle is a cycle programs can not read or write to the ram-cell. So a big value should be faster, BUT if
your value is to big, your RAM looses data because of energy loss, which dependents on production flaws like impurities of the silicon-crystal.
You'll have to find the biggest refresh-interval which isn't interfering with the data-integrity.

RAM-Divider
Same as CPU-Divider ... it divides the RAM-Clock. The RAM-Clock is the half of the CPU-Sourceclock. If you overclock your CPU, your RAM will be
overclocked too. The used RAM is PC133 RAM, so the maximal frequency specified is 133mhz. This means, if you go over 266mhz CPU clock, the RAM will
run outside it's specifications. Now the divider comes in handy. If you clock your GP2X at 300mhz, your RAM-Clock is 150MHZ. If you now choose a
divider of two, the resulting RAM-Frequency will be 75Mhz. I implemented this in the hope, that I can overclock my GP higher than before, but it
seems, that for me the CPU is the weak part. But if you're unlucky and have a bad RAM-Chip, this could be a solution for a faster CPU.


Options in the MAIN-Menu:
=========================

When you retourn from your submenu, you have four options:

1. Go into another submenu
2. Exit the program with START discard the settings ... use this, if you don't want to do anything .. NOTE: The LCD-Options will be set, because 
	they are set in the submenu and not at program-exit.
3. Exit the program with SELECT and set parameters. This runs the SET-Funktions for CPU and RAM Options and returns to the GP2XMenu.
4. SAVE to SD with the Y-Button. This creates a config file named cpu_speed.cfg in the same directory where the tweaker is. This 
	config will be loaded when you run the tweaker again automatically. If the tweaker finds no config-file, it returns a "no file found" per
	text-output (viewable per telnet or file-piping), runs the menu and reads the system-settings.
	
	
Config-File Specials:
=====================

The config file looks like this:
	--------
	CPU-Clock
	250
	CPU-Div
	1
	UPLL
	1
	Gamma
	1.00
	--------
First comes the parameter and beneath it the value. The last line in the config is a newline.

If add a line which "Run" and beneath a file, the tweaker doesn't run the menue on startup. The Tweaker will set the parameters specified in
the config-file and after that it will run the file. This should be easier for unexperienced users than writing a script.

There are two things you have to look at, when you want to run a file:
1. The Run-Argument has to be the last one, because it doesn't run if there's a line beneath the line with the file-name.
2. you have to add ./ before the filename or it won't work. You can hand over whole paths too, but notice, that some programs won't run if
	you don't change the directory (Quake2 e.g.). For this programs to run, the tweaker has to be in the same directory as the the program.
3. Make no new line under the filename ... a newline prevents the program to run.
4. The filename (with ./) can't be longer than 40 characters.

A config, which starts squidgesnes after setting the tweaks looks like this:
	--------
	CPU-Clock
	250
	CPU-Div
	1
	UPLL
	1
	Gamma
	0.6
	Run
	./squidgesnes.gpe
	--------


Commandline-options:
====================

I've rewritten the whole commandline-thing. Now you can use the program like any other unix program, that means it's irrelevant in which order
you hand over the Options. The only thing you have to think about is, that after every option there has to be a the specific value except for 
the options "--upll" and "--fpll" ... these two don't have values.
If you hand over "--help" as option, you'll get a list of all options ... i'll present this list here too.

-------------
Listed Output:

CPU/LCD/RAM-Tweaker Ver. 2.0 (c) god_at_hell
--------------------------------------------
Usage: cpu_speed.gpe [option1] [value1] [option2]...
Options:
 RAM-Options
 -----------
 --cas          CAS Latency. Delay in clock cycles between the registration
                of a READ command and the first bit of output data.
                Valid values are 2 and 3 cycles.
 --trc          ACTIVE to ACTIVE /AUTOREFRESH command delay. Defines ACTIVE
                to ACTIVE/auto refresh command period delay.
                Valid values are from 1 to 16 cycles.
 --tras         ACTIVE to PRECHARGE delay. Defines the delay between the ACTIVE
                and PRECHARGE commands.
                Valid values are from 1 to 16 cycles.
 --twr          Write recovery time in cycles.
                Valid values are from 1 to 16 cycles.
 --tmrd         LOAD MODE REGISTER command cycle time.
                Valid values are from 1 to 16 cycles.
 --trfc         AUTO REFRESH command period in cycles.
                Valid values are from 1 to 16 cycles.
 --trp          PRECHARGE command period in cycles.
                Valid values are from 1 to 16 cycles.
 --trcd         RAS to CAS Delay in cycles.
                Valid values are from 1 to 16 cycles.
 --refperd      Refresh Period. Defines maximum time period between
                AUTOREFRESH commands.
                Valid values are from 1 to 65535 (default ~ 250) cycles.
 --ramdiv       Divider for the Memory-Clock which is 1/2 of the CPU-Clock.
                Valid values are from 1 to 8.

 CPU-Options
 -----------
 --cpuclk       Sets the CPU-Frequency in Mhz.
                Valid values are from 33 to 340.
 --cpudiv       Divider for the CPU-Clock.
                Valid values are from 1 to 8.

 Display-Options
----------------
 --fpll         Sets clockgenerator to fpll (for firmware 1.0 - 1.0.1).
 --upll         Sets clockgenerator to upll (for the rest).
 --timing       Timing Prescaler to eliminate flickering.
                Valid values are: -20 to 36 with fpll.
                                  -6 to 10 with upll.
 --gamma        Regulates the gamma.
                Valid values are from 0.0001 to 15.0000.
------------

You can use this commandline arguments in a script ... a proper script looks like this:
---
#/bin/sh
/mnt/sd/cpu_speed.gpe --upll -timing 1 --cpuclk 230 --gamma 0.6 --tras 5 > /mnt/sd/output.txt
cd /usr/gp2x
exec /usr/gp2x/gp2xmenu
---
With " > /mnt/sd/output.txt" the Text-Output of the tweaker is saved to a testfile named output.txt ... with this you can look if
your settings are set right.


Fallback-Commandline
====================

The old commandline is not scrapped ... i've build in a fallback, so you can copy the new tweaker onto your SD and use your old
scripts ... BUT you can't use the new ram-parameters ... this would be a bit to chaotic.

The following is a copy-paste from the old readme and describes the usage of the old commandline:
When you set 2 or 3 parameters, the program will run in commandline-mode. In this mode,
no graphical output is given, so you can run it with a GPU-script. A proper GPU looks like this:
---
#/bin/sh
/mnt/sd/cpu_speed.gpe 1 5 230 0.6 > /mnt/sd/output.txt
cd /usr/gp2x
exec /usr/gp2x/gp2xmenu
---
The first parameter sets the clock-generator. Choose 0 for FPLL and 1 for UPLL.
The second parameter sets the prescaler for the LCD-timing. Get your prefered values with the graphical-menue. Choose values between 
-20 and 36 for FPLL-mode and -5 and 10 for UPLL-mode.
The third parameter sets the CPU-frequency in MHz. Choose a value between 33MHz and 320MHz.
If you use values which are too high or too low, the program exits without changing anything.
The forth parameter sets the gamma-value. You can use values from 0.02 up to 10 where 0.02 is dark and 10 is bright.
With > you can pipe the output to a file. This only works in commandline-mode. You'll get something like this:
---
set Timing-Prescaler = 5
..set to UPLL-Clockgen...
---



NOTE: !!!I take no responsibility for any damage caused by the program.!!!


What's new:
===========
CPU/LCD/RAM Tuner 2.0
---------------------
- complete new menu
- RAM-Tuning Options
- Saveoption for Configfiles
- complete new commandline-options
- no SDL anymore
- CPU-Tester

CPU & LCD Tuner V.1.3
---------------------
- added gamma-selection (cody by theoddbot)
- hardware-sdl (it's useless in this program ... but ... it's cool) *G*


CPU & LCD Tuner V.1.2
---------------------
- added pictureviewer to use test-pictures
- removed div-setting, because it caused some instabilities
- removed hardcoded array for CPU-Clock Settings
- added CPU-clock finetune as replacement for div
- busted some bugs ... but..  	for sure i made new ones :)

CPU & LCD Tuner V.1.1c
----------------------
I messed some things up with the 1.1b version. It seems it was a very unstable one. This should be better.
- commandline and menue don't use the same exit-function any more.

CPU & LCD Tuner V.1.1b
----------------------
- fixed a little issue, where you could not run anything after the tool, when you run a GPU-File.

CPU & LCD Tuner V.1.1
---------------------
- merged to one version
- using commandline-options
- cleaning up the code (indend was really necessary)
- fixed some issues
- added output
- removed "disable_940t()", because it doesn't do anything.

CPU & LCD Tuner v1.0.0 & v1.0.1:
--------------------------------
- other glockgenerator for the LCD (1.0.1 only)
- finetuning for the LCD
- new background-color
- new initial-value and so ... no more flickering

CPU-Speed 1.01c:
----------------
- added more frequenz-settings, no you can go up to 320mhz. From 266mhz on you can go up in 5mhz steps (bzw 4mhz from 266 to 270)

CPU-Speed 1.01b:
----------------
- Correct display and function by using robsters he posted at www.gp32x.com

CPU-Speed 1.01:
---------------
- programmed by Hermes/PS2Reality


To do
======
- daemon-mode
- filebrowser
- more tweaks :)
- fixe some bugs (like every time :P)


Thanks goes to Hermes/PS2Reality for the original-code, robster for great help with the LCD-settings, 
theoddbot for the gamma-routine, Guyfawkes for his demo-code which helped me with the picture viewer in
Ver 1.2 - 1.3 (not included anymore), Vimacs for the poking me to code :), all those guys who tested the 
program at gp2x.de and all i have forgotten. :)


enjoy 

god_at_hell

PS: Please excuse my maybe bad english ^^.