dc v6 graphics

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

What about int __psp_free_heap(void); ?

For some reason the module_stop() never gets called in my PRXs.
Unless I manually call __psp_free_heap() in my main thread before unloading, I usually lose some memory which causes problems in XMB. I've included the following PRX_EXPORTS file:

Code: Select all

# Define the exports for the prx

PSP_BEGIN_EXPORTS

# These four lines are mandatory (although you can add other functions like module_stop)
# syslib is a psynonym for the single mandatory export.

PSP_EXPORT_START(syslib, 0, 0x8000)

PSP_EXPORT_FUNC(module_start)
PSP_EXPORT_VAR(module_info)
PSP_EXPORT_FUNC(module_stop)

PSP_EXPORT_END

PSP_END_EXPORTS
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Here is the new binary+libc lib: http://www.sendspace.com/file/ncrj2b

There is a problem with _impure_ptr though. _impure_ptr_ is a variable, and while pspsdk lets variables to be exported, it doesn't allow them to be imported. The solution is a bit tricky: add struct _reent *_impure_ptr = NULL; in one of your source files, hopefully it won't have effects in execution, I have no idea what _impure_ptr is used for.

Anyways i planned to support png and other formats in future and keep 2 version of the library, one whith those format support which would be bigger, and other without them. Whenever I do that, I will aproach to export libpng, zlib, etc.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Thanks a lot. Its compiling now.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Its compiling without errors, but it crashes with 0x8002013C.

Even simply including the graphics.o in the makefile causes the error, even without calling ANY function from it at all.
Remove graphics.o from the makefile and it works fine.

The graphics.c is in the file I uploaded. I've added struct _reent *_impure_ptr = NULL; while compiling.

The exact same graphics.c works fine using ordinary newlib.
There are no other GU functions at all, its only a PNG decompresser.
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

moonlight wrote:Try that one: http://www.sendspace.com/file/ptlrqe
Same error.

Heres a test project showing exactly the problem.
http://www.sendspace.com/file/cm3tiw

Remove graphics.o from the makefile and its fine.
Hellcat
Posts: 83
Joined: Wed Jan 24, 2007 2:52 pm

Post by Hellcat »

One question while we're at it:

Are you using the original functions of the FW to show the GUI (paf.prx and the such) or did you re-code it based on your reversal?
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

I recoded, using paf directly is more difficult.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

I can't seem to load the original vshmain.prx from my PRX when using VLF.
I've replaced vshmain.prx with my custom VLF based one and it runs fine.
However when I try to start module the original vshmain.prx it just hangs. Doesn't return any error or anything.

I'm guessing it needs some cleanup or something before the original vshmain.prx can use the GUI stuff again. I've manually destroyed all objects and unloaded the iop.prx, intraFont.prx and vlf.prx, but it still crashes.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Excuse me,
but to use dcManager funcions I've to laod specific prx's?
And pspIplUpdate?
( I think that a prx has to load because I've see that the function are exported! )
Mashphealh
Posts: 18
Joined: Wed Nov 28, 2007 4:18 am

Post by Mashphealh »

ne0h wrote:Excuse me,
but to use dcManager funcions I've to laod specific prx's?
And pspIplUpdate?
( I think that a prx has to load because I've see that the function are exported! )
You have to load dcman.prx located at dc folder \kd, and include in line OBJS of your makefile DcManager.o .

But, it's strange... Moonlight doesn't load it from main.c of vunbricker.

PD : Moonlight, just a question. dcLflashStartFatfmt only returns vshLflashFatfmtStartFatfmt or there are more/different code in that function ?
Hellcat
Posts: 83
Joined: Wed Jan 24, 2007 2:52 pm

Post by Hellcat »

AFAIK he loads dcman at boot time (pspbtcfg).

The format function indeed seems to be only a bridge, the more magic thing is dcPatchModule - but I have yet to inderstand why he also patches when OFW is to be installed....
Mashphealh
Posts: 18
Joined: Wed Nov 28, 2007 4:18 am

Post by Mashphealh »

Hellcat wrote:AFAIK he loads dcman at boot time (pspbtcfg).

The format function indeed seems to be only a bridge, the more magic thing is dcPatchModule - but I have yet to inderstand why he also patches when OFW is to be installed....
Hellcat, are you reversed dcPatchModule ?

Seems that first, use sceKernelFindModuleByName for found a module. Them if findmodulebyname returns 0, dcPatchModule returns 0xFFFFFFFF, else the function uses various mips asm functions as sw, sb and sh to patch the module, but I don't understand complete the code.

Format function has more than a simple bridge function, is thus :

Code: Select all

int dcLflashStartFatfmt(int args, char *argv[])
{
       int k1 = pspSdkSetK1(0);
       int res;
       int ra;
       res = SystemCtrlForKernel_EB74FE45(4);
       sceLflashFatfmtStartFatfmt(args, argv);
       ra = SystemCtrlForKernel_EB74FE45(res);
       pspSdkSetK1(k1);
       return ra;
}
I thought that it only returns sceLflashFatfmtStartFatfmt or vshLflash... but not, is thus.
Hellcat
Posts: 83
Joined: Wed Jan 24, 2007 2:52 pm

Post by Hellcat »

As far as I got dcPatchModule:

Code: Select all

void dcPatchModule( char* modName, int unk, int value, int offset);
Given unk is "1" (it's only used that way, so far) it does this:

Code: Select all

mod = (u32)sceFindModuleByName( modName );
_sh( value, mod+offset );
It stores/overwrites a 16 bit value at the address "offset" inside the module.


I could be wrong tho :p
Mashphealh
Posts: 18
Joined: Wed Nov 28, 2007 4:18 am

Post by Mashphealh »

From dcPatchModule I got :

Code: Select all

 int dcPatchModule(const char *modulename, unsigned int unk, unsigned int addr, unsigned int unkk); 
Inside the function there is this code :

Code: Select all

int dcPatchModule(const char *modulename, unsigned int unk, unsigned int addr, unsigned int unkk)
{
	int k1 = pspSdkSetK1(0);
	SceModule2 *mod;
	mod = sceKernelFindModuleByName(modulename);
	if(mod != 0)
	{
		if&#40;unk < 0&#41;
		&#123;
			if&#40;unk != 1&#41;
			&#123;
				if&#40;unk != 2&#41;
				&#123;
					goto loc_954;
					
				&#125;
				_sb&#40;unkk & 0xFF, mod->text_addr + addr&#41;;
			&#125;
		_sh&#40;unkk & 0xFFFF, addr + mod->text_addr&#41;;
		&#125;
		_sw&#40;unkk, mod->text_addr + addr&#41;;
		loc_954&#58;
		sceKernelDcacheWritebackAll&#40;&#41;;
		sceKernelIcacheClearAll&#40;&#41;;
		pspSdkSetK1&#40;k1&#41;;
		return 0;
	&#125;
	pspSdkSetK1&#40;k1&#41;;
	return 0xFFFFFFFF;
&#125;
I can be wrong also.
Last edited by Mashphealh on Sat Aug 09, 2008 10:50 pm, edited 1 time in total.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Any one know why its crashing when I sceKernelStartModule vshmain.prx?
It successfully loads the XMB in the very same program when I DON'T use VLF.

If I don't use VLF I can call __psp_free_heap() before I load vshmain.prx and there is around 27MB free. With vlflibc that function doesnt exist it seems.

If render the WAVE background with VLF, there is about 18MB free RAM on a Slim PSP after initializing VLF with the minimum working heap size of around 5MB.
Since VLF uses heap, even If i remove the rendered objects, the RAM isn't returned to the system until the heap is freed (Which I assume can't be done without __psp_free_heap(). Even then I think it can only be done from inside vlf.prx)

I'm guessing its because 18MB free on a Slim is not enough for vshmain.prx and it probably needs the usual 27MB (even though the Phat has only 2.8MB before vshmain.prx).

BTW my program is a replacement vshmain.prx, NOT an EBOOT. All the memory values I've mentioned are after powering on and my replacement vshmain.prx is loaded.
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

vlf already calls free heap at module_stop, but it leaves timers and callbacks executing, so if you stop it and unload it, it will surely crash.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

moonlight wrote:vlf already calls free heap at module_stop, but it leaves timers and callbacks executing, so if you stop it and unload it, it will surely crash.
Oh, previously I though it only installed callbacks etc when you created menus and stuff, not that it had callbacks even if you simply use it.

Is it something unfixable or have you just left it like this for now because it just enough to work in DC6?

Will I ever be able to create a replacement vshmain.prx using VLF even after you have fully developed it?
moonlight
Posts: 567
Joined: Wed Oct 26, 2005 7:46 pm

Post by moonlight »

Torch wrote:
moonlight wrote:vlf already calls free heap at module_stop, but it leaves timers and callbacks executing, so if you stop it and unload it, it will surely crash.
Oh, previously I though it only installed callbacks etc when you created menus and stuff, not that it had callbacks even if you simply use it.

Is it something unfixable or have you just left it like this for now because it just enough to work in DC6?

Will I ever be able to create a replacement vshmain.prx using VLF even after you have fully developed it?
yeah i guess that when i add a proper shutdown you will be able to do it. vlf creates always a power callback (this is to update clock and battery when returning from sleep mode, in case they exist), and timers are created if battery or clock are added.
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

moonlight wrote:yeah i guess that when i add a proper shutdown you will be able to do it. vlf creates always a power callback (this is to update clock and battery when returning from sleep mode, in case they exist), and timers are created if battery or clock are added.
I don't want to add anything other than the wave background and some pictures.
Would it be an easy task to make it add the power callback ONLY if the clock/battery are present, such that it would be possible to unload VLF (or are there more complications that make it impossible in its current state) ?
stefyx7
Posts: 12
Joined: Thu Jul 31, 2008 10:25 pm
Contact:

Post by stefyx7 »

Hi!

OT/This is my first post, excuse me for don't introduce in the forum and for my bad english!I'm italian xd..../OT

I have many problems whit this library...I wanted to make a nice sample that it made to see a menù (that of dc6)...I make a main.cpp and a makefile but not be done....

main.cpp:

Code: Select all

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspctrl.h>
#include <stdlib.h>
#include <string.h>
#include <pspdisplay.h>
#include <pspsdk.h>
#include <pspsuspend.h>
#include <psppower.h>
#include <pspreg.h>
#include <psprtc.h>
#include <psputils.h>
#include <systemctrl.h>
#include <kubridge.h>
#include <stdio.h>
#include <stdarg.h>
#include <libpsardumper.h>
#include <pspdecrypt.h>
#include <pspipl_update.h>
#include <vlf.h>
#include <time.h>

#define RGB&#40;r, g, b&#41; &#40;&#40;b << 16&#41; | &#40;g << 8&#41; | r&#41;
#define GREEN &#40;0, 255, 0&#41;
#define BLUE RGB&#40;0, 0, 255&#41;
#define BLACK RGB&#40;0, 0, 0&#41;
#define WHITE RGB&#40;255, 255, 255&#41;
#define RED RGB&#40;255, 0, 0&#41;
#define YELLOW RGB&#40;255, 255, 0&#41;

PSP_MODULE_INFO&#40;"Test", 0, 1, 0&#41;;
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;
PSP_HEAP_SIZE_KB&#40;12*1024&#41;;
#define SMALL_BUFFER_SIZE	2100000
static int BIG_BUFFER_SIZE;

void *ReadFileAllocEx&#40;char *file, int seek, int size, int *retSize&#41;;

int done = 0;

int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	done = 1;
	return 0;
&#125;

int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;

int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;
	&#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;

	return thid;
&#125;

u8 *big_buffer;
u8 *sm_buffer1, *sm_buffer2;

#define N_FILES		12
int progress_text = -1, progress_bar = -1;
int status = -1;

void *ReadFileAllocEx&#40;char *file, int seek, int size, int *retSize&#41;;
int ReadFile&#40;char *file, int offset, void *buf, int size&#41;;
int WriteFile&#40;char *file, void *buf, int size&#41;;
void *malloc64&#40;int size&#41;;

int scePower_0442D852&#40;int&#41;;
#define scePowerRequestColdReset scePower_0442D852

void MainMenu&#40;int sel&#41;;

#define N_HI_ITEMS	10
int hi_texts&#91;N_HI_ITEMS&#93;;


typedef struct U64
&#123;
	u32 low;
	u32 high;
&#125; U64;


int OnMainMenuSelect&#40;int sel&#41;
&#123;
	void *wi;

	switch &#40;sel&#41;
	&#123;

	    case 0&#58;
			vlfGuiCancelBottomDialog&#40;&#41;;
			sceKernelExitGame&#40;&#41;;
		break;

		case 1&#58;
		&#123;
			vlfGuiAddWaitIcon&#40;&wi&#41;;
			scePowerRequestStandby&#40;&#41;;
			return VLF_EV_RET_REMOVE_HANDLERS;
		&#125;

		break;

		case 2&#58;
		&#123;

			vlfGuiAddWaitIcon&#40;&wi&#41;;
			scePowerRequestColdReset&#40;0&#41;;
			return VLF_EV_RET_REMOVE_HANDLERS;
		&#125;

		break;

		case 3&#58;
		&#123;
			vlfGuiAddWaitIcon&#40;&wi&#41;;
			sceKernelExitGame&#40;&#41;;
			return VLF_EV_RET_REMOVE_HANDLERS;
		&#125;

		break;



	&#125;

	return VLF_EV_RET_REMOVE_OBJECTS | VLF_EV_RET_REMOVE_HANDLERS;
&#125;


void MainMenu&#40;int sel&#41;
&#123;
	char *items&#91;&#93; =
	&#123;
		"By Stefyx7",
		"Shotdown",
		"Reboot",
		"Exit"
	&#125;;

	vlfGuiCentralMenu&#40;4, items, sel, OnMainMenuSelect, 0, 0&#41;;
	vlfGuiBottomDialog&#40;-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL&#41;;
&#125;

int app_main&#40;int argc, char *argv&#91;&#93;&#41;
&#123;
	SetupCallbacks&#40;&#41;;
	void *bi;
	void *data = ReadFileAllocEx&#40;"flash0&#58;/vsh/resource/01-12.bmp", 7*6176, 6176, NULL&#41;;

	if &#40;!data || vlfGuiSetBackgroundFileBuffer&#40;data, 6176&#41; < 0&#41;
	&#123;
		vlfGuiSetBackgroundPlane&#40;0xFF000000&#41;;
	&#125;

	if &#40;data&#41;
		free&#40;data&#41;;

	vlfGuiCacheResource&#40;"system_plugin"&#41;;
	vlfGuiCacheResource&#40;"system_plugin_fg"&#41;;

	vlfGuiSetModelSystem&#40;&#41;;
	vlfGuiAddBatteryIconSystem&#40;&bi, 10*1000*1000&#41;;
	vlfGuiAddClock&#40;&#41;;

	while &#40;!done&#41;
	&#123;
		vlfGuiDrawFrame&#40;&#41;;
	&#125;

	sceKernelExitGame&#40;&#41;;
   	return 0;
&#125;
makefile:

Code: Select all

TARGET = test
OBJS = crt0.o main.o graphics.o

INCDIR = ./include
CFLAGS = -O2 -G0 -Wall -fshort-wchar -fno-pic -mno-check-zero-division 
CXXFLAGS = $&#40;CFLAGS&#41; -fno-exceptions -fno-rtti
ASFLAGS = $&#40;CFLAGS&#41; -c

LIBDIR = ./lib
LDFLAGS = -mno-crt0 -nostdlib -nodefaultlibs
LIBS = -lvlfgui -lvlfgu -lvlfutils -lpng -lz -lm -lvlflibc -lpspkubridge

PSP_FW_VERSION = 150

BUILD_PRX = 1

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Test
#PSP_EBOOT_ICON="icon0.png"

PSPSDK=$&#40;shell psp-config --pspsdk-path&#41;
include ./build.mak
help meeeeeeeee!
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Compile this program I linked to before: http://www.sendspace.com/file/cm3tiw

Just remove the graphics.o from the makefile.
It should show just the wave background.
After that try adding menu's etc.
stefyx7
Posts: 12
Joined: Thu Jul 31, 2008 10:25 pm
Contact:

Post by stefyx7 »

Torch wrote:Compile this program I linked to before: http://www.sendspace.com/file/cm3tiw

Just remove the graphics.o from the makefile.
It should show just the wave background.
After that try adding menu's etc.
Thank you for the answer...I will try this
stefyx7
Posts: 12
Joined: Thu Jul 31, 2008 10:25 pm
Contact:

Post by stefyx7 »

excuse me for duble post but the programm crashed...!
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

stefyx7 wrote:excuse me for duble post but the programm crashed...!
Did you remove graphics.o from the makefile?? It isn't working with vlf right now.
stefyx7
Posts: 12
Joined: Thu Jul 31, 2008 10:25 pm
Contact:

Post by stefyx7 »

Torch wrote:
stefyx7 wrote:excuse me for duble post but the programm crashed...!
Did you remove graphics.o from the makefile?? It isn't working with vlf right now.
Yes I remove graphics.o from makefile and #include "graphics.h" form main.c but crashed......
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

Did you put the 3 PRXs from the DC6 installer in the same folder as the program on the memory stick?
iop.prx intrafont.prx vlf.prx

Use the latest version of vlf.prx from this thread.
Compile it with the same version of the libs.
stefyx7
Posts: 12
Joined: Thu Jul 31, 2008 10:25 pm
Contact:

Post by stefyx7 »

Torch wrote:Did you put the 3 PRXs from the DC6 installer in the same folder as the program on the memory stick?
iop.prx intrafont.prx vlf.prx

Use the latest version of vlf.prx from this thread.
Compile it with the same version of the libs.
nothing...i'm include in the eboot directory the files include in the directory:vlftset in the pack...but crashed...:(
User avatar
Torch
Posts: 825
Joined: Wed May 28, 2008 2:50 am

Post by Torch »

stefyx7 wrote: nothing...i'm include in the eboot directory the files include in the directory:vlftset in the pack...but crashed...:(
I've uploaded it again: http://www.sendspace.com/file/vcua55

Its the same thing. I compiled it so there is an EBOOT which is working on my PSP -- just tested it, using the PRXs from the vlftest folder.

Do you have a custom theme or something ? That might be causing a problem.
stefyx7
Posts: 12
Joined: Thu Jul 31, 2008 10:25 pm
Contact:

Post by stefyx7 »

Torch wrote:
stefyx7 wrote: nothing...i'm include in the eboot directory the files include in the directory:vlftset in the pack...but crashed...:(
I've uploaded it again: http://www.sendspace.com/file/vcua55

Its the same thing. I compiled it so there is an EBOOT which is working on my PSP -- just tested it, using the PRXs from the vlftest folder.

Do you have a custom theme or something ? That might be causing a problem.
no i'dont have a cxmb xd, try your example and post it...
Post Reply