News/release from Torch

This is a simple plugin I made a long time ago for my personal use. I just found the source code while going through some old stuff on my computer, so I thought I'd clean up the code a bit and release the plugin.

I realize that there are other plugins that feature similar functionality but I wrote my own because I wanted to be sure its coded optimally, as there are a few careless ways in which these functions can be improperly used (the point of this after all is to conserve battery life).

It does the following when the Hold switch is enabled:
* Switches off the LCD backlight.
* Switches off the actual LCD screen.
(This is important because the backlight and actual screen are two different things. You can have an image being displayed on the screen while the backlight is switched off, such that you can see the image if you use a flashlight. You can also have the screen switched off while the backlight still illuminates the powered off screen.)
* Underclocks the CPU to 60MHz
(Sony has changed the clock speed functions such that only certain combinations of speeds work correctly. Simply trying to underclock to arbitary values will result in the CPU simply running at the stock speed. I have verified that Hold+ successfully underclocks to 60MHz.)
* The original screen brightness and clock speed are restored when the Hold switch is released.
* Prevents the PSP from going into suspend mode if you accidently push the power switch too far when turning off Hold mode.
* Allows complete operation of the PSP controls with the display turned off.
* Turns off LEDs in hold mode. LEDs are flashed once in 30 seconds so that the PSP is not mistaken to be powered off.
* While in hold mode, allows the use of Left, Right, LTrigger, RTrigger, Volume and Start buttons, if you hold the Select button first. Useful to skip songs, pause etc.

Usage:
Turn on the Hold switch to automatically disable the display and underclock the CPU. Turn off the Hold switch to return the CPU to normal speed and enable the display.

If you push the ANALOG UP button when turning on the Hold switch, it will only lock the keypad like normal hold mode. The display and CPU speed will not be changed, so that you can watch videos etc. with the keypad locked.

If you push the ANALOG UP button when turning off the Hold switch, the display will remain switched off and the CPU will remain underclocked, but you can operate the PSP. To return to normal, push the power switch to the suspend position, or just press the Screen button.

While the PSP is in hold mode, if you first hold down the Select button, you can use the following buttons: Left, Right, LTrigger, RTrigger, Vol+, Vol-, Start.

Installation:
You can install it in the seplugins folder, and make an entry in VSH.txt. Thus it will be active in the XMB. Its also possible to use it in games by adding it to GAME.txt, but some games may crash etc., if the CPU is underclocked to such a low value.

Optionally, its also possible to install it in your PSP's flash0 so that it will work without a Memory Stick. For this you can use FreePlay's "NewBTCFNedit" and enable it for VSH mode in the all the PSPBT?NF.bin files. Add it before vshmain.prx.

Advanced:
If you want to change the clock speed to your own values, you can use a hex editor to change them. The offsets in the file for v3.2 are
0xD98 - CPU
0xD9C - Bus (Should be half the CPU speed or less)

The values should be entered in hexadecimal. The default value for CPU is 3C (60 MHz in decimal) and the default value for Bus is 1E (30 MHz in decimal).

Note that simply using any arbitrary value will not work. You will have to test and see which values for CPU and Bus speed work.

Credits:
Thanks to adrahil for helping with preventing the suspend mode.

Thanks to Booster for the SysCon Hook sample, based on which Hold+ v3.0 was updated.

Thanks to Total_Noob; As his plugin MusicHold was not compatible with Hold+, with his permission I've implemented the same features in Hold+ v3.0 for people who wanted some buttons to be usable in hold mode.


Spoiler for Changelog:
Changelog v3.2
----------------------------------
Fixed a bug where after you exit a Photo or the Browser, the battery icon would keep disappearing and reappearing.

Fixed a bug where each time you exit a Photo or the Browser, the first time you turn on Hold after that it would only go to Normal Hold mode.

Changelog v3.1
----------------------------------
Reduced CPU usage by delaying longer in main loop. Since v3.0 the main loop doesn't do much so it needn't run as fast as before. This *should* alleviate problems with the battery icon.

Now its not possible to accidently press 'other' buttons in hold mode while holding Select button. Ex: If you are holding Select + VolUp to increase volume, and you accidently press X, the X button will not have effect.

Changelog v3.0
----------------------------------
Completely overhauled the plugin to work using only the SysCon functions based on Booster's example.

The prevention of accidental suspend was changed to Booster's method as that is more efficient.

In Display Off mode, pressing the Screen button to return to normal no longer causes the firmware's internal brightness variable to become one step higher than the original screen brightness.

Added the ability to use some of the buttons while in hold mode, by holding the Select button first.

Download and Give Feedback Via Comments