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);
}
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;}
#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
}
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?
sceIoClose(fd);
free(pBlockTable);
free(pBlockBuf);
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
I said I fixed the link in the previous post.No its not, it works fine for me. Try it again
I said I fixed the link in the previous post.
Ah, fail link pasting, fixed and here it is again http://forums.ps2dev.org/viewtopic.php?t=11509&highlight=txc+png