/* * "ESCGBOXO.C" * * Part of The Escotia Playstation Library * * Author: ScoTT Campbell * Date: 18/9/98 * */ #include "..\headers\escgboxo.h" /******************************/ /* Start of EsGBOXF functions */ /******************************/ void InitGBoxO(EsGBOXO* boxPtr, int xPosition, int yPosition, int width, int height) { boxPtr->x = xPosition; boxPtr->y = yPosition; boxPtr->w = width; boxPtr->h = height; boxPtr->attribute = 0; boxPtr->r0 = boxPtr->g0 = boxPtr->b0 = 0; boxPtr->r1 = boxPtr->g1 = boxPtr->b1 = 0; boxPtr->r2 = boxPtr->g2 = boxPtr->b2 = 255; boxPtr->r3 = boxPtr->g3 = boxPtr->b3 = 255; }/* InitGBoxO */ void SetGBoxOPosition(EsGBOXO* boxPtr, int xPosition, int yPosition) { boxPtr->x = xPosition; boxPtr->y = yPosition; }/* SetGBoxOPosition */ void SetGBoxOXPosition(EsGBOXO* boxPtr, int xPosition) { boxPtr->x = xPosition; }/* SetGBoxOXPosition */ void SetGBxOYPosition(EsGBOXO* boxPtr, int yPosition) { boxPtr->y = yPosition; }/* SetGBoxOYPosition */ void MoveGBoxO(EsGBOXO* boxPtr, int xAmount, int yAmount) { boxPtr->x += xAmount; boxPtr->y += yAmount; }/* MoveGBoxO */ void SetGBoxOSize(EsGBOXO* boxPtr, unsigned short int width, unsigned short int height) { boxPtr->w = width; boxPtr->h = height; }/* SetGBoxOSize */ void SetGBoxOWidth(EsGBOXO* boxPtr, unsigned short int width) { boxPtr->w = width; }/* SetGBoxOWidth */ int AdjustGBoxOHeight(EsGBOXO* boxPtr, int amount) { if((amount < 0) && (abs(amount) > boxPtr->h)) { boxPtr->h = 0; return 1; } else { boxPtr->h += amount; return 0; } }/* AdjustGBoxOHeight */ int AdjustGBoxOWidth(EsGBOXO* boxPtr, int amount) { if((amount < 0) && (abs(amount) > boxPtr->w)) { boxPtr->w = 0; return 1; } else { boxPtr->w += amount; return 0; } } void SetGBoxOAttributes(EsGBOXO* boxPtr, unsigned long int attributes) { /* Clear top 4 bits ready to set*/ boxPtr->attribute &= 0x0FFFFFFF; /* Set the bits we want */ boxPtr->attribute |= attributes; } void SetGBoxOColourVectors(EsGBOXO* boxPtr, CVECTOR* topLeftVectorPtr, CVECTOR* bottomLeftVectorPtr, CVECTOR* topRightVectorPtr, CVECTOR* bottomRightVectorPtr) { boxPtr->r0 = topLeftVectorPtr->r; boxPtr->g0 = topLeftVectorPtr->g; boxPtr->b0 = topLeftVectorPtr->b; boxPtr->r1 = bottomLeftVectorPtr->r; boxPtr->g1 = bottomLeftVectorPtr->g; boxPtr->b1 = bottomLeftVectorPtr->b; boxPtr->r2 = topRightVectorPtr->r; boxPtr->g2 = topRightVectorPtr->g; boxPtr->b2 = topRightVectorPtr->b; boxPtr->r3 = bottomRightVectorPtr->r; boxPtr->g3 = bottomRightVectorPtr->g; boxPtr->b3 = bottomRightVectorPtr->b; } void SetGBoxOTopLeftColourVector(EsGBOXO* boxPtr, CVECTOR* colourVectorPtr) { boxPtr->r0 = colourVectorPtr->r; boxPtr->g0 = colourVectorPtr->g; boxPtr->b0 = colourVectorPtr->b; } void SetGBoxOTopRightColourVector(EsGBOXO* boxPtr, CVECTOR* colourVectorPtr) { boxPtr->r2 = colourVectorPtr->r; boxPtr->g2 = colourVectorPtr->g; boxPtr->b2 = colourVectorPtr->b; } void SetGBoxOBottomLeftColourVector(EsGBOXO* boxPtr, CVECTOR* colourVectorPtr) { boxPtr->r1 = colourVectorPtr->r; boxPtr->g1 = colourVectorPtr->g; boxPtr->b1 = colourVectorPtr->b; } void SetGBoxOBottomRightColourVector(EsGBOXO* boxPtr, CVECTOR* colourVectorPtr) { boxPtr->r3 = colourVectorPtr->r; boxPtr->g3 = colourVectorPtr->g; boxPtr->b3 = colourVectorPtr->b; } void SetGBoxOColours(EsGBOXO* boxPtr, unsigned char r0, unsigned char g0, unsigned char b0, unsigned char r1, unsigned char g1, unsigned char b1, unsigned char r2, unsigned char g2, unsigned char b2, unsigned char r3, unsigned char g3, unsigned char b3) { boxPtr->r0 = r0; boxPtr->g0 = g0; boxPtr->b0 = b0; boxPtr->r1 = r1; boxPtr->g1 = g1; boxPtr->b1 = b1; boxPtr->r2 = r2; boxPtr->g2 = g2; boxPtr->b2 = b2; boxPtr->r3 = r3; boxPtr->g3 = g3; boxPtr->b3 = b3; } void SetGBoxOTopLeftColour(EsGBOXO* boxPtr, unsigned char r, unsigned char g, unsigned char b) { boxPtr->r0 = r; boxPtr->g0 = g; boxPtr->b0 = b; } void SetGBoxOTopRightColour(EsGBOXO* boxPtr, unsigned char r, unsigned char g, unsigned char b) { boxPtr->r2 = r; boxPtr->g2 = g; boxPtr->b2 = b; } void SetGBoxOBottomLeftColour(EsGBOXO* boxPtr, unsigned char r, unsigned char g, unsigned char b) { boxPtr->r1 = r; boxPtr->g1 = g; boxPtr->b1 = b; } void SetGBoxOBottomRightColour(EsGBOXO* boxPtr, unsigned char r, unsigned char g, unsigned char b) { boxPtr->r3 = r; boxPtr->g3 = g; boxPtr->b3 = b; } void EsSortGBoxOutline(EsGBOXO* boxPtr, GsOT* otPtr, unsigned short int pri) /* Creates the GBOXO using GLINEs */ { GsGLINE line; /* Box's x co-ordinates */ int leftX = boxPtr->x; int rightX = leftX + (boxPtr->w - 1); /* Box's y co-ordinates */ int topY = boxPtr->y; int bottomY = topY + (boxPtr->h - 1); /* Check that something is to be drawn */ if((boxPtr->h) && (boxPtr->w)) { /* Draw the box */ line.attribute = boxPtr->attribute; /* Top line of box */ line.x0 = leftX; line.x1 = rightX; line.y0 = line.y1 = topY; line.r0 = boxPtr->r0; line.g0 = boxPtr->g0; line.b0 = boxPtr->b0; line.r1 = boxPtr->r2; line.g1 = boxPtr->g2; line.b1 = boxPtr->b2; GsSortGLine(&line, otPtr, pri); /* Right-hand line of box */ line.x0 = rightX; line.y0 = bottomY; line.r0 = boxPtr->r2; line.g0 = boxPtr->g2; line.b0 = boxPtr->b2; GsSortGLine(&line, otPtr, pri); /* Bottom line of box */ line.x1 = leftX; line.y1 = bottomY; line.r1 = boxPtr->r1; line.g1 = boxPtr->g1; line.b1 = boxPtr->b1; GsSortGLine(&line, otPtr, pri); /* Left-hand line of box */ line.x0 = leftX; line.y0 = topY; line.r0 = boxPtr->r0; line.g0 = boxPtr->g0; line.b0 = boxPtr->b0; GsSortGLine(&line, otPtr, pri); } } /****************************/ /* End of EsGBOXF functions */ /****************************/