![]() |
|
#1
|
||||
|
||||
|
[Edit]I fixed a tiny bug and re-uploaded. CPU - Modulator v.0.20 - Mega-Upload
__________________
A wise man once said "...what was I saying..." Last edited by lokiare1; 10-03-2008 at 11:01 AM. |
|
#2
|
||||
|
||||
|
Looking good. Can't wait for the source code. Might use it in Thing Thing
Mirrored at Rapidshare -- http://rapidshare.com/files/15068047...dulator_2_.zip
__________________
--| Thing Thing: PSP Edition -0.9.1- | My Theme Pack | Ice Pong -1.2.1- | My Hack Your PSP Guide | My Website |-- Last edited by Scorpus; 10-03-2008 at 07:14 PM. |
|
#3
|
|||
|
|||
|
Good work again
|
|
#4
|
||||
|
||||
|
Can you update the mirror? I just re-uploaded it after fixing a tiny bug (that affects performance).
__________________
A wise man once said "...what was I saying..." |
|
#5
|
||||
|
||||
|
Done .
__________________
--| Thing Thing: PSP Edition -0.9.1- | My Theme Pack | Ice Pong -1.2.1- | My Hack Your PSP Guide | My Website |-- |
|
#6
|
||||
|
||||
|
can't wait for the source, i could never figure out how to calculate cpu load when i was working on my cpu manager or managment (whatever i called it.. :/) plugin.
when u release the source, ill be able to do that. ![]() u'll be in the credits of course. lol (unless my dumb ass forgets to make credits... in that case, just remind me lol)
__________________
PHAT(TA-086) & GOW Slim(TA-088v2) - firmware: 5.00M33-3 - addons: 1.50 addon(phat). Me: newbie programmer... Levone == pspjoke;
releases ignorance is forgivable.. stupidity is a sin i can never forgive. |
|
#7
|
||||
|
||||
|
Ok, since I probably won't update it anymore I'll go ahead and release the source code.
This needs the vshblit files that are used to write to the screen in PRX files. If anyone needs them I can go back and look for the thread that discusses them and link to it (I'm just too lazy right now). Code:
TARGET = CPUModulator OBJS = blit.o main.o BUILD_PRX = 1 #USE_PSPSDK_LIBC = 1 INCDIR = LIBDIR = LIBS = -lstdc++ -lpsppower -lpspgu -lpsprtc -lpspkernel LDFLAGS = CFLAGS = -Os -G0 -Wall -g CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti ASFLAGS = $(CFLAGS) PSPSDK = $(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build_prx.mak Code:
#include <pspkernel.h>
#include <pspdisplay.h>
#include <stdlib.h>
#include <pspdebug.h>
#include <pspsdk.h>
#include <pspctrl.h>
#include <pspgu.h>
#include <pspthreadman.h>
#include <psppower.h>
#include <time.h>
#include "psputils.h"
#include <stdio.h>
#include <string.h>
#include "blit.h"
#include <psploadcore.h>
#include <pspiofilemgr.h>
#include <malloc.h>
#include <psprtc.h>
#include <pspiofilemgr.h>
#include <pspdisplay_kernel.h>
PSP_MODULE_INFO("CPU-Modulator", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
int main_thread(SceSize args, void *argp) {
// Wait for xmb to load up
sceKernelDelayThread(7000000);
blit_setup();
unsigned int posx = 0;
unsigned int posy = 20;
// Variables to hold the frequencies
int pll = 222;
int cpu = 222;
int bus = 166;
int curCPU = 0;
int curBUS = 0;
int changeCPU = 0;
int logging = 0;
int changed = 0;
// File open and write stuff
char fpath[200];
int fd = 0;
int flen = 0;
char buffer[100];
//For some reason the logging doesn't work in the latest build. I'll have to check it out.
// Read in an .ini file
sprintf(fpath, "%s", "ms0:/seplugins/cpumodulator.ini");
// Check if we can open the file
if(!(fd = sceIoOpen(fpath, PSP_O_RDONLY, 0777)))
{
// Error if we cant open it
}
else
{
// Continue if we can open it
int bIndex = 0;
sprintf(buffer, "%s", "");
while (bIndex < 9)
{
char temp;
flen = sceIoRead(fd, &temp, sizeof(temp));
if (temp == '1' || temp == '0')
{
if (temp == '1')
logging = 1;
else
logging = 0;
break;
}
bIndex++;
}
}
// Must make sure to close the file I/O before continuing with the rest of the program.
sceIoClose(fd);
sprintf(buffer, "%s", "Loaded CPU-Modulator\n\0");
u64 oldTime, newTime;
if (logging == 1)
{
// Set the path for logging
sprintf(fpath, "%s", "ms0:/seplugins/cpumodulatorlog.txt");
// Check if we can open the file
if(!(fd = sceIoOpen(fpath, PSP_O_APPEND | PSP_O_WRONLY | PSP_O_CREAT, 0777)))
{
// Error if we cant open it
}
else
{
// Continue if we can open it
int bIndex = 0;
while (bIndex < 100)
{
char temp = buffer[bIndex];
flen = sceIoWrite(fd, &temp, sizeof(temp));
if (buffer[bIndex] == '\0')
break;
bIndex++;
}
}
}
changed = 0;
// Must make sure to close the file I/O before continuing with the rest of the program
sceIoClose(fd);
while(1)
{
// Set the old time on start-up.
//oldTime = sceKernelLibcTime((time_t *) 0);
sceRtcGetCurrentTick(&oldTime);
// Loop through for a specified number of times to see how long it takes
// for the loop to process. (this can be replaced by any piece of code that may seem cpu intensive)
int i = 0;
while (i < 65534)
{
i++;
}
// Get the new time and compare it to the old time
//newTime = sceKernelLibcTime((time_t *) 0);
sceRtcGetCurrentTick(&newTime);
u64 delay = newTime - oldTime;
// Move CPU up
if (delay > 3800)
changeCPU = 1;
// Move CPU down
else if (delay < 1000)
changeCPU = -1;
// No change
else
changeCPU = 0;
if (changeCPU == 1)
{
// Increase speed
pll+=2;
cpu+=2;
bus++;
if (pll > 333)
pll = 333;
if (cpu > 333)
cpu = 333;
if (bus > 166)
bus = 166;
scePowerSetClockFrequency(pll,cpu,bus);
changeCPU = 0;
changed = 1;
}
if (changeCPU == -1)
{
// Decrease speed
pll-=2;
cpu-=2;
bus--;
if (pll < 96)
pll = 96;
if (cpu < 96)
cpu = 96;
if (bus < 48)
bus = 48;
scePowerSetClockFrequency(pll,cpu,bus);
changeCPU = 0;
changed = 1;
}
curBUS = scePowerGetBusClockFrequency();
curCPU = scePowerGetCpuClockFrequency();
if (logging == 1)
{
posx++;
sceDisplayWaitVblankStart();
sprintf(buffer, "%s%d%s%d%s%d%s", " cpu: ", curCPU, " bus: ", curBUS, " Delay: ", (int)delay, "\n\0");
blit_string(posx, posy, buffer);
}
else
sceDisplayWaitVblankStart();
if (changed == 1 && logging == 1)
{
// Check if we can open the file
if(!(fd = sceIoOpen(fpath, PSP_O_APPEND | PSP_O_WRONLY | PSP_O_CREAT, 0777)))
{
// Error if we cant open it
}
else
{
// Continue if we can open it
// Writes buffer to the file that we opened.
int bIndex = 0;
while (bIndex < 100)
{
char temp = buffer[bIndex];
flen = sceIoWrite(fd, &temp, sizeof(temp));
if (buffer[bIndex] == '\0')
break;
bIndex++;
}
}
// Must make sure to close the file I/O before continuing with the rest of the program
sceIoClose(fd);
changed = 0;
}
sceKernelDelayThread(10000);
}
sceKernelSleepThread();
return 0;
}
int module_start(SceSize args, void *argp) {
int thid;
/* Create a high priority thread */
thid = sceKernelCreateThread("CPU-Modulator", main_thread, 0x18, 0x1000, 0, NULL);//8, 64*1024, PSP_THREAD_ATTR_USER, NULL);
if(thid >= 0) sceKernelStartThread(thid, args, argp);
return 0;
}
__________________
A wise man once said "...what was I saying..." |
|
#8
|
|||
|
|||
|
Hey do I set my CPU at 333 for this to work right? I put it at default but it doesn't really change but when I put it on 333 it changes a lot and lags and stuff so what do i set my CPU at for it to do what its supposed to do?
|
|
#9
|
||||
|
||||
|
it should be default, but you may have to set it at a custom setting to allow the processor speed to change.
__________________
A wise man once said "...what was I saying..." |
![]() |
|
|
|||
|
|||
|
|
| Thread Tools | |
| Display Modes | |
|
|