Psy-Q Video Init and Automatic Video Control (AUTO PAL/NTSC)

Graphic based area of development (Graphics Processing Unit), including the Geometry Transform Engine (GTE), TIM, STR (MDEC), etc.
Post Reply
User avatar
t0rxe
C Programming Expert
C Programming Expert
Posts: 140
Joined: December 19th, 2012, 8:08 pm
IRC: t0rxe
Motto: /\OX[]
PlayStation Model: SCPH-5502
Location: Australia

Psy-Q Video Init and Automatic Video Control (AUTO PAL/NTSC)

Post by t0rxe » June 3rd, 2013, 6:55 pm

Code: Select all

void initGraphics()
{
   int SCREEN_WIDTH, SCREEN_HEIGHT;

   // puts display mask into the status specified by the mask (0 not displayed, 1 displayed)
   SetDispMask(1);
   
   // resets the graphic system (0 full reset, 1 cancels the current drawing and flushes the command buffer, 3 initialises the drawing engine while preserving the current display environment)
   ResetGraph(0);

   // clear all VRAM contents
   //clearVRAM();

   // automatic video mode control
   if (*(char *)0xbfc7ff52=='E')  // SCEE string address
   {
     // PAL MODE
     SCREEN_WIDTH = 320;
     SCREEN_HEIGHT = 256;
     if (DEBUG) printf("Setting the PlayStation Video Mode to (PAL %dx%d)\n",SCREEN_WIDTH,SCREEN_HEIGHT,")");
     SetVideoMode(1);
     if (DEBUG_DISPLAY) printf("Video Mode is (%d)\n",GetVideoMode());
   }
   else
   {
     // NTSC MODE
     SCREEN_WIDTH = 320;
     SCREEN_HEIGHT = 240;
     if (DEBUG) printf("Setting the PlayStation Video Mode to (NTSC %dx%d)\n",SCREEN_WIDTH,SCREEN_HEIGHT,")");
     SetVideoMode(0);
     if (DEBUG_DISPLAY) printf("Video Mode is (%d)\n",GetVideoMode());
   }

   // set the graphics mode resolutions
   GsInitGraph(SCREEN_WIDTH, SCREEN_HEIGHT, GsNONINTER|GsOFSGPU, 1, 0);

   // set the top left coordinates of the two buffers in video memory
   GsDefDispBuff(0, 0, 0, SCREEN_HEIGHT);

   // init the ordering tables
   WorldOrderingTable[0].length = OT_LENGTH;
   WorldOrderingTable[1].length = OT_LENGTH;

   WorldOrderingTable[0].org = OrderingTable[0];
   WorldOrderingTable[1].org = OrderingTable[1];
   
   GsClearOt(0,0,&WorldOrderingTable[0]);
   GsClearOt(0,0,&WorldOrderingTable[1]);

   printf("Graphics Initialised!\n");
}
If you want to clear the VRAM, uncomment the 'clearVRAM();' function and make a function with the code seen here:
viewtopic.php?f=51&t=316
"Nostalgia isn't a big enough word to describe the PlayStation from my eyes"

DEBRO
Curious PSXDEV User
Curious PSXDEV User
Posts: 17
Joined: February 5th, 2013, 3:08 am

Re: Psy-Q Video Init and Automatic Video Control (AUTO PAL/N

Post by DEBRO » June 5th, 2013, 7:24 am

Nice...thanks for the post.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests