• Steam recently changed the default privacy settings for all users. This may impact tracking. Ensure your profile has the correct settings by following the guide on our forums.

The Help Thread

Roe

Well-Known Member
You need to close the file before renaming it with the sceIoClose function.
 

Alex

Active Member
But, the file opened is on the ms. the file im trying to rename is in flash...
 

Roe

Well-Known Member
Ah I'm sorry I misread your post, answered on my phone :blushing: I've had a look at the vshmain file and it is read only which probably is stopping you from renaming it. Use the following to remove the read only attribute.
Code:
	SceIoStat stats;
	memset(&stats, 0, sizeof(SceIoStat));
	sceIoGetstat("flash0:/vsh/module/vshmain.prx", &stats);	
	if(stats.st_attr & PSP_O_RDONLY) // Check if the file is read only
	{
		stats.st_attr ^= PSP_O_RDONLY; // If it is then toggle it's read only status
		sceIoChstat("flash0:/vsh/module/vshmain.prx", &stats, 3);
	}
 

Alex

Active Member
nope it still didnt work. i'll post up my code,
Code:
	while (1) {

        SceCtrlData pad;
        sceCtrlReadBufferPositive(&pad, 1);

		if (pad.Buttons & PSP_CTRL_CROSS) {
		SceUID check;
	printf("Searching for vshamin.prx...\n");
	check = sceIoOpen("./vshmain.prx", PSP_O_RDONLY, 0777);
	if (check < 0) {
	Wait;
		printf ("Error: Cannot Find vshmain.prx\n");
	}
	else {
	Wait;
		printf("vshmain.prx found\n");
		printf(" - Assigning flash0....\n ");                       
                        if (sceIoUnassign("flash0:") < 0)
                        printf("Cannot Un-Assign flash0:");
                        if (sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0) < 0) {
                                             printf("Error Assigning flash0 in write mode"); }
                        printf("- Flash Assigned\n");
		printf("Installing Lockdowns vshmain.prx\n");
		copyFile("./Lockdown (Phat & Slim)/loader.prx", "flash0:/loader.prx");
		copyFile("./Lockdown (Phat & Slim)/lockdown.thm", "flash0:/lockdown.thm");
			SceIoStat stats;
	memset(&stats, 0, sizeof(SceIoStat));
	sceIoGetstat("flash0:/vsh/module/vshmain.prx", &stats);	
	if(stats.st_attr & PSP_O_RDONLY) // Check if the file is read only
	{
		stats.st_attr ^= PSP_O_RDONLY; // If it is then toggle it's read only status
		sceIoChstat("flash0:/vsh/module/vshmain.prx", &stats, 3);
	}
		sceIoRename("flash0:/vsh/module/vshmain.prx", "flash0:/vsh/module/vshmain_real.prx");
		Wait;
		copyFile("./Lockdown (Phat & Slim)/vsh/module/vshmain.prx", "flash0:/vsh/module/vshmain.prx");
		
		break;}

and i have the pspfilemgr.h header. is there supposed to be anything special the makefile?
 

Roe

Well-Known Member
As this is such an odd problem I've tested some stuff out myself and found that the file can be deleted but not renamed, which is pretty weird. I'll look into it more for you although I can't promise anything. You could try to work around it by trying to copy the vshmain.prx into a new vshmain_real.prx file. It's a work around, but it should work.
 

Alex

Active Member
Right im working on a new program, its a gui based flashing tool. Heres the code then i'll explain the problem:
Code:
#include <psppower.h>
#include <pspsdk.h>   
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"

#define Wait sceKernelDelayThread(1000);
#define ClearScreen pspDebugScreenClear()

#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))


PSP_MODULE_INFO("GUI FLASH", 0, 1, 1);

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
	sceKernelExitGame();
	return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
	int cbid;

	cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
	sceKernelRegisterExitCallback(cbid);

	sceKernelSleepThreadCB();

	return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
	int thid = 0;

	thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
	if(thid >= 0) {
		sceKernelStartThread(thid, 0, 0);
	}

	return thid;
}

void flashers_1(void){
Wait;
		ClearScreen;
		char buffer[200];
	Image* flashers;
	sprintf(buffer, "flashers.png");
	flashers = loadImage(buffer);
	if (!flashers) {
		//Image load failed
		printf("Image load failed!\n");
	} else {
		int x = 0;
		int y = 0;
		sceDisplayWaitVblankStart();
		while (x < 480) {
			while (y < 272) {
				blitAlphaImageToScreen(0 ,0 ,272 , 480, flashers, x, y);
				y += 272;
			}
			x += 480;
			y = 0;
		}
	}
}

int main(void)
{	
char buffer[200];
	Image* one;
	pspDebugScreenInit();
	SetupCallbacks();
	initGraphics();
	sprintf(buffer, "one.png");
	one = loadImage(buffer);
	if (!one) {
		//Image load failed
		printf("Image load failed!\n");
	} else {
		int x = 0;
		int y = 0;
		sceDisplayWaitVblankStart();
		while (x < 480) {
			while (y < 272) {
				blitAlphaImageToScreen(0 ,0 ,272 , 480, one, x, y);
				y += 272;
			}
			x += 480;
			y = 0;
		}
	
		flipScreen();
		flashers_1();
}
	sceKernelSleepThread();
    
	return 0;   // never reaches here, again, just to suppress warning 
}

So what happens is that is sticks to int main when i want it to jump to flashers_1();. any idea of what im doing wrong?

EDIt, i noticed the first few includes wont show, so here they are

#include psppower.h
#include pspsdk.h
#include pspdisplay.h
#include pspctrl.h
#include pspkernel.h
#include pspdebug.h
#include pspgu.h
#include png.h
#include stdio.h
#include "graphics.h"

EDIT2: forgot to flip the screen and change the resolution, fixed. lol

Is there anyway to clear the memory during an homebrew, i think my app is using up all the ram so i need to empty it. anyway?
 

angelsniper45

New Member
Right im working on a new program, its a gui based flashing tool. Heres the code then i'll explain the problem:
Code:
#include <psppower.h>
#include <pspsdk.h>   
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspkernel.h>
#include <pspdebug.h>
#include <pspgu.h>
#include <png.h>
#include <stdio.h>
#include "graphics.h"

#define Wait sceKernelDelayThread(1000);
#define ClearScreen pspDebugScreenClear()

#define MAX(X, Y) ((X) > (Y) ? (X) : (Y))


PSP_MODULE_INFO("GUI FLASH", 0, 1, 1);

/* Exit callback */
int exit_callback(int arg1, int arg2, void *common) {
	sceKernelExitGame();
	return 0;
}

/* Callback thread */
int CallbackThread(SceSize args, void *argp) {
	int cbid;

	cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
	sceKernelRegisterExitCallback(cbid);

	sceKernelSleepThreadCB();

	return 0;
}

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks(void) {
	int thid = 0;

	thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
	if(thid >= 0) {
		sceKernelStartThread(thid, 0, 0);
	}

	return thid;
}

void flashers_1(void){
Wait;
		ClearScreen;
		char buffer[200];
	Image* flashers;
	sprintf(buffer, "flashers.png");
	flashers = loadImage(buffer);
	if (!flashers) {
		//Image load failed
		printf("Image load failed!\n");
	} else {
		int x = 0;
		int y = 0;
		sceDisplayWaitVblankStart();
		while (x < 480) {
			while (y < 272) {
				blitAlphaImageToScreen(0 ,0 ,272 , 480, flashers, x, y);
				y += 272;
			}
			x += 480;
			y = 0;
		}
	}
}

int main(void)
{	
char buffer[200];
	Image* one;
	pspDebugScreenInit();
	SetupCallbacks();
	initGraphics();
	sprintf(buffer, "one.png");
	one = loadImage(buffer);
	if (!one) {
		//Image load failed
		printf("Image load failed!\n");
	} else {
		int x = 0;
		int y = 0;
		sceDisplayWaitVblankStart();
		while (x < 480) {
			while (y < 272) {
				blitAlphaImageToScreen(0 ,0 ,272 , 480, one, x, y);
				y += 272;
			}
			x += 480;
			y = 0;
		}
	
		flipScreen();
		flashers_1();
}
	sceKernelSleepThread();
    
	return 0;   // never reaches here, again, just to suppress warning 
}

So what happens is that is sticks to int main when i want it to jump to flashers_1();. any idea of what im doing wrong?

EDIt, i noticed the first few includes wont show, so here they are

#include psppower.h
#include pspsdk.h
#include pspdisplay.h
#include pspctrl.h
#include pspkernel.h
#include pspdebug.h
#include pspgu.h
#include png.h
#include stdio.h
#include "graphics.h"

EDIT2: forgot to flip the screen and change the resolution, fixed. lol

Is there anyway to clear the memory during an homebrew, i think my app is using up all the ram so i need to empty it. anyway?

I dont know if this will work in your case, but in nand currency i use

Code:
	sceIoClose(fd);
	free(pBlockTable);
	free(pBlockBuf);

It goes right at the end where your return; 0 } is at. :)
 

Alex

Active Member
best way to blit images?

im working on a psp program, infact a psp game and i was wondering, what is the best way to blit multiple images without filling up the ram. have you got any advice or what size images to use, ect. any help would be great.
 

Roe

Well-Known Member
Well by blitting multiple images I'd be more interested in keeping the fps at a nice level than filling up the RAM.

So if you're looking for blitting speed I'd suggest you check out the blit sample in the sample/gu directory that came with the pspsdk. It's got both swizzling and slice blitting in there.

If by blitting you meant loading then it really depends on the quality you want from your images, play around with the code at this link HERE and you'll see the difference in the quality of the images you load. Better quality generally = more memory usage.
 

Alex

Active Member
Well by blitting multiple images I'd be more interested in keeping the fps at a nice level than filling up the RAM.

So if you're looking for blitting speed I'd suggest you check out the blit sample in the sample/gu directory that came with the pspsdk. It's got both swizzling and slice blitting in there.

If by blitting you meant loading then it really depends on the quality you want from your images, play around with the code at this link HERE and you'll see the difference in the quality of the images you load. Better quality generally = more memory usage.

thanks but the link is broken
 

angelsniper45

New Member

The-R

The One & Only
ok so i tried setting up my psp sdk and what not. using Notepad++ as well. PSPSDK 0.8.10. made a program and saved it with the .c extension and made a make file with the .mak extension. now trying to make it into a EBOOT through CMD but the make command doesnt work. it jus says make: *** no targets specified and no makefile found. stop. can sumone tell me what im doing wrong cause i really wanna learn and cement the basics b4 i move on to something harder.
 
Top