danzeff osk and graphics.h library problem

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

Moderators: cheriff, TyRaNiD

Post Reply
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

danzeff osk and graphics.h library problem

Post by ne0h »

Excuse me,
I'm working on a text editor,
I've already write all the functions, but now I'll add the danzeff osk!
I've writed this:

Code: Select all

while (1)
{
        psp_main_screen();
        
        if (danzeff)
        {
            guStart();
            danzeff_render();
        }
        
        flipScreen();

      ....
}
( initGraphics(); is called before, and the main_screen blit 2 images to screen using blitAlphaImageToScreen function )
But It doesn't work,
when I press SELECT ( to active the osk ) the psp freeze, why?
Sorry for my bad english!
Last edited by ne0h on Mon Aug 18, 2008 4:39 am, edited 1 time in total.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

I've try with this solution:

Code: Select all

while (1)
{
        psp_main_screen();
       
        if (danzeff)
        {
            guStart();
            danzeff_render();
            sceGuFinish();
            sceGuSync(0,0);
        }
       
        flipScreen();

      ....
}
But this is the results:
Image
And this is the screen before try to blit the osk:
Image

Please, help! :(
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

The init code used in graphics.c doesn't work for things like intraFonts or danzeff. Try this one:

Code: Select all

	// setup GU
	sceGuInit();
	sceGuStart(GU_DIRECT,list);
	sceGuDrawBuffer(GU_PSM_8888,(void*)DRAW_BUF,BUF_WIDTH);
	sceGuDispBuffer(SCR_WIDTH,SCR_HEIGHT,(void*)DISP_BUF,BUF_WIDTH);
	sceGuDepthBuffer((void*)DEBUG_BUF,BUF_WIDTH);
	sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
	sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
	sceGuDepthRange(65535,0);
	sceGuDepthMask(GU_TRUE);
	sceGuDisable(GU_DEPTH_TEST);
	sceGuDisable(GU_BLEND);
	sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
	sceGuEnable(GU_SCISSOR_TEST);
	sceGuFrontFace(GU_CW);
	sceGuEnable(GU_TEXTURE_2D);
	sceGuClear(GU_COLOR_BUFFER_BIT);
	sceGuFinish();
	sceGuSync(0,0);
	sceDisplayWaitVblankStart();
	sceGuDisplay(GU_TRUE);
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Can you post the definition of DRAW_BUF etc?
I've try to set all buf (DRAW_BUF, DISP_BUF and DEBUG_BUF) to 512 and the results is badder than before!
All the screen is black and only little part of it is correctly show! O.O
This is my initGraphics function now:

Code: Select all

#define DEBUG_BUF (512)
#define DISP_BUF (512)
#define DRAW_BUF (512)
#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
#define PIXEL_SIZE (4)
#define FRAME_SIZE (BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE)
#define ZBUF_SIZE (BUF_WIDTH SCR_HEIGHT * 2)

void initGraphics()
{
	dispBufferNumber = 0;

        sceGuInit();
        sceGuStart(GU_DIRECT,list);
        sceGuDrawBuffer(GU_PSM_8888, (void*)DRAW_BUF, BUF_WIDTH);
        sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)DISP_BUF, BUF_WIDTH);
        sceGuDepthBuffer((void*)DEBUG_BUF,BUF_WIDTH);
        sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
        sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
        sceGuDepthRange(65535,0);
        sceGuDepthMask(GU_TRUE);
        sceGuDisable(GU_DEPTH_TEST);
        sceGuDisable(GU_BLEND);
        sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
        sceGuEnable(GU_SCISSOR_TEST);
        sceGuFrontFace(GU_CW);
        sceGuEnable(GU_TEXTURE_2D);
        sceGuClear(GU_COLOR_BUFFER_BIT);
        sceGuFinish();
        sceGuSync(0,0);
        sceDisplayWaitVblankStart();
        sceGuDisplay(GU_TRUE);
        
	initialized = 1;
}
KickinAezz
Posts: 328
Joined: Sun Jun 03, 2007 10:05 pm

Post by KickinAezz »

ne0h wrote:Can you post the definition of DRAW_BUF etc?
I've try to set all buf (DRAW_BUF, DISP_BUF and DEBUG_BUF) to 512 and the results is badder than before!
All the screen is black and only little part of it is correctly show! O.O
This is my initGraphics function now:

Code: Select all

#define DEBUG_BUF (512)
#define DISP_BUF (512)
#define DRAW_BUF (512)
#define BUF_WIDTH (512)
#define SCR_WIDTH (480)
#define SCR_HEIGHT (272)
#define PIXEL_SIZE (4)
#define FRAME_SIZE (BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE)
#define ZBUF_SIZE (BUF_WIDTH SCR_HEIGHT * 2)

void initGraphics()
{
	dispBufferNumber = 0;

        sceGuInit();
        sceGuStart(GU_DIRECT,list);
        sceGuDrawBuffer(GU_PSM_8888, (void*)DRAW_BUF, BUF_WIDTH);
        sceGuDispBuffer(SCR_WIDTH, SCR_HEIGHT, (void*)DISP_BUF, BUF_WIDTH);
        sceGuDepthBuffer((void*)DEBUG_BUF,BUF_WIDTH);
        sceGuOffset(2048 - (SCR_WIDTH/2),2048 - (SCR_HEIGHT/2));
        sceGuViewport(2048,2048,SCR_WIDTH,SCR_HEIGHT);
        sceGuDepthRange(65535,0);
        sceGuDepthMask(GU_TRUE);
        sceGuDisable(GU_DEPTH_TEST);
        sceGuDisable(GU_BLEND);
        sceGuScissor(0,0,SCR_WIDTH,SCR_HEIGHT);
        sceGuEnable(GU_SCISSOR_TEST);
        sceGuFrontFace(GU_CW);
        sceGuEnable(GU_TEXTURE_2D);
        sceGuClear(GU_COLOR_BUFFER_BIT);
        sceGuFinish();
        sceGuSync(0,0);
        sceDisplayWaitVblankStart();
        sceGuDisplay(GU_TRUE);
        
	initialized = 1;
}
Are you sure YOU coded a text editor? I see a LOT of BARE BASICS missing...
Intrigued by PSP system Since December 2006.
Use it more for Development than for Gaming.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Yes I've coded it by myself!
Anyway I doesn't know the sceGu library, so please, can you help me?
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

try this:

Code: Select all

#define BUF_WIDTH  (512)
#define SCR_WIDTH  (480)
#define SCR_HEIGHT (272)

void *dList;
void *fbp0;

...
	fbp0 = 0;
	dList = memalign(16, 640);

	sceGuDrawBuffer( GU_PSM_8888, fbp0, BUF_WIDTH );
	sceGuDispBuffer( SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
	sceGuDepthBuffer( (void*)0x110000, BUF_WIDTH);

...
And check out sdk samples, can be useful as to the GU stuff...
Last edited by kralyk on Mon Aug 18, 2008 5:36 am, edited 1 time in total.
...sorry for my english...
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

kralyk wrote:try this:

Code: Select all

#define BUF_WIDTH  (512)
#define SCR_WIDTH  (480)
#define SCR_HEIGHT (272)

void *dList;
void *fbp0;

...

	sceGuDrawBuffer( GU_PSM_8888, fbp0, BUF_WIDTH );
	sceGuDispBuffer( SCR_WIDTH, SCR_HEIGHT, (void*)0x88000, BUF_WIDTH);
	sceGuDepthBuffer( (void*)0x110000, BUF_WIDTH);

...
And check out sdk samples, can be useful as to the GU stuff...
Please don't teach people to use uninitialized variables like that.......
if at all then do this:
void *fbp0 = 0;
And the 'correct' defines of the *_BUFs would be this:
#define DRAW_BUF (0)
#define DISP_BUF (0x88000)
#define DEBUG_BUF (0x110000)
TBH, it quite sucks to use such hardcoded values though.

PS: Who the hell named the depth buffer define "DEBUG_BUF"?
Last edited by Raphael on Mon Aug 18, 2008 5:37 am, edited 2 times in total.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

oh yeah sorry, I got that line elswwhere, of course fbp0 = 0, sry, will edit that...

(hope its ok now)
...sorry for my english...
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Are you sure YOU coded a text editor? I see a LOT of BARE BASICS missing...
Yes I've coded it by myself!
Anyway I doesn't know the sceGu library, so please, can you help me?
Same old story... what's so fascinating about making people believe you're a software developer while in reality you're all in the world but that? When i was young, children were willing to become astronauts or super-heroes, not PSP nerds...
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

Not knowing the GU calls makes you think the person is not a programmer?

(Im just curious, I dont wanna to say wheter he wrote it himself or not)

EDIT: I still think he might have done it: http://www.psp-hacks.com/2008/08/04/xpl ... e-manager/ (if he the same ne0h)
...sorry for my english...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

ne0h wrote:Can you post the definition of DRAW_BUF etc?
I've try to set all buf (DRAW_BUF, DISP_BUF and DEBUG_BUF) to 512 and the results is badder than before!
All the screen is black and only little part of it is correctly show! O.O
I used variables since my code had to deal with the TV as well as the LCD.

Code: Select all

    // set PSP screen variables
    BUF_WIDTH = 768;
    SCR_WIDTH = psp_vidout_select ? 720 &#58; 480;
    SCR_HEIGHT = psp_vidout_select ? 480 &#58; 272;
    FRAME_SIZE = BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE;
    DISP_BUF = 0;
    if &#40;!psp_tv_laced&#41;
    &#123;
        DRAW_BUF = FRAME_SIZE;
        TEX_BUF = DRAW_BUF + FRAME_SIZE;
        DEBUG_BUF = TEX_BUF + 64*4*576;
    &#125;
    else
    &#123;
        DRAW_BUF = 0; // not double buffered
        TEX_BUF = FRAME_SIZE;
        DEBUG_BUF = TEX_BUF + 64*4*576;
        LACE_BUF = &#40;uint32&#41;sceGeEdramGetAddr&#40;&#41; + DEBUG_BUF + 512*4*8;
    &#125;
DISP_BUF and DRAW_BUF are your two double-buffers. TEX_BUF was a small space I used for millions mode refresh. DEBUG_BUF was the offset for the debug printing, and LACE_BUF is the interlaced framebuffer if you were using the TV in interlaced mode. Interlaced mode also implied no double-buffer, so DRAW_BUF was 0. All those buffers (except LACE_BUF) are offsets from the start of video EDRAM.
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

Not knowing the GU calls makes you think the person is not a programmer?
No, it's not that (even if someone willing can open documentation and see by himself) ...he's one of our old stories... anyway i was speaking of children in general...
Apart from the fact that an optimistic 1/10 of people posting here are "programmers" for their formation at university or work, a 4/10 serious hobbyists and the remaining 5/10... well, you know.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Thanks kralyk, yes, Xplora is a my project (and I've writed it by myself),
I'm working on the Text editor for Xplora 1.6! :)
Anyway thanks...
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Sorry, but I've still problems! :(
This is my initGraphics function now:

Code: Select all

#define DRAW_BUF &#40;0&#41;
#define DISP_BUF &#40;0x88000&#41;
#define DEBUG_BUF &#40;0x110000&#41;
#define BUF_WIDTH &#40;512&#41;
#define SCR_WIDTH &#40;480&#41;
#define SCR_HEIGHT &#40;272&#41;
#define PIXEL_SIZE &#40;4&#41;
#define FRAME_SIZE &#40;BUF_WIDTH * SCR_HEIGHT * PIXEL_SIZE&#41;
#define ZBUF_SIZE &#40;BUF_WIDTH SCR_HEIGHT * 2&#41;

void initGraphics&#40;&#41;
&#123;
	dispBufferNumber = 0;
        
        void *dList;
        void *fbp0;
        
        fbp0 = 0;
        dList = memalign&#40;16, 640&#41;;
        
        sceGuInit&#40;&#41;;
        sceGuStart&#40;GU_DIRECT,list&#41;;
        sceGuDrawBuffer&#40; GU_PSM_8888, fbp0, BUF_WIDTH &#41;;
        sceGuDispBuffer&#40; SCR_WIDTH, SCR_HEIGHT, &#40;void*&#41;0x88000, BUF_WIDTH&#41;;
        sceGuDepthBuffer&#40; &#40;void*&#41;0x110000, BUF_WIDTH&#41;; 
        sceGuOffset&#40;2048 - &#40;SCR_WIDTH/2&#41;,2048 - &#40;SCR_HEIGHT/2&#41;&#41;;
        sceGuViewport&#40;2048,2048,SCR_WIDTH,SCR_HEIGHT&#41;;
        sceGuDepthRange&#40;65535,0&#41;;
        sceGuDepthMask&#40;GU_TRUE&#41;;
        sceGuDisable&#40;GU_DEPTH_TEST&#41;;
        sceGuDisable&#40;GU_BLEND&#41;;
        sceGuScissor&#40;0,0,SCR_WIDTH,SCR_HEIGHT&#41;;
        sceGuEnable&#40;GU_SCISSOR_TEST&#41;;
        sceGuFrontFace&#40;GU_CW&#41;;
        sceGuEnable&#40;GU_TEXTURE_2D&#41;;
        sceGuClear&#40;GU_COLOR_BUFFER_BIT&#41;;
        sceGuFinish&#40;&#41;;
        sceGuSync&#40;0,0&#41;;
        sceDisplayWaitVblankStart&#40;&#41;;
        sceGuDisplay&#40;GU_TRUE&#41;; 
        
	initialized = 1;
&#125;
Please, excuse me...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Missing a "*" in ZBUF_SIZE.
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Thanks to all, but I've resolved, I've ported the danzeff osk under graphics.c library(simply replaced the blit function with blitAlphaImageToScreen), I'll post the source soon ( now I've to finish the 1.6 of Xplora! )
Thanks you guys!
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

mm, it makes me wonder
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
Post Reply