Black Screen

General help for the PSY-Q SDK, such as setting the SDK up, compiling correctly, linking and debugging
Post Reply
User avatar
jacen
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: March 27th, 2017, 6:46 pm
I am a: Programmer, Musician, Artist
PlayStation Model: SCPH-7501
Steam: jacen_chio
Location: Winter Haven, Florida

Black Screen

Post by jacen » March 28th, 2017, 2:14 am

Hi. I've been wanting to make a ps1 game for a while and just found this site not too long ago. After reading a little bit of the documentation, I decided to give it a try. I'm trying to write a small program that displays a purple triangle over a bluish background using libgpu, but whenever I compile and try to run it I just get a black screen.

Being new to this, and new to C in general (being primarily a C# programmer, with a little C++), I'm sure it's some dumb obvious mistake. But I just can't figure it out.

Here's my code:

Code: Select all

#include<sys/types.h>
#include<libgte.h>
#include<libgpu.h>
#include<libetc.h>

#define x_res 320 /* Screen Width */
#define y_res 240 /* Screen Height */

DRAWENV draw[2];
DISPENV disp[2];
RECT clearRect[2];
int dispId = 0;

POLY_F3 tri;

/* Function Declarations */
void InitDispDrawEnvs();
void RenderAndSwap(); /* Handles rendering and swapping buffers */

int main()
{
    InitDispDrawEnvs();

    SetPolyF3(&tri);
    setRGB0(&tri, 200, 0, 255);
    setXY3(&tri, (x_res / 2), (y_res / 2) - 15, (x_res / 2) + 15, (y_res / 2) + 15, (x_res / 2) - 15, (y_res / 2) + 15);

	while(1) /* Main Loop */
	{
        RenderAndSwap();
	}

	return 0;
}

void InitDispDrawEnvs()
{
    SetDefDrawEnv(&draw[0], 0, y_res, x_res, y_res); /* Sets the drawing env */
    SetDefDrawEnv(&draw[1], 0, 0, x_res, y_res);
    SetDefDispEnv(&disp[0], 0, 0, x_res, y_res);     /* Sets the display env */
    SetDefDispEnv(&disp[1], 0, y_res, x_res, y_res);
    PutDrawEnv(&draw[0]);
    PutDispEnv(&disp[0]);

    setRECT(&clearRect[0], 0, y_res, x_res, y_res);
    setRECT(&clearRect[1], 0, 0, x_res, y_res);
}

void RenderAndSwap()
{
    /* Clear only the drawing enviornment */
    ClearImage(&clearRect[dispId], 75, 75, 150);

    /* Draw Primitives */
    DrawPrim(&tri);

    /* Swap the draw and disp envs */
        VSync(0);
        dispId = (dispId + 1) % 2;
        PutDrawEnv(&draw[dispId]);
        PutDispEnv(&disp[dispId]);
}
Any help would be greatly appreciated. Thank you.

User avatar
Shadow
Admin / PSXDEV
Admin / PSXDEV
Posts: 2262
Joined: December 31st, 2012, 5:37 pm
PlayStation Model: H2000/5502

Re: Black Screen

Post by Shadow » March 28th, 2017, 8:53 am

You haven't setup the GPU. No wonder you're getting nothing on screen :P
Take a look at some example code: http://www.psxdev.net/help/psyq_hello_world.html
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.

PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.

User avatar
jacen
What is PSXDEV?
What is PSXDEV?
Posts: 2
Joined: March 27th, 2017, 6:46 pm
I am a: Programmer, Musician, Artist
PlayStation Model: SCPH-7501
Steam: jacen_chio
Location: Winter Haven, Florida

Re: Black Screen

Post by jacen » March 28th, 2017, 2:53 pm

Oh, ha. Of course I overlooked something so important. I got it working now, thanks for the help. :lol:

I will add for the sake of anyone else who runs into this issue, that the helloworld example uses libgs, so I looked around for the relevant libgpu functions. What I found is that I was missing a call to "ResetGraph(0);" to initialize the drawing engine and "SetDispMask(1);" to allow the image to be displayed on the screen. Once I added those to my initialization code, it started working.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest