diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/cruise/font.cpp | 200 | ||||
-rw-r--r-- | engines/cruise/font.h | 2 | ||||
-rw-r--r-- | engines/cruise/gfxModule.cpp | 30 | ||||
-rw-r--r-- | engines/cruise/gfxModule.h | 4 | ||||
-rw-r--r-- | engines/cruise/mainDraw.cpp | 21 | ||||
-rw-r--r-- | engines/cruise/mainDraw.h | 2 |
6 files changed, 46 insertions, 213 deletions
diff --git a/engines/cruise/font.cpp b/engines/cruise/font.cpp index e60d22e457..6d87d0ef6f 100644 --- a/engines/cruise/font.cpp +++ b/engines/cruise/font.cpp @@ -28,6 +28,7 @@ #include "common/util.h" #include "cruise/cruise_main.h" +#include "cruise/mouse.h" #include "cruise/staticres.h" namespace Cruise { @@ -200,15 +201,13 @@ void flipGen(void *var, int32 length) { } } -void renderWord(const uint8 *fontPtr_Data, uint8 *outBufferPtr, - int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, - int32 stringRenderBufferSize, int32 width, int32 charWidth) { +void renderWord(const uint8 *fontPtr_Data, uint8 *outBufferPtr, int xOffset, int yOffset, + int32 height, int32 param4, int32 stringRenderBufferSize, int32 width, int32 charWidth) { int i; int j; const uint8 *fontPtr_Data2 = fontPtr_Data + height * 2; - outBufferPtr += heightOff * width * 2; // param2 = height , param6 = width - outBufferPtr += drawPosPixel_X; // param1 = drawPosPixel_X + outBufferPtr += yOffset * width * 2 + xOffset; for (i = 0; i < height; i++) { // y++ uint16 bitSet1 = READ_BE_UINT16(fontPtr_Data); @@ -218,7 +217,7 @@ void renderWord(const uint8 *fontPtr_Data, uint8 *outBufferPtr, fontPtr_Data2 += sizeof(uint16); for (j = 0; j < charWidth; j++) { - *outBufferPtr = ((bitSet1 >> 15) & 1) | ((bitSet2 >>14) & 2); + *outBufferPtr = ((bitSet1 >> 15) & 1) | ((bitSet2 >> 14) & 2); outBufferPtr++; bitSet1 <<= 1; @@ -279,188 +278,17 @@ int32 prepareWordRender(int32 inRightBorder_X, int16 wordSpacingWidth, return counter; } -void drawString(int32 x, int32 y, const char *string, uint8 *buffer, uint8 color, - int32 inRightBorder_X) { - const FontInfo *fontPtr; - const FontEntry *fontPtr_Desc; - const uint8 *fontPtr_Data; - int16 wordSpacingWidth; // var1 - int16 wordSpacingHeight; // var2 - int32 rightBorder_X; // param2 - int32 lineHeight; // fontProc1result - int32 numLines; - int32 stringHeight; - int32 stringFinished; - int32 stringWidth; // var_1C - int32 stringRenderBufferSize; - int32 useDynamicBuffer; - uint8 *currentStrRenderBuffer; - // int32 var_8; // don't need that on - int32 heightOffset; // var_12 - int32 renderBufferSize; // var_1E - int needFlip; - - if (!buffer || !string) - return; - - if (fontFileIndex != -1) { - fontPtr = (const FontInfo *)filesDatabase[fontFileIndex].subData.ptr; - - if (!fontPtr) { - fontPtr = (const FontInfo *)_systemFNT; - } - } else { - fontPtr = (const FontInfo *)_systemFNT; - } +void drawString(int32 x, int32 y, const char *string, uint8 *buffer, uint8 fontColour, int32 rightBorder_X) { - if (!fontPtr) { - return; - } - - fontPtr_Desc = (const FontEntry *)((const uint8 *)fontPtr + sizeof(FontInfo)); - fontPtr_Data = (const uint8 *)fontPtr + FROM_LE_32(fontPtr->offset); + // Get the rendered text to display + gfxEntryStruct *s = renderText(rightBorder_X, string); - lineHeight = getLineHeight(FROM_LE_16(fontPtr->numChars), fontPtr_Desc); - - wordSpacingWidth = FROM_LE_16(fontPtr->hSpacing); - wordSpacingHeight = FROM_LE_16(fontPtr->vSpacing); - - if (inRightBorder_X > 310) { - rightBorder_X = 310; - } else { - rightBorder_X = inRightBorder_X; - } - if (x + rightBorder_X > 319) { - x = 319 - rightBorder_X; - } - if (y < 0) { - y = 0; - } - if (x < 0) { - x = 0; - } - numLines = getTextLineCount(rightBorder_X, wordSpacingWidth, fontPtr_Desc, string); // ok - - if (!numLines) { - return; - } - stringHeight = ((wordSpacingHeight + lineHeight + 2) * numLines) + 1; - - if (y + stringHeight > 199) { - y = 200 - stringHeight; - } - stringFinished = 0; - stringWidth = (rightBorder_X / 16) + 2; - stringRenderBufferSize = stringWidth * stringHeight * 4; - inRightBorder_X = rightBorder_X; - - if (stringRenderBufferSize > 0x2000) { - currentStrRenderBuffer = - (uint8 *) mallocAndZero(stringRenderBufferSize); - - if (!currentStrRenderBuffer) { - return; - } - useDynamicBuffer = 1; - } else { - currentStrRenderBuffer = (uint8 *) workBuffer; - useDynamicBuffer = 0; - } - - resetRaster(currentStrRenderBuffer, stringRenderBufferSize); - - // var_8 = 0; - heightOffset = 0; - renderBufferSize = stringRenderBufferSize; + // Draw the message + drawMessage(s, x, y, rightBorder_X - x, fontColour, buffer); - do { - int spacesCount = 0; // si - char character = *(string); - short int strPixelLength; // var_16; - const char *ptrStringEnd; // var_4 //ok - int drawPosPixel_X; // di - - while (character == ' ') { - spacesCount++; - character = *(string + spacesCount); - } - - string += spacesCount; - ptrStringEnd = string + prepareWordRender(inRightBorder_X, wordSpacingWidth, &strPixelLength, fontPtr_Desc, string); //ok - - if (inRightBorder_X > strPixelLength) { - drawPosPixel_X = - (inRightBorder_X - strPixelLength) / 2; - } else { - drawPosPixel_X = 0; - } - // drawPosPixel_X = var_8; - - do { - character = *(string++); - - short int data = fontCharacterTable[(int)character]; - - if (character) { - if (character == ' ' || character == 0x7D) { - drawPosPixel_X += wordSpacingWidth + 5; - } else { - if (data) { - const FontEntry &fe = fontPtr_Desc[data]; - - renderWord((const uint8 *)fontPtr_Data + FROM_LE_32(fe.offset), - currentStrRenderBuffer, - drawPosPixel_X, - FROM_LE_16(fe.height2) - FROM_LE_16(fe.charHeight) + - lineHeight + heightOffset, - FROM_LE_16(fe.charHeight), - FROM_LE_16(fe.v1), - renderBufferSize / 2, - stringWidth * 2, - FROM_LE_16(fe.charWidth)); - - drawPosPixel_X += - wordSpacingWidth + FROM_LE_16(fe.charWidth); - } - } - } else { - stringFinished = 1; - } - - if (ptrStringEnd <= string) { - break; - } - - } while (!stringFinished); - - // var_8 = 0; - heightOffset = wordSpacingHeight + lineHeight; - - } while (!stringFinished); - - needFlip = 0; - - if (buffer == gfxModuleData.pPage00) { - if (gfxModuleData.field_1 != 0) { - needFlip = 1; - gfxModuleData_field_90(); - } - - gfxModuleData_gfxWaitVSync(); - } - - gfxModuleData_field_64((char *)currentStrRenderBuffer, stringWidth, - stringHeight, (char *)buffer, x, y, 0); - gfxModuleData_field_64((char *)currentStrRenderBuffer, stringWidth, - stringHeight, (char *)buffer, x, y, color); - - if (needFlip) { - gfxModuleData_flip(); - } - - if (useDynamicBuffer) { - free(currentStrRenderBuffer); - } + // Free the data + delete s->imagePtr; + delete s; } // calculates all necessary datas and renders text @@ -531,7 +359,7 @@ gfxEntryStruct *renderText(int inRightBorder_X, const char *string) { currentStrRenderBuffer = (uint8 *) mallocAndZero(stringRenderBufferSize); - resetRaster(currentStrRenderBuffer, stringRenderBufferSize); + resetBitmap(currentStrRenderBuffer, stringRenderBufferSize); generatedGfxEntry = (gfxEntryStruct *) malloc(sizeof(gfxEntryStruct)); generatedGfxEntry->imagePtr = currentStrRenderBuffer; diff --git a/engines/cruise/font.h b/engines/cruise/font.h index 8895214416..0a3dc14379 100644 --- a/engines/cruise/font.h +++ b/engines/cruise/font.h @@ -68,7 +68,7 @@ void renderWord(uint8 *fontPtr_Data, uint8 *outBufferPtr, int32 drawPosPixel_X, int32 heightOff, int32 height, int32 param4, int32 stringRenderBufferSize, int32 width, int32 charWidth); gfxEntryStruct *renderText(int inRightBorder_X, const char *string); -void drawString(int32 x, int32 y, const char *string, uint8 * buffer, uint8 color, +void drawString(int32 x, int32 y, const char *string, uint8 * buffer, uint8 fontColour, int32 inRightBorder_X); } // End of namespace Cruise diff --git a/engines/cruise/gfxModule.cpp b/engines/cruise/gfxModule.cpp index e46ea0da54..3671b01b0e 100644 --- a/engines/cruise/gfxModule.cpp +++ b/engines/cruise/gfxModule.cpp @@ -42,7 +42,6 @@ int palDirtyMin = 256; int palDirtyMax = -1; gfxModuleDataStruct gfxModuleData = { - 0, // field_1 0, // use Tandy 0, // use EGA 1, // use VGA @@ -193,25 +192,26 @@ void gfxModuleData_convertOldPalColor(uint16 oldColor, uint8* pOutput) { *(pOutput++) = B; } -void gfxModuleData_field_90(void) { -} - void gfxModuleData_gfxWaitVSync(void) { } void gfxModuleData_flip(void) { } -void gfxModuleData_field_64(char *sourceBuffer, int width, int height, char *dest, int x, int y, int color) { - int i; - int j; +void gfxCopyRect(const byte *sourceBuffer, int width, int height, byte *dest, int x, int y, int colour) { + int xp, yp; + + for (yp = 0; yp < height; ++yp) { + const uint8 *srcP = &sourceBuffer[yp * width]; + uint8 *destP = &dest[(y + yp) * 320 + x]; - x = 0; - y = 0; + for (xp = 0; xp < width; ++xp, ++srcP, ++destP) { + uint8 v = *srcP; + int xDest = x + xp; + int yDest = y + yp; - for (i = 0; i < height; i++) { - for (j = 0; j < width; j++) { - dest[(y + i) * 320 / 4 + x + j] = sourceBuffer[i * width + j]; + if ((v != 0) && (xDest >= 0) && (yDest >= 0) && (xDest < 320) && (yDest < 200)) + *destP = (v == 1) ? 0 : colour; } } } @@ -271,4 +271,10 @@ void drawSolidBox(int32 x1, int32 y1, int32 x2, int32 y2, uint8 colour) { } } +void resetBitmap(uint8 *dataPtr, int32 dataSize) { + memset(dataPtr, 0, dataSize); +} + + + } // End of namespace Cruise diff --git a/engines/cruise/gfxModule.h b/engines/cruise/gfxModule.h index 7a48d4c2fc..d0aab71fc8 100644 --- a/engines/cruise/gfxModule.h +++ b/engines/cruise/gfxModule.h @@ -29,7 +29,6 @@ namespace Cruise { struct gfxModuleDataStruct { - int field_1; int useTandy; int useEGA; int useVGA; @@ -53,7 +52,7 @@ void gfxModuleData_setPalColor(int idx, int r, int g, int b); void gfxModuleData_field_90(void); void gfxModuleData_gfxWaitVSync(void); void gfxModuleData_flip(void); -void gfxModuleData_field_64(char *sourceBuffer, int width, int height, char *dest, int x, int y, int color); +void gfxCopyRect(const byte *sourceBuffer, int width, int height, byte *dest, int x, int y, int colour); void gfxModuleData_gfxCopyScreen(char *sourcePtr, char *destPtr); void convertGfxFromMode4(uint8 *sourcePtr, int width, int height, uint8 *destPtr); void convertGfxFromMode5(uint8 *sourcePtr, int width, int height, uint8 *destPtr); @@ -63,6 +62,7 @@ void gfxModuleData_convertOldPalColor(uint16 oldColor, uint8* pOutput); void gfxModuleData_setPal256(uint8 * ptr); void flip(void); void drawSolidBox(int32 x1, int32 y1, int32 x2, int32 y2, uint8 colour); +void resetBitmap(uint8 *dataPtr, int32 dataSize); } // End of namespace Cruise diff --git a/engines/cruise/mainDraw.cpp b/engines/cruise/mainDraw.cpp index a42800994a..36a90c8d4c 100644 --- a/engines/cruise/mainDraw.cpp +++ b/engines/cruise/mainDraw.cpp @@ -1132,17 +1132,15 @@ void mainDrawPolygons(int fileIndex, cellStruct *plWork, int X, int scale, int Y buildPolyModel(newX, newY, newScale, (char*)polygonMask, destBuffer, newFrame); } -void drawMessage(gfxEntryStruct *pGfxPtr, int globalX, int globalY, int width, int newColor, uint8 *ouputPtr) { +void drawMessage(const gfxEntryStruct *pGfxPtr, int globalX, int globalY, int width, int newColor, uint8 *ouputPtr) { // this is used for font only if (pGfxPtr) { uint8 *initialOuput; uint8 *output; - int i; - int j; - int x; - int y; - uint8 *ptr = pGfxPtr->imagePtr; + int xp, yp; + int x, y; + const uint8 *ptr = pGfxPtr->imagePtr; int height = pGfxPtr->height; if (width > 310) @@ -1160,13 +1158,12 @@ void drawMessage(gfxEntryStruct *pGfxPtr, int globalX, int globalY, int width, i initialOuput = ouputPtr + (globalY * 320) + globalX; - y = globalY; - x = globalX; + for (yp = 0; yp < height; yp++) { + output = initialOuput + 320 * yp; + y = globalY + yp; - for (i = 0; i < height; i++) { - output = initialOuput + 320 * i; - - for (j = 0; j < pGfxPtr->width; j++) { + for (xp = 0; xp < pGfxPtr->width; xp++) { + x = globalX + xp; uint8 color = *(ptr++); if (color) { diff --git a/engines/cruise/mainDraw.h b/engines/cruise/mainDraw.h index 0f51565129..98ba47c842 100644 --- a/engines/cruise/mainDraw.h +++ b/engines/cruise/mainDraw.h @@ -45,6 +45,8 @@ void getPolySize(int positionX, int positionY, int scale, int sizeTable[4], unsi bool findPoly(char* dataPtr, int x, int y, int zoom, int mouseX, int mouseY); unsigned char *drawPolyMode2(unsigned char *dataPointer, int linesToDraw); void calcRGB(uint8* pColorSrc, uint8* pColorDst, int* offsetTable); +void drawMessage(const gfxEntryStruct *pGfxPtr, int globalX, int globalY, int width, int newColor, uint8 *ouputPtr); + } // End of namespace Cruise #endif |