#include "ps_graphics.hpp" #include "wstruct.hpp" #include "ps_view.hpp" #include "ps_object.hpp" //#include "3dobject.h" extern char worldGroundData[MAX_Z][MAX_X]; // We need two Ordering Table Headers, one for each buffer //GsOT othWorld[2]; /* COrderTableHeader othWorld[2]; // And we need Two Ordering Tables, one for each buffer GsOT_TAG otWorld[2][1<draw( h ) ; } } void AsPSGraphics::InitialiseLight(GsF_LIGHT *flLight, int nLight, int nX, int nY, int nZ, int nRed, int nGreen, int nBlue) { // Set the direction in which the light travels flLight->vx = nX;flLight->vy = nY; flLight->vz = nZ; // Set the colour flLight->r = nRed; flLight->g = nGreen; flLight->b = nBlue; // Activate light GsSetFlatLight(nLight, flLight); } void AsPSGraphics::DrawWorld(WorldStructType0 *theWorld, GsOT *othWorld) { MATRIX tmpls, tmplw; int nCurrentModel; int tmpz,tmpx; char c; // for (nCurrentModel = 0; nCurrentModel < theWorld->nTotalModels; nCurrentModel++) // { //GetCurrentWorldGroundData(); for (tmpz = 0; tmpz < MAX_Z; tmpz++ ){ //for (tmpz = 0; tmpz < 1; tmpz++ ){ for (tmpx = 0; tmpx < MAX_X; tmpx++ ){ //for (tmpx = 0; tmpx < 1; tmpx++ ){ c= worldGroundData[tmpz][tmpx]; if(c == '1') //if (worldGroundData[tmpz][tmpx]) //if (currentWorldGroundData[tmpz][tmpx]) { //Get the local world and screen coordinates, needed for light calculations GsGetLws(theWorld->gsObjectHandler[tmpz][tmpx].coord2, &tmplw, &tmpls); // Set the resulting light source matrix GsSetLightMatrix(&tmplw); // Set the local screen matrix for the GTE (so it works out perspective etc) GsSetLsMatrix(&tmpls); // Send Object To Ordering Table GsSortObject4( &theWorld->gsObjectHandler[tmpz][tmpx], othWorld, 2,(u_long *)getScratchAddr(0)); } } } // } } //void AsPSGraphics::Render(WorldStructType0 *theWorld,CView *viewer) void AsPSGraphics::Render(CView *viewer) { // This variable keeps track of the current buffer for double buffering int currentBuffer; //get the current buffer currentBuffer=GsGetActiveBuff(); // Set the viewing system //GsSetRefView2(&view); viewer->set(); // set address for GPU scratchpad area GsSetWorkBase((PACKET*)out_packet[currentBuffer]); // clear the ordering table GsClearOt(0, 0, &othWorld[currentBuffer]); // Draw the world //DrawWorld(theWorld, &othWorld[currentBuffer]); draw(othWorld[currentBuffer]); //print your elegant message //FntPrint(); //FntPrint(streams[currentStream],"Jeff woz ere on Playstation!"); //FntPrint("Jeff woz ere on Playstation!"); // force text output to the PSX screen //FntFlush(-1); // wait for end of drawing DrawSync(0); // wait for V_BLANK interrupt VSync(0); // ResetGraph(1); // swap double buffers GsSwapDispBuff(); // register clear-command: clear to black GsSortClear(0, 0, 0,&othWorld[currentBuffer]); // register request to draw ordering table GsDrawOt(&othWorld[currentBuffer]); } void AsPSGraphics::DrawList() { draw(othWorld[currentBuffer]); } GsOT *AsPSGraphics::GetOT() { return(&othWorld[currentBuffer]); } int AsPSGraphics::GetCurrentBuffer() { return(currentBuffer); } void AsPSGraphics::Render1(CView *viewer) { //get the current buffer currentBuffer=GsGetActiveBuff(); // Set the viewing system //GsSetRefView2(&view); viewer->set(); // set address for GPU scratchpad area GsSetWorkBase((PACKET*)out_packet[currentBuffer]); // clear the ordering table GsClearOt(0, 0, &othWorld[currentBuffer]); } void AsPSGraphics::Render2() { // wait for end of drawing DrawSync(0); // wait for V_BLANK interrupt VSync(0); // ResetGraph(1); // swap double buffers GsSwapDispBuff(); // register clear-command: clear to black GsSortClear(0, 0, 0,&othWorld[currentBuffer]); // register request to draw ordering table GsDrawOt(&othWorld[currentBuffer]); }