PSP Hacks - Forums

Go Back   PSP Hacks - Forums > PSP Community > PSP Programming & Development

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 10-03-2008, 09:19 AM
lokiare1's Avatar
lokiare1 lokiare1 is offline
Programmer
PSP Enthusiast
 

Join Date: Jul 2005
Location: Arkansas, USA
Posts: 466
lokiare1 is on a distinguished road
Default [Release] CPU-Modulator PRX v. 0.2 by Lokiare

In this release I've included the full range from 333mhz to 96mhz. this means it changes from 333 to 332 to 331 on down until it finds the "perfect" speed for running your programs. It changes speed less, and runs much smoother. When I get all the bugs out I will release the source code, so that anyone can include this in their homebrew projects.

[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 10:01 AM.
Reply With Quote
  #2  
Old 10-03-2008, 09:33 AM
Scorpus's Avatar
Scorpus Scorpus is offline
Moderator
PSP Titan
 

Join Date: Jan 2008
Location: Australia
Posts: 4,540
Scorpus is a name known to allScorpus is a name known to allScorpus is a name known to allScorpus is a name known to allScorpus is a name known to allScorpus is a name known to all
Default

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
__________________


The PC Report is looking for someone to write posts
Show us your interest HERE, and you could get paid for your contributions.


Last edited by Scorpus; 10-03-2008 at 06:14 PM.
Reply With Quote
  #3  
Old 10-03-2008, 09:39 AM
pirata nervo pirata nervo is offline
Programmer
PSP Titan
 

Join Date: Mar 2007
Location: www.consoleworld.net
Posts: 5,650
pirata nervo is on a distinguished road
Default

Good work again
__________________
Reply With Quote
  #4  
Old 10-03-2008, 10:02 AM
lokiare1's Avatar
lokiare1 lokiare1 is offline
Programmer
PSP Enthusiast
 

Join Date: Jul 2005
Location: Arkansas, USA
Posts: 466
lokiare1 is on a distinguished road
Default

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..."
Reply With Quote
  #5  
Old 10-03-2008, 06:15 PM
Scorpus's Avatar
Scorpus Scorpus is offline
Moderator
PSP Titan
 

Join Date: Jan 2008
Location: Australia
Posts: 4,540
Scorpus is a name known to allScorpus is a name known to allScorpus is a name known to allScorpus is a name known to allScorpus is a name known to allScorpus is a name known to all
Default

Quote:
Originally Posted by lokiare1 View Post
Can you update the mirror? I just re-uploaded it after fixing a tiny bug (that affects performance).
Done .
__________________


The PC Report is looking for someone to write posts
Show us your interest HERE, and you could get paid for your contributions.

Reply With Quote
  #6  
Old 10-05-2008, 08:40 PM
pspjoke's Avatar
pspjoke pspjoke is offline
Programmer
PSP Guru
 

Join Date: Mar 2008
Location: U.S.
Posts: 1,828
pspjoke is a name known to allpspjoke is a name known to allpspjoke is a name known to allpspjoke is a name known to allpspjoke is a name known to allpspjoke is a name known to all
Default

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)
__________________
http://levoneprojects.net23.net/

++rep me if i helped you please.
Ahh, shit. Stupidity is on the rise again.
went legit Oct. 31, 09'
piracy is wrong, please don't do it.

Reply With Quote
  #7  
Old 10-12-2008, 09:37 AM
lokiare1's Avatar
lokiare1 lokiare1 is offline
Programmer
PSP Enthusiast
 

Join Date: Jul 2005
Location: Arkansas, USA
Posts: 466
lokiare1 is on a distinguished road
Default

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
I'm not completely sure I need all of the include files, but all of the examples I learned from used all of them.

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..."
Reply With Quote
  #8  
Old 10-12-2008, 10:09 AM
ilikeadabox ilikeadabox is offline
PSP Neophyte
 

Join Date: Oct 2007
Posts: 57
ilikeadabox Has a Beginner Reputation
Smile I like this plugin

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?
Reply With Quote
  #9  
Old 10-12-2008, 05:20 PM
lokiare1's Avatar
lokiare1 lokiare1 is offline
Programmer
PSP Enthusiast
 

Join Date: Jul 2005
Location: Arkansas, USA
Posts: 466
lokiare1 is on a distinguished road
Default

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..."
Reply With Quote
Reply

 



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:05 AM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
©