#include "Main.h" #include const u_long CUBE_DATA = 0x80090000 ; const u_long TEX_DATA = 0X800A0000 ; const long CUBE_X = 0 ; const long CUBE_Y = 0 ; const long CUBE_Z = 250 ; // long x = 0, y=-500, z = 800 ; int LoadTexture(long addr) ; main() { long l1, l2 ; //l1=open("cdrom:\\data\\cube.tmd",O_RDONLY); // hTim=open("e:\\psxprojects\\test3d\\data\\tex.tim",O_RDONLY); // Connect to ars cg_fsinit(); l1 = cg_bload( "e:\\psxprojects\\test3d\\data\\cube.tmd", CUBE_DATA ) ; // long lTex = cg_bload( "e:\\psxprojects\\test3d\\data\\tex.tim", TEX_DATA ); // Connect to ars cg_fsinit(); l1 = cg_bload( "e:\\psxprojects\\test3d\\data\\cube.tmd", CUBE_DATA ) ; // set up print-to-screen font, the parameters are where the font is // loaded into the frame buffer FntLoad(960, 256); //specify where to write on the PSX screen FntOpen(-140, -120, 252, 222, 0, 512); // FntOpen(-96, -96, 192, 192, 0, 512); // Initialise The Graphics System to PAL as opposed to NTSC SetVideoMode(MODE_PAL); // Set the Actual Size of the Video memory GsInitGraph(SCREEN_WIDTH, SCREEN_HEIGHT, GsINTER|GsOFSGPU, 1, 0); // Set the Top Left Coordinates Of The Two Buffers in video memory GsDefDispBuff(0, 0, 0, SCREEN_HEIGHT); // Initialise the 3D Graphics... GsInit3D(); CLight light1( 0 ) , light2( 1 ) ; CView theView ; CWorld theWorld ; CProjection projection(0, 0, 0 ), projectionCopy( 0,0,-500 ) ; CCord reference ( 0, 0, 0 ) ; CCube theCube ; CAccellPad thePad ; theView.projection( projection ) ; theView.reference ( reference ) ; theView.distance( 250 ) ; theView.twist( 0 ) ; theView.parent( WORLD ) ; theView.set( ) ; light1.position( CCord( -1, -1, -1 ) ) ; light2.position( CCord( 1, 1, 1 ) ) ; //we don't need to set the light colors, as it defaults to white. light1.on( ) ; light2.on( ) ; CLight::ambient( 0,0,0 ) ; CLight::normal( ) ; //no fogging ; //initialise the coordinates of the objects theCube.initCords( ) ; theCube.model( CUBE_DATA ) ; theCube.position( CUBE_X, CUBE_Y, CUBE_Z ) ; LoadTexture( TEX_DATA ) ; theWorld.init( ) ; theWorld+=&theCube ; while( 1 ) { // long x = 0, y=-500, z = 800 ; u_long padStatus = (u_long)thePad ;//thePad.getState( ) ; if ( (padStatus & PADselect) && (padStatus & PADstart ) ) { //cg_shutdown(); return 0; } if ( padStatus & PADstart ) { projection = projectionCopy ; theCube.initCords( ) ; theCube.position( CUBE_X, CUBE_Y, CUBE_Z ) ; } theCube.servicePad( thePad ) ; projection.servicePad( thePad ) ; projection.dump( ) ; theView.projection( projection ) ; theView.set( ) ; theWorld.draw( ) ; } } // load up from conventional memeory into video memory int LoadTexture(long addr) { RECT rect; GsIMAGE tim1; // get tim info/header, again a little bit of majic is needd the pointer // is incremented past the first 4 positions to get to this! GsGetTimInfo((u_long *)(addr+4),&tim1); // set the rect struct to contain the images x and y offset, width and height rect.x=tim1.px; rect.y=tim1.py; rect.w=tim1.pw; rect.h=tim1.ph; //load image from main memory to video memory LoadImage(&rect,tim1.pixel); // if image has clut we need to load it too, //pmode =8 for 4 bit and 9 for 8 bit colour if((tim1.pmode>>3)&0x01) { // set the rect struct to contain the clut's x and y offset, width and height rect.x=tim1.cx; rect.y=tim1.cy; rect.w=tim1.cw; rect.h=tim1.ch; // load the clut into video memeory LoadImage(&rect,tim1.clut); } DrawSync(0); return(0); }