void AGOSEngine::justifyOutPut(byte chr) { if (chr == 12) { _numLettersToPrint = 0; _printCharCurPos = 0; _printCharPixelCount = 0; doOutput(&chr, 1); clsCheck(_textWindow); } else if (chr == 0 || chr == ' ' || chr == 10) { bool fit; if (getGameType() == GType_FF || getGameType() == GType_PP) { fit = _printCharMaxPos - _printCharCurPos > _printCharPixelCount; } else { fit = _printCharMaxPos - _printCharCurPos >= _printCharPixelCount; } if (fit) { _printCharCurPos += _printCharPixelCount; doOutput(_lettersToPrintBuf, _numLettersToPrint); if (_printCharCurPos == _printCharMaxPos) { _printCharCurPos = 0; } else { if (chr) doOutput(&chr, 1); if (chr == 10) _printCharCurPos = 0; else if (chr != 0) _printCharCurPos += (getGameType() == GType_FF || getGameType() == GType_PP) ? getFeebleFontSize(chr) : 1; } } else { const byte newline_character = 10; _printCharCurPos = _printCharPixelCount; doOutput(&newline_character, 1); doOutput(_lettersToPrintBuf, _numLettersToPrint); if (chr == ' ') { doOutput(&chr, 1); _printCharCurPos += (getGameType() == GType_FF || getGameType() == GType_PP) ? getFeebleFontSize(chr) : 1; } else { doOutput(&chr, 1); _printCharCurPos = 0; } } _numLettersToPrint = 0; _printCharPixelCount = 0; } else { _lettersToPrintBuf[_numLettersToPrint++] = chr; _printCharPixelCount += (getGameType() == GType_FF || getGameType() == GType_PP) ? getFeebleFontSize(chr) : 1; } }
void AGOSEngine_Feeble::saveUserGame(int slot) { WindowBlock *window; Common::InSaveFile *in; char name[108]; int len; memset(name, 0, 108); window = _windowArray[3]; window->textRow = (slot + 1 - window->scrollY) * 15; window->textColumn = 26; if ((in = _saveFileMan->openForLoading(genSaveName(readVariable(55))))) { in->read(name, 100); delete in; } len = 0; while (name[len]) { byte chr = name[len]; window->textColumn += getFeebleFontSize(chr); len++; } windowPutChar(window, 0x7f); while (!shouldQuit()) { _keyPressed.reset(); delay(1); if (_keyPressed.ascii == 0 || _keyPressed.ascii >= 127) continue; window->textColumn -= getFeebleFontSize(127); name[len] = 0; windowBackSpace(_windowArray[3]); if (_keyPressed.keycode == Common::KEYCODE_ESCAPE) { _variableArray[55] = 27; break; } if (_keyPressed.keycode == Common::KEYCODE_KP_ENTER || _keyPressed.keycode == Common::KEYCODE_RETURN) { if (!saveGame(readVariable(55), name)) _variableArray[55] = (int16)0xFFFF; else _variableArray[55] = 0; break; } if (_keyPressed.keycode == Common::KEYCODE_BACKSPACE && len != 0) { len--; byte chr = name[len]; window->textColumn -= getFeebleFontSize(chr); name[len] = 0; windowBackSpace(_windowArray[3]); } if (_keyPressed.ascii >= 32 && window->textColumn + 26 <= window->width) { name[len++] = _keyPressed.ascii; windowPutChar(_windowArray[3], _keyPressed.ascii); } windowPutChar(window, 0x7f); } }
void AGOSEngine::windowPutChar(WindowBlock *window, byte c, byte b) { byte width = 6; if (c == 12) { clearWindow(window); } else if (c == 13 || c == 10) { windowNewLine(window); } else if ((c == 1 && _language != Common::HE_ISR) || (c == 8)) { if (_language == Common::HE_ISR) { if (b >= 64 && b < 91) width = _hebrewCharWidths [b - 64]; if (window->textLength != 0) { window->textLength--; window->textColumnOffset += width; if (window->textColumnOffset >= 8) { window->textColumnOffset -= 8; window->textColumn--; } } } else { int8 val = (c == 8) ? 6 : 4; if (window->textLength != 0) { window->textLength--; window->textColumnOffset -= val; if ((int8)window->textColumnOffset < val) { window->textColumnOffset += 8; window->textColumn--; } } } } else if (c >= 32) { if (getGameType() == GType_FF || getGameType() == GType_PP) { // Ignore invalid characters if (c - 32 > 195) return; windowDrawChar(window, window->textColumn + window->x, window->textRow + window->y, c); window->textColumn += getFeebleFontSize(c); return; } // Ignore invalid characters if (c - 32 > 98) return; if (window->textLength == window->textMaxLength) { windowNewLine(window); } else if (window->textRow == window->height) { windowNewLine(window); window->textRow--; } if (_language == Common::HE_ISR) { if (c >= 64 && c < 91) width = _hebrewCharWidths [c - 64]; window->textColumnOffset -= width; if (window->textColumnOffset >= width) { window->textColumnOffset += 8; window->textColumn++; } windowDrawChar(window, (window->width + window->x - window->textColumn) * 8, window->textRow * 8 + window->y, c); window->textLength++; } else { windowDrawChar(window, (window->textColumn + window->x) * 8, window->textRow * 8 + window->y, c); window->textLength++; window->textColumnOffset += 6; if (getGameType() == GType_SIMON1 || getGameType() == GType_SIMON2) { if (c == 'i' || c == 'l') window->textColumnOffset -= 2; } if (window->textColumnOffset >= 8) { window->textColumnOffset -= 8; window->textColumn++; } } } }