TWINE: reduced scope and cleanup

This commit is contained in:
Martin Gerhardy 2020-10-20 23:52:15 +02:00 committed by Eugene Sandulenko
parent 3afcbb8f35
commit 859957cbee

View File

@ -402,20 +402,16 @@ Text::WordSize Text::getWordSize(const char *arg1, char *arg2) {
} }
void Text::processTextLine() { void Text::processTextLine() {
int16 var4; char *buffer = printText8Var8;
char *buffer;
char *temp;
buffer = printText8Var8;
dialCharSpace = 7; dialCharSpace = 7;
var4 = 1; int16 var4 = 1;
addLineBreakX = 0; addLineBreakX = 0;
printText8PrepareBufferVar2 = 0; printText8PrepareBufferVar2 = 0;
buf2[0] = 0; buf2[0] = 0;
for (;;) { for (;;) {
if (*buffer == 0x20) { if (*buffer == ' ') {
buffer++; buffer++;
continue; continue;
} }
@ -424,7 +420,7 @@ void Text::processTextLine() {
printText8Var8 = buffer; printText8Var8 = buffer;
WordSize wordSize = getWordSize(buffer, buf1); WordSize wordSize = getWordSize(buffer, buf1);
if (addLineBreakX + dialCharSpace + wordSize.inPixel < dialTextBoxParam2) { if (addLineBreakX + dialCharSpace + wordSize.inPixel < dialTextBoxParam2) {
temp = buffer + 1; char *temp = buffer + 1;
if (*buffer == 1) { if (*buffer == 1) {
var4 = 0; var4 = 0;
buffer = temp; buffer = temp;
@ -462,7 +458,7 @@ void Text::processTextLine() {
if (printText8PrepareBufferVar2 != 0) if (printText8PrepareBufferVar2 != 0)
printText8PrepareBufferVar2--; printText8PrepareBufferVar2--;
if (*printText8Var8 != 0 && var4 == 1) { if (*printText8Var8 != '\0' && var4 == 1) {
dialCharSpace += (dialTextBoxParam2 - addLineBreakX) / printText8PrepareBufferVar2; dialCharSpace += (dialTextBoxParam2 - addLineBreakX) / printText8PrepareBufferVar2;
printText10Var1 = dialTextBoxParam2 - addLineBreakX - dialTextBoxParam2 - addLineBreakX; // stupid... recheck printText10Var1 = dialTextBoxParam2 - addLineBreakX - dialTextBoxParam2 - addLineBreakX; // stupid... recheck
} }
@ -494,51 +490,38 @@ void Text::printText10Sub() {
} }
void Text::printText10Sub2() { void Text::printText10Sub2() {
int32 currentLetter; const int32 currentLetter = printText8Var3 - 1;
int32 currentIndex; const int32 currentIndex = currentLetter * 3;
int32 counter; int16 *ptr = pt8s4 + currentIndex;
int32 counter2; int32 counter = printText8Var3;
int16 *ptr; int32 fontColor = dialTextStartColor;
currentLetter = printText8Var3;
currentLetter--;
currentIndex = currentLetter * 3;
ptr = pt8s4 + currentIndex;
_engine->_system->delayMillis(15); _engine->_system->delayMillis(15);
counter = printText8Var3;
counter2 = dialTextStartColor;
while (--counter >= 0) { while (--counter >= 0) {
setFontColor(counter2); setFontColor(fontColor);
drawCharacterShadow(*(ptr + 1), *(ptr + 2), (uint8)*ptr, counter2); drawCharacterShadow(*(ptr + 1), *(ptr + 2), (uint8)*ptr, fontColor);
counter2 -= dialTextStepSize; fontColor -= dialTextStepSize;
if (counter2 > dialTextStopColor) if (fontColor > dialTextStopColor) {
counter2 = dialTextStopColor; fontColor = dialTextStopColor;
}
ptr -= 3; ptr -= 3;
}; };
} }
void Text::TEXT_GetLetterSize(uint8 character, int32 *pLetterWidth, int32 *pLetterHeight, uint8 *pFont) { // TEXT_GetLetterSize void Text::TEXT_GetLetterSize(uint8 character, int32 *pLetterWidth, int32 *pLetterHeight, uint8 *pFont) { // TEXT_GetLetterSize
uint8 *temp; uint8 *temp = (uint8 *)(pFont + *((int16 *)(pFont + character * 4)));
temp = (uint8 *)(pFont + *((int16 *)(pFont + character * 4)));
*pLetterWidth = *(temp); *pLetterWidth = *(temp);
*pLetterHeight = *(temp + 1); *pLetterHeight = *(temp + 1);
} }
// TODO: refactor this code // TODO: refactor this code
int Text::printText10() { int Text::printText10() {
int32 charWidth, charHeight; // a, b
if (printTextVar13 == 0) { if (printTextVar13 == 0) {
return 0; return 0;
} }
if (*(printText8Ptr2) == 0) { if (*printText8Ptr2 == '\0') {
if (printText8Var5 != 0) { if (printText8Var5 != 0) {
if (newGameVar5 != 0) { if (newGameVar5 != 0) {
printText10Sub(); printText10Sub();
@ -554,7 +537,7 @@ int Text::printText10() {
TEXT_CurrentLetterX = dialTextBoxLeft + 8; TEXT_CurrentLetterX = dialTextBoxLeft + 8;
TEXT_CurrentLetterY = dialTextBoxTop + 8; TEXT_CurrentLetterY = dialTextBoxTop + 8;
} }
if (*(printText8Var8) == 0) { if (*printText8Var8 == '\0') {
initProgressiveTextBuffer(); initProgressiveTextBuffer();
printText8Var5 = 1; printText8Var5 = 1;
return 1; return 1;
@ -563,15 +546,17 @@ int Text::printText10() {
} }
// RECHECK this later // RECHECK this later
if (*(printText8Ptr2) == 0) { if (*printText8Ptr2 == '\0') {
return 1; return 1;
} }
printText8Sub4(TEXT_CurrentLetterX, TEXT_CurrentLetterY, *printText8Ptr2); printText8Sub4(TEXT_CurrentLetterX, TEXT_CurrentLetterY, *printText8Ptr2);
printText10Sub2(); printText10Sub2();
int32 charWidth;
int32 charHeight;
TEXT_GetLetterSize(*printText8Ptr2, &charWidth, &charHeight, (uint8 *)fontPtr); TEXT_GetLetterSize(*printText8Ptr2, &charWidth, &charHeight, (uint8 *)fontPtr);
if (*(printText8Ptr2) != 0x20) { if (*printText8Ptr2 != ' ') {
TEXT_CurrentLetterX += charWidth + 2; TEXT_CurrentLetterX += charWidth + 2;
} else { } else {
if (printText10Var1 != 0) { if (printText10Var1 != 0) {
@ -584,7 +569,7 @@ int Text::printText10() {
// next character // next character
printText8Ptr2++; printText8Ptr2++;
if (*(printText8Ptr2) != 0) if (*printText8Ptr2 != '\0')
return 1; return 1;
TEXT_CurrentLetterY += 38; TEXT_CurrentLetterY += 38;
@ -603,7 +588,7 @@ int Text::printText10() {
initProgressiveTextBuffer(); initProgressiveTextBuffer();
printText8Var6 = 1; printText8Var6 = 1;
if (*(printText8Var8) == 0) { if (*printText8Var8 == '\0') {
printText8Var5 = 1; printText8Var5 = 1;
} }
@ -777,8 +762,9 @@ bool Text::getText(int32 index) { // findString
// choose right text from order index // choose right text from order index
do { do {
orderIdx = *(localOrderBuf++); orderIdx = *(localOrderBuf++);
if (orderIdx == index) if (orderIdx == index) {
break; break;
}
currIdx++; currIdx++;
} while (currIdx < numDialTextEntries); } while (currIdx < numDialTextEntries);
@ -801,8 +787,9 @@ bool Text::getText(int32 index) { // findString
void Text::copyText(const char *src, char *dst, int32 size) { // copyStringToString void Text::copyText(const char *src, char *dst, int32 size) { // copyStringToString
int32 i; int32 i;
for (i = 0; i < size; i++) for (i = 0; i < size; i++) {
*(dst++) = *(src++); *(dst++) = *(src++);
}
} }
void Text::getMenuText(int32 index, char *text, uint32 textSize) { // GetMultiText void Text::getMenuText(int32 index, char *text, uint32 textSize) { // GetMultiText