// // Main.h - Miscellanious Yaroze functions // // Andrew Murray - Max Studios - 2001 // // // ------------------defines #define SCREEN_WIDTH 640 // holds the screen width #define SCREEN_HEIGHT 512 // holds the screen height #define OT_LENGTH 10 // ordering table length #define NUM_POLYS 1000 // estimated amount of POLYS in scene used to set PACKET work area #define TECHWALL_ADDR (0x80090000) // location of tech wall texture for mapping on the cube #define CUBE_ADDR (0x80094608) // address to use to build simple cube for the arena #define setRect(r,_x,_y,_w,_h) (r)->x = (_x), (r)->y = (_y), (r)->w = (_w), (r)->h = (_h) // macro used to set up a RECT // ------------------globals int frameNo = 0; int PLAYING = 1; GsOT WorldOT[2]; // ordering table headers GsOT_TAG WorldTags[2][1<>3)&0x01) // CLUT flag set so load it { setRect(&rect,imageInfo.cx,imageInfo.cy,imageInfo.cw,imageInfo.ch); // set up rect for CLUT load to VRAM LoadImage( &rect, imageInfo.clut ); // load CLUT to rect in VRAM DrawSync( 0 ); // wait for drawing commands to finish if ( imageInfo.cx % 16 ) printf("Clut not 16 byte aligned\n"); // clut not aligned to a 16x boundry temp = ( imageInfo.cy * 64 ) + ( imageInfo.cx / 16 ); if ( temp > 65535 ) printf("Clut address to big\n"); // address to big for u_short texture->cba = temp; } else // No CLUT to load. { if ((imageInfo.pmode & 7) <= 1) // 4-bit or 8-bit so why no clut??? printf( "Missing clut?\n" ); texture->cba = 0; } // Values for the second parameter of GetTPage ('abr' -- Semi-transparency rate)... // 0: 0.5 x Back + 0.5 x poly // 1: 1.0 x Back + 1.0 x poly // 2: 1.0 x Back - 1.0 x poly // 3: 1.0 x Back + 0.25 x poly texture->tsb = GetTPage(imageInfo.pmode,1,imageInfo.px,imageInfo.py); // Bits 0-3 of imageInfo.pmode: Pixel mode (Bit length) (Also bits 0-3 of Flag in TIM data) // 0: 4-bit CLUT // 1: 8-bit CLUT // 2: 15-bit direct // 3: 24-bit direct // 4: Mixed // (these are actual values and not bit numbers) switch( (imageInfo.pmode & 7) ) { case 0: texture->xScale = 4; // 4-bit break; case 1: texture->xScale = 2; // 8-bit break; case 2: texture->xScale = 1; // 16-bit break; default: texture->xScale = 1; // Pixel Width compared with data width not tested for this bit depth,,,, printf( "\nimage depth not coded for (24 bit?)" ); } if ( imageInfo.pw & 1 ) // do not use odd widths for textures printf( "\nodd width" ); texture->width = imageInfo.pw * texture->xScale; // set up the correct rendering width i.e. width x scale texture->height = imageInfo.ph; // If you use these variable to assign to your prim u0, v1 etc then you can // change the size of your texture without having to recode the coordinates... texture->left = ( imageInfo.px % 64 ) * texture->xScale; texture->right = texture->left + texture->width - 1; texture->top = imageInfo.py % 256; texture->bottom = texture->top + texture->height - 1; } void InitView(GsRVIEW2 *view, // structure that holds the view details int projDist, // distance from camera to user defined position int nRZ, // this is the tilt or swivel of the camera int nVPX, int nVPY, int nVPZ, // viewpoint coordinates int nVRX, int nVRY, int nVRZ) // viewpoint look at coordinates { // camera position view->vpx = nVPX; view->vpy = nVPY; view->vpz = nVPZ; // look-at position view->vrx = nVRX; view->vry = nVRY; view->vrz = nVRZ; // camera tilt view->rz = nRZ; view->super = WORLD; GsSetProjection(projDist); // set the distance between camera and object GsSetRefView2(view); } void InitLight(GsF_LIGHT *light, // passed light structure holds light info int lightIndex, // only three lights are allowed this is either 0, 1 or 2 int nX, int nY, int nZ, // vector direction of traveling light int nRED, int nGREEN, int nBLUE) // RGB components of the light { // set light direction light->vx = nX; light->vy = nY; light->vz = nZ; // set the light colour light->r = nRED; light->g = nGREEN; light->b = nBLUE; GsSetFlatLight(lightIndex,light); // set the light in the scene }