 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
J-Fox
Joined: 26 Sep 2007 Posts: 15 Location: Hannover, Germany
|
Posted: Wed Sep 26, 2007 12:45 am Post subject: sceDisplayGetFrameBuf() fails, Bufferwidth / Pixelformat = 0 |
|
|
Hey, I m currently having a problem getting my code to work:
| Code: | #include <pspkernel.h>
#include <pspdisplay.h>
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("MSUpdate", 0x1000, 1, 1);
PSP_MAIN_THREAD_ATTR(0);
static int bufferwidth, pixelformat, unk, fd;
static u32* vram32;
static char cancel, format[512];
void add_log(const char* Text)
{
fd = sceIoOpen("ms0:/msupdate.txt", PSP_O_WRONLY | PSP_O_APPEND, 0777);
sceIoWrite(fd,Text,strlen(Text));
sceIoWrite(fd,"\n",strlen("\n"));
sceIoClose(fd);
}
int loop(SceSize args, void *argp)
{
add_log("Waiting");
sceKernelDelayThread(1000*5000);
add_log("Loop");
while(!cancel)
{
sceDisplayWaitVblankStart();
sceDisplayGetFrameBuf((void*)&vram32, &bufferwidth, &pixelformat, &unk);
if(bufferwidth!=0)
{
int x; int y;
for (x=0;x<20;x++)
{
for (y=0;y<20;y++)
{
vram32[x + y*bufferwidth] = 0xffff00ff;
}
}
} else {
sprintf(format,"Buffer-Width: %i, %i",bufferwidth, pixelformat);
add_log(format);
add_log("Error");
cancel=1;
}
}
add_log("Quit");
return 0;
}
int module_start(int argc, char **argv)
{
fd = sceIoOpen("ms0:/msupdate.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
sceIoClose(fd);
add_log("MSUpdate 0.1");
int thid = sceKernelCreateThread("MSUpdate", loop, 0x20, 0x1000, 0, 0);
sprintf(format,"Thread: %i",thid);
add_log(format);
if(thid >= 0) sceKernelStartThread(thid, 0, 0);
return 0;
} |
| Code: | TARGET = msupdate
OBJS = main.o
BUILD_PRX=1
PRX_EXPORTS=exports.exp
USE_KERNEL_LIBS = 1
USE_KERNEL_LIBC = 1
LIBS = -lpspkernel
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
LDFLAGS = -nostdlib -nodefaultlibs
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak |
All this returns is:
| Code: | MSUpdate 0.1
Thread: 73806443
Waiting
Loop
Buffer-Width: 0, 0
Error
Quit |
meaning that bufferwidth and pixelformat are 0. Now I wonder why...
GetVideoMode returns 480x272 so there doesnt seem to be a problem with the display calls in general.
The whole thing is running on 3.71 M33 (PSP1000) and 3.71 M33 (PSP2000), both having the same problem. Any ideas?
//Edit: This is supposed to draw a 20x20px box on the screen starting at the upper left corner in the XMB. It is loaded using the Recovery menu -> Plugins from VSH.txt |
|
| Back to top |
|
 |
weltall
Joined: 20 Feb 2004 Posts: 310
|
Posted: Wed Sep 26, 2007 4:04 am Post subject: |
|
|
did you fix nids before attempting this?
0xDEA197D4 [0x00001E6C] - sceDisplayGetMode => this wasn't touched by sony while get framebuffer was |
|
| Back to top |
|
 |
J.F.
Joined: 22 Feb 2004 Posts: 2906
|
Posted: Wed Sep 26, 2007 10:14 am Post subject: |
|
|
| The last arg for sceDisplayGetFrameBuf() is not &unk, it's the same as sceDisplaySetFrameBuf - a constant of either PSP_DISPLAY_SETBUF_IMMEDIATE or PSP_DISPLAY_SETBUF_NEXTFRAME. |
|
| Back to top |
|
 |
J-Fox
Joined: 26 Sep 2007 Posts: 15 Location: Hannover, Germany
|
Posted: Wed Sep 26, 2007 6:00 pm Post subject: |
|
|
weltall:
I havent works with nids before and i wasnt able to find any helpful posts on the forum either about this topic, however: i assumed adding an ASM Stub would help:
| Code: | .set noreorder
#include "pspstub.s"
STUB_START "sceDisplay_driver", 0x40010000, 0x00010005
STUB_FUNC 0xEEDA2E54, sceDisplayGetFrameBuf
STUB_END |
I added this to the "OBJS" but it didnt really help either. (I m pretty sure i m doing something wrong here :P, the first param for STUB_FUNC was taken from http://silverspring.lan.st/3.5x/index.html btw, since i wasnt able to find any newer version for 3.7x)
J.F.:
Yeh i read about this in another topic, but i had an outdated toolchain which still had the wrong parameters, so i decided to put it like that so it doesnt bitch on every compile (it didnt work anyways ;) )
//Edit:
Just changed the stub to:
| Code: | .set noreorder
#include "pspstub.s"
STUB_START "sceDisplay", 0x40010000, 0x00010005
STUB_FUNC 0xEEDA2E54, sceDisplayGetFrameBuf
STUB_END |
And its still not working, BUT i m kinda sure that the nid is correct cause i tried using prxtool on Coolj's screenshot plugin which is using exactly the same imports! Somehow i start to believe that the function can only be called from usermode or something weird
//Edit:
_______________________________________________________
Working solution
makefile
| Code: | TARGET = msupdate
OBJS = main.o
BUILD_PRX=1
PRX_EXPORTS=exports.exp
INCDIR =
CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak |
main.c
| Code: | #include <pspuser.h>
#include <pspdisplay.h>
#include <stdio.h>
#include <string.h>
PSP_MODULE_INFO("MSUpdate", 0x0, 1, 1);
PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
static int bufferwidth, pixelformat, fd;
static char cancel, format[512];
static u32* vram32;
void add_log(const char* Text)
{
fd = sceIoOpen("ms0:/msupdate.txt", PSP_O_WRONLY | PSP_O_APPEND, 0777);
sceIoWrite(fd,Text,strlen(Text));
sceIoWrite(fd,"\r\n",strlen("\r\n"));
sceIoClose(fd);
}
int main(int argc, char **argv)
{
fd = sceIoOpen("ms0:/msupdate.txt", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
sceIoClose(fd);
add_log("MSUpdate 0.1");
add_log("Waiting");
int i;
for (i=0;i<60*5;i++)
{
sceDisplayWaitVblankStart();
}
add_log("Loop");
while(!cancel)
{
sceDisplayWaitVblankStart();
sceDisplayGetFrameBuf((void*)&vram32, &bufferwidth, &pixelformat, 0);
if(bufferwidth!=0)
{
int x; int y;
for (x=0;x<20;x++)
{
for (y=0;y<20;y++)
{
vram32[x + y*bufferwidth] = 0xffff00ff;
}
}
} else {
sprintf(format,"Display Data: %i, %i",bufferwidth, pixelformat);
add_log(format);
for (i=0;i<60*5;i++)
{
sceDisplayWaitVblankStart();
}
}
}
add_log("Quit");
return 0;
} |
I m still asking myself: WHY... Can't see a reason why it havent worked before. However, shouldnt be too hard to find out |
|
| Back to top |
|
 |
weltall
Joined: 20 Feb 2004 Posts: 310
|
Posted: Wed Sep 26, 2007 10:46 pm Post subject: |
|
|
because before you had a wrong nid (the nid you posted isn't right on 3.71)
while the other is an improper plugin as it's user mode and could give problems to homebrews and games (just like the screenshoot plugin for 3.71)
nids for user weren't changed so now it seems to work.
if you want to do a proper plugin please fix that nid with the new one you may use prxtool to easily get it (tyranid did an update to it to make this easier yesterday) and build it in kernel mode |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|