Page 1 of 1

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

Posted: June 3rd, 2013, 6:55 pm
by t0rxe

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:
http://www.psxdev.net/forum/viewtopic.php?f=51&t=316

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

Posted: June 5th, 2013, 7:24 am
by DEBRO
Nice...thanks for the post.