/* * "ESCBOXO.C" * * Part of The Escotia Playstation Library * * Author: ScoTT Campbell * Date: 10/9/98 * */ #include "..\headers\escboxo.h" /*****************************/ /* Start of EsBOXO functions */ /*****************************/ void InitBoxO(EsBOXO* boxPtr, short int xPosition, short int yPosition, unsigned short int width, unsigned short int height) { boxPtr->x = xPosition; boxPtr->y = yPosition; boxPtr->w = width; boxPtr->h = height; boxPtr->r0 = boxPtr->r1 = boxPtr->r2 = boxPtr->r3 = 255; boxPtr->g0 = boxPtr->g1 = boxPtr->g2 = boxPtr->g3 = 255; boxPtr->b0 = boxPtr->b1 = boxPtr->b2 = boxPtr->b3 = 255; boxPtr->attribute = 0; }/* InitBoxO */ void SetBoxOPosition(EsBOXO* boxPtr, short int xPosition, short int yPosition) { boxPtr->x = xPosition; boxPtr->y = yPosition; }/* SetBoxOPosition */ void SetBoxOXPosition(GsBOXF* boxPtr, int xPosition) { boxPtr->x = xPosition; }/* SetBoxOXPosition */ void SetBoxOYPosition(GsBOXF* boxPtr, int yPosition) { boxPtr->y = yPosition; }/* SetBoxOYPosition */ void MoveBoxO(EsBOXO* boxPtr, int xAmount, int yAmount) { boxPtr->x += xAmount; boxPtr->y += yAmount; }/* MoveBoxO */ void SetBoxOSize(EsBOXO* boxPtr, unsigned short int width, unsigned short int height) { boxPtr->w = width; boxPtr->h = height; }/* SetBoxOSize */ void SetBoxOWidth(EsBOXO* boxPtr, unsigned short int width) { boxPtr->w = width; }/* SetBoxOWidth */ void SetBoxOHeight(EsBOXO* boxPtr, unsigned short int height) { boxPtr->h = height; }/* SetBoxOHeight */ int AdjustBoxOHeight(EsBOXO* boxPtr, int amount) { if((amount < 0) && (abs(amount) > boxPtr->h)) { boxPtr->h = 0; return 1; } else { boxPtr->h += amount; return 0; } }/* AdjustBoxOHeight */ int AdjustBoxOWidth(EsBOXO* boxPtr, int amount) { if((amount < 0) && (abs(amount) > boxPtr->w)) { boxPtr->w = 0; return 1; } else { boxPtr->w += amount; return 0; } }/* AdjustBoxOWidth */ void SetBoxOColourVectors(EsBOXO* boxPtr, CVECTOR* topVectorPtr, CVECTOR* rightVectorPtr, CVECTOR* bottomVectorPtr, CVECTOR* leftVectorPtr) { boxPtr->r0 = topVectorPtr->r; boxPtr->g0 = topVectorPtr->g; boxPtr->b0 = topVectorPtr->b; boxPtr->r1 = rightVectorPtr->r; boxPtr->g1 = rightVectorPtr->g; boxPtr->b1 = rightVectorPtr->b; boxPtr->r2 = bottomVectorPtr->r; boxPtr->g2 = bottomVectorPtr->g; boxPtr->b2 = bottomVectorPtr->b; boxPtr->r3 = leftVectorPtr->r; boxPtr->g3 = leftVectorPtr->g; boxPtr->b3 = leftVectorPtr->b; }/* SetBoxOColourVectors */ void SetBoxOTopColourVector(EsBOXO* boxPtr, CVECTOR* colourVectorPtr) { boxPtr->r0 = colourVectorPtr->r; boxPtr->g0 = colourVectorPtr->g; boxPtr->b0 = colourVectorPtr->b; }/* SetBoxOTopColourVector */ void SetBoxORightColourVector(EsBOXO* boxPtr, CVECTOR* colourVectorPtr) { boxPtr->r1 = colourVectorPtr->r; boxPtr->g1 = colourVectorPtr->g; boxPtr->b1 = colourVectorPtr->b; }/* SetBoxORightColourVector */ void SetBoxOBottomColourVector(EsBOXO* boxPtr, CVECTOR* colourVectorPtr) { boxPtr->r2 = colourVectorPtr->r; boxPtr->g2 = colourVectorPtr->g; boxPtr->b2 = colourVectorPtr->b; }/* SetBoxOBottomColourVector */ void SetBoxOLeftColourVector(EsBOXO* boxPtr, CVECTOR* colourVectorPtr) { boxPtr->r3 = colourVectorPtr->r; boxPtr->g3 = colourVectorPtr->g; boxPtr->b3 = colourVectorPtr->b; }/* SetBoxOLeftColourVector */ void SetBoxOColours(EsBOXO* 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; }/* SetBoxOColours */ void SetBoxOTopColour(EsBOXO* boxPtr, unsigned char r, unsigned char g, unsigned char b) { boxPtr->r0 = r; boxPtr->g0 = g; boxPtr->b0 = b; }/* SetBoxOTopColour */ void SetBoxORightColour(EsBOXO* boxPtr, unsigned char r, unsigned char g, unsigned char b) { boxPtr->r1 = r; boxPtr->g1 = g; boxPtr->b1 = b; }/* SetBoxORightColour */ void SetBoxOBottomColour(EsBOXO* boxPtr, unsigned char r, unsigned char g, unsigned char b) { boxPtr->r2 = r; boxPtr->g2 = g; boxPtr->b2 = b; }/* SetBoxOBottomColour */ void SetBoxOLeftColour(EsBOXO* boxPtr, unsigned char r, unsigned char g, unsigned char b) { boxPtr->r3 = r; boxPtr->g3 = g; boxPtr->b3 = b; }/* SetBoxOLeftColour */ void SetBoxOAttributes(EsBOXO* boxPtr, unsigned long int attributes) { /* Clear the top 4 bits */ boxPtr->attribute &= 0x0FFFFFFF; /* Set the bits we want */ boxPtr->attribute |= attributes; }/* SetBoxOAttributes */ void EsSortBoxOutline(EsBOXO* boxPtr, GsOT* otPtr, unsigned short int pri) { GsLINE 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.r = boxPtr->r0; line.g = boxPtr->g0; line.b = boxPtr->b0; line.x0 = leftX; line.x1 = rightX; line.y0 = line.y1 = topY; GsSortLine(&line, otPtr, pri); /* Bottom line of box */ line.r = boxPtr->r2; line.g = boxPtr->g2; line.b = boxPtr->b2; line.y0 = line.y1 = bottomY; GsSortLine(&line, otPtr, pri); /* Right-hand line of box */ line.r = boxPtr->r1; line.g = boxPtr->g1; line.b = boxPtr->b1; line.x0 = rightX; line.y0 = topY; GsSortLine(&line, otPtr, pri); /* Left-hand line of box */ line.r = boxPtr->r3; line.g = boxPtr->g3; line.b = boxPtr->b3; line.x0 = line.x1 = leftX; GsSortLine(&line, otPtr, pri); } }/* EsSortBoxOutline */ /***************************/ /* End of EsBOXO functions */ /***************************/