forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

dc v6 graphics
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Fri Aug 08, 2008 8:58 am    Post subject: Reply with quote

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:
# 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
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Fri Aug 08, 2008 9:15 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Fri Aug 08, 2008 9:33 am    Post subject: Reply with quote

Thanks a lot. Its compiling now.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Fri Aug 08, 2008 10:03 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Fri Aug 08, 2008 4:23 pm    Post subject: Reply with quote

Try that one: http://www.sendspace.com/file/ptlrqe
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Fri Aug 08, 2008 6:30 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Hellcat



Joined: 24 Jan 2007
Posts: 84

PostPosted: Fri Aug 08, 2008 7:22 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Fri Aug 08, 2008 10:20 pm    Post subject: Reply with quote

I recoded, using paf directly is more difficult.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Fri Aug 08, 2008 10:28 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
ne0h



Joined: 21 Feb 2008
Posts: 386

PostPosted: Sat Aug 09, 2008 3:12 am    Post subject: Reply with quote

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! )
Back to top
View user's profile Send private message
Mashphealh



Joined: 28 Nov 2007
Posts: 18

PostPosted: Sat Aug 09, 2008 3:42 am    Post subject: Reply with quote

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 ?
Back to top
View user's profile Send private message
Hellcat



Joined: 24 Jan 2007
Posts: 84

PostPosted: Sat Aug 09, 2008 6:45 am    Post subject: Reply with quote

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....
Back to top
View user's profile Send private message
Mashphealh



Joined: 28 Nov 2007
Posts: 18

PostPosted: Sat Aug 09, 2008 8:18 am    Post subject: Reply with quote

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:

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.
Back to top
View user's profile Send private message
Hellcat



Joined: 24 Jan 2007
Posts: 84

PostPosted: Sat Aug 09, 2008 11:38 am    Post subject: Reply with quote

As far as I got dcPatchModule:

Code:
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:
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
Back to top
View user's profile Send private message
Mashphealh



Joined: 28 Nov 2007
Posts: 18

PostPosted: Sat Aug 09, 2008 9:47 pm    Post subject: Reply with quote

From dcPatchModule I got :

Code:
 int dcPatchModule(const char *modulename, unsigned int unk, unsigned int addr, unsigned int unkk);


Inside the function there is this code :

Code:

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(unk < 0)
      {
         if(unk != 1)
         {
            if(unk != 2)
            {
               goto loc_954;
               
            }
            _sb(unkk & 0xFF, mod->text_addr + addr);
         }
      _sh(unkk & 0xFFFF, addr + mod->text_addr);
      }
      _sw(unkk, mod->text_addr + addr);
      loc_954:
      sceKernelDcacheWritebackAll();
      sceKernelIcacheClearAll();
      pspSdkSetK1(k1);
      return 0;
   }
   pspSdkSetK1(k1);
   return 0xFFFFFFFF;
}

I can be wrong also.


Last edited by Mashphealh on Sat Aug 09, 2008 10:50 pm; edited 1 time in total
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat Aug 09, 2008 10:13 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Sat Aug 09, 2008 10:46 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sat Aug 09, 2008 10:53 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
moonlight



Joined: 26 Oct 2005
Posts: 567

PostPosted: Sun Aug 10, 2008 12:17 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Sun Aug 10, 2008 3:48 am    Post subject: Reply with quote

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) ?
Back to top
View user's profile Send private message
stefyx7



Joined: 31 Jul 2008
Posts: 12

PostPosted: Mon Aug 11, 2008 12:51 am    Post subject: Reply with quote

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:
#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(r, g, b) ((b << 16) | (g << 8) | r)
#define GREEN (0, 255, 0)
#define BLUE RGB(0, 0, 255)
#define BLACK RGB(0, 0, 0)
#define WHITE RGB(255, 255, 255)
#define RED RGB(255, 0, 0)
#define YELLOW RGB(255, 255, 0)

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

void *ReadFileAllocEx(char *file, int seek, int size, int *retSize);

int done = 0;

int exit_callback(int arg1, int arg2, void *common)
{
   done = 1;
   return 0;
}

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

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

   return 0;
}

int SetupCallbacks(void)
{
   int thid = 0;

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

   return thid;
}

u8 *big_buffer;
u8 *sm_buffer1, *sm_buffer2;

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

void *ReadFileAllocEx(char *file, int seek, int size, int *retSize);
int ReadFile(char *file, int offset, void *buf, int size);
int WriteFile(char *file, void *buf, int size);
void *malloc64(int size);

int scePower_0442D852(int);
#define scePowerRequestColdReset scePower_0442D852

void MainMenu(int sel);

#define N_HI_ITEMS   10
int hi_texts[N_HI_ITEMS];


typedef struct U64
{
   u32 low;
   u32 high;
} U64;


int OnMainMenuSelect(int sel)
{
   void *wi;

   switch (sel)
   {

       case 0:
         vlfGuiCancelBottomDialog();
         sceKernelExitGame();
      break;

      case 1:
      {
         vlfGuiAddWaitIcon(&wi);
         scePowerRequestStandby();
         return VLF_EV_RET_REMOVE_HANDLERS;
      }

      break;

      case 2:
      {

         vlfGuiAddWaitIcon(&wi);
         scePowerRequestColdReset(0);
         return VLF_EV_RET_REMOVE_HANDLERS;
      }

      break;

      case 3:
      {
         vlfGuiAddWaitIcon(&wi);
         sceKernelExitGame();
         return VLF_EV_RET_REMOVE_HANDLERS;
      }

      break;



   }

   return VLF_EV_RET_REMOVE_OBJECTS | VLF_EV_RET_REMOVE_HANDLERS;
}


void MainMenu(int sel)
{
   char *items[] =
   {
      "By Stefyx7",
      "Shotdown",
      "Reboot",
      "Exit"
   };

   vlfGuiCentralMenu(4, items, sel, OnMainMenuSelect, 0, 0);
   vlfGuiBottomDialog(-1, VLF_DI_ENTER, 1, 0, VLF_DEFAULT, NULL);
}

int app_main(int argc, char *argv[])
{
   SetupCallbacks();
   void *bi;
   void *data = ReadFileAllocEx("flash0:/vsh/resource/01-12.bmp", 7*6176, 6176, NULL);

   if (!data || vlfGuiSetBackgroundFileBuffer(data, 6176) < 0)
   {
      vlfGuiSetBackgroundPlane(0xFF000000);
   }

   if (data)
      free(data);

   vlfGuiCacheResource("system_plugin");
   vlfGuiCacheResource("system_plugin_fg");

   vlfGuiSetModelSystem();
   vlfGuiAddBatteryIconSystem(&bi, 10*1000*1000);
   vlfGuiAddClock();

   while (!done)
   {
      vlfGuiDrawFrame();
   }

   sceKernelExitGame();
      return 0;
}


makefile:

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

INCDIR = ./include
CFLAGS = -O2 -G0 -Wall -fshort-wchar -fno-pic -mno-check-zero-division
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS) -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=$(shell psp-config --pspsdk-path)
include ./build.mak


help meeeeeeeee!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Mon Aug 11, 2008 12:56 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
stefyx7



Joined: 31 Jul 2008
Posts: 12

PostPosted: Mon Aug 11, 2008 12:59 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
stefyx7



Joined: 31 Jul 2008
Posts: 12

PostPosted: Mon Aug 11, 2008 1:10 am    Post subject: Reply with quote

excuse me for duble post but the programm crashed...!
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Mon Aug 11, 2008 1:11 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
stefyx7



Joined: 31 Jul 2008
Posts: 12

PostPosted: Mon Aug 11, 2008 1:18 am    Post subject: Reply with quote

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......
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Mon Aug 11, 2008 1:23 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
stefyx7



Joined: 31 Jul 2008
Posts: 12

PostPosted: Mon Aug 11, 2008 2:04 am    Post subject: Reply with quote

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...:(
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Torch



Joined: 28 May 2008
Posts: 842

PostPosted: Mon Aug 11, 2008 2:31 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
stefyx7



Joined: 31 Jul 2008
Posts: 12

PostPosted: Mon Aug 11, 2008 3:16 am    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
Page 2 of 9

 
Jump to:  
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