void SimonEngine::printScreenText(uint vgaSpriteId, uint color, const char *string, int16 x, int16 y, int16 width) { char convertedString[320]; char *convertedString2 = convertedString; const char *string2 = string; int16 height, talkDelay; int stringLength = strlen(string); int padding, lettersPerRow, lettersPerRowJustified; const int textHeight = (getGameType() == GType_FF) ? 15: 10; height = textHeight; lettersPerRow = width / 6; lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1; talkDelay = (stringLength + 3) / 3; if ((getGameType() == GType_SIMON1) && (getFeatures() & GF_TALKIE)) { if (_variableArray[141] == 0) _variableArray[141] = 9; _variableArray[85] = _variableArray[141] * talkDelay; } else { if (_variableArray[86] == 0) talkDelay /= 2; if (_variableArray[86] == 2) talkDelay *= 2; _variableArray[85] = talkDelay * 5; } assert(stringLength > 0); if (getGameType() == GType_FF) { uint16 b, pixels, spaces; uint16 curWdth = width; while (1) { string2 = getPixelLength(string, curWdth, pixels); if (*string2 == 0) { spaces = (width - pixels) / 12; if (spaces != 0) spaces--; while (spaces) { *convertedString2++=' '; spaces--; } strcpy(convertedString2, string); break; } while (*string2 != ' ') { byte chr = *string2; pixels -= charWidth[chr]; string2--; } spaces = (width - pixels) / 12; if (spaces != 0) spaces--; while (spaces) { *convertedString2++ = ' '; spaces--; } b = string2 - string; strncpy(convertedString2, string, b); convertedString2 += b; *convertedString2++ = '\n'; height += textHeight; y -= textHeight; if (y < 2) y = 2; curWdth = pixels; string = string2; } } else { while (stringLength > 0) { int pos = 0; if (stringLength > lettersPerRow) { int removeLastWord = 0; if (lettersPerRow > lettersPerRowJustified) { pos = lettersPerRowJustified; while (string[pos] != ' ') pos++; if (pos > lettersPerRow) removeLastWord = 1; } if (lettersPerRow <= lettersPerRowJustified || removeLastWord) { pos = lettersPerRow; while (string[pos] != ' ' && pos > 0) pos--; } height += textHeight; y -= textHeight; } else pos = stringLength; padding = (lettersPerRow - pos) % 2 ? (lettersPerRow - pos) / 2 + 1 : (lettersPerRow - pos) / 2; while (padding--) *convertedString2++ = ' '; stringLength -= pos; while (pos--) *convertedString2++ = *string++; *convertedString2++ = '\n'; string++; // skip space stringLength--; // skip space } *(convertedString2 - 1) = '\0'; } if (getGameType() == GType_SIMON1) stopAnimateSimon1(vgaSpriteId + 199); else stopAnimateSimon2(2, vgaSpriteId); if (getGameType() == GType_FF) { renderString(1, color, width, height, convertedString); } else { color = color * 3 + 192; if (getPlatform() == Common::kPlatformAmiga) renderStringAmiga(vgaSpriteId, color, width, height, convertedString); else renderString(vgaSpriteId, color, width, height, convertedString); } int b = 4; if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { if (!getBitFlag(133)) b = 3; x /= 8; if (y < 2) y = 2; } if (getGameType() == GType_SIMON1) loadSprite(b, 2, vgaSpriteId + 199, x, y, 12); else loadSprite(b, 2, vgaSpriteId, x, y, 12); }
void AGOSEngine::printScreenText(uint vgaSpriteId, uint color, const char *string, int16 x, int16 y, int16 width) { char convertedString[320]; char *convertedString2 = convertedString; int16 height, talkDelay; int stringLength = strlen(string); int padding, lettersPerRow, lettersPerRowJustified; const int textHeight = 10; height = textHeight; lettersPerRow = width / 6; lettersPerRowJustified = stringLength / (stringLength / lettersPerRow + 1) + 1; talkDelay = (stringLength + 3) / 3; if (getGameType() == GType_SIMON1 && (getFeatures() & GF_TALKIE)) { if (_variableArray[141] == 0) _variableArray[141] = 9; _variableArray[85] = _variableArray[141] * talkDelay; } else { if (_variableArray[86] == 0) talkDelay /= 2; if (_variableArray[86] == 2) talkDelay *= 2; _variableArray[85] = talkDelay * 5; } assert(stringLength > 0); while (stringLength > 0) { int pos = 0; if (stringLength > lettersPerRow) { int removeLastWord = 0; if (lettersPerRow > lettersPerRowJustified) { pos = lettersPerRowJustified; while (string[pos] != ' ') pos++; if (pos > lettersPerRow) removeLastWord = 1; } if (lettersPerRow <= lettersPerRowJustified || removeLastWord) { pos = lettersPerRow; while (string[pos] != ' ' && pos > 0) pos--; } height += textHeight; y -= textHeight; } else pos = stringLength; padding = ((lettersPerRow - pos) % 2) ? (lettersPerRow - pos) / 2 + 1 : (lettersPerRow - pos) / 2; while (padding--) *convertedString2++ = ' '; stringLength -= pos; while (pos--) *convertedString2++ = *string++; *convertedString2++ = '\n'; string++; // skip space stringLength--; // skip space } *(convertedString2 - 1) = '\0'; if (getGameType() == GType_SIMON1) stopAnimate(vgaSpriteId + 199); else stopAnimateSimon2(2, vgaSpriteId); if (getPlatform() == Common::kPlatformAmiga) { color = color * 3 + 1; renderStringAmiga(vgaSpriteId, color, width, height, convertedString); } else { color = color * 3 + 192; renderString(vgaSpriteId, color, width, height, convertedString); } uint16 windowNum = (!getBitFlag(133)) ? 3 : 4; if (getGameType() == GType_SIMON1 && (getFeatures() & GF_DEMO)) windowNum = 4; x /= 8; if (y < 2) y = 2; if (getGameType() == GType_SIMON1) { uint16 id = 199 + vgaSpriteId; animate(windowNum, id / 100, id, x, y, 12); } else { animate(windowNum, 2, vgaSpriteId, x, y, 12); } }