void AdlEngine_v2::checkTextOverflow(char c) { if (c != APPLECHAR('\r')) return; ++_linesPrinted; if (_linesPrinted < 4) return; _linesPrinted = 0; _display->updateTextScreen(); bell(); while (true) { char key = inputKey(false); if (shouldQuit()) return; if (key == APPLECHAR('\r')) break; bell(3); } }
int AdlEngine_v2::askForSlot(const Common::String &question) { while (1) { _display->printString(question); Common::String input = inputString(); if (shouldQuit()) return -1; if (input.size() > 0 && input[0] >= APPLECHAR('A') && input[0] <= APPLECHAR('O')) return input[0] - APPLECHAR('A'); } }
void HiRes1Engine::wordWrap(Common::String &str) const { uint end = 39; while (1) { if (str.size() <= end) return; while (str[end] != APPLECHAR(' ')) --end; str.setChar(APPLECHAR('\r'), end); end += 40; } }
int AdlEngine_v2::o2_tellTime(ScriptEnv &e) { OP_DEBUG_0("\tTELL_TIME()"); Common::String time = _strings_v2.time; time.setChar(APPLECHAR('0') + _state.time.hours / 10, 12); time.setChar(APPLECHAR('0') + _state.time.hours % 10, 13); time.setChar(APPLECHAR('0') + _state.time.minutes / 10, 15); time.setChar(APPLECHAR('0') + _state.time.minutes % 10, 16); printString(time); return 0; }
Common::String Console::toAppleWord(const Common::String &str) { Common::String apple(str); if (apple.size() > IDI_WORD_SIZE) apple.erase(IDI_WORD_SIZE); apple.toUppercase(); for (uint i = 0; i < apple.size(); ++i) apple.setChar(APPLECHAR(apple[i]), i); while (apple.size() < IDI_WORD_SIZE) apple += APPLECHAR(' '); return apple; }
void HiRes5Engine::runIntro() { insertDisk(2); StreamPtr stream(_disk->createReadStream(0x10, 0x0, 0x00, 31)); _display->setMode(DISPLAY_MODE_HIRES); _display->loadFrameBuffer(*stream); _display->updateHiResScreen(); inputKey(); _display->home(); _display->setMode(DISPLAY_MODE_TEXT); stream.reset(_disk->createReadStream(0x03, 0xc, 0x34, 1)); Common::String menu(readString(*stream)); while (!g_engine->shouldQuit()) { _display->home(); _display->printString(menu); Common::String cmd(inputString()); // We ignore the backup and format menu options if (!cmd.empty() && cmd[0] == APPLECHAR('1')) break; }; }
void Display::printAsciiString(const Common::String &str) { Common::String aStr; Common::String::const_iterator it; for (it = str.begin(); it != str.end(); ++it) aStr += APPLECHAR(*it); printString(aStr); }
// FIXME: This does not currently update the surfaces void Display::printChar(char c) { if (c == APPLECHAR('\r')) _cursorPos = (_cursorPos / TEXT_WIDTH + 1) * TEXT_WIDTH; else if ((byte)c < 0x80 || (byte)c >= 0xa0) { setCharAtCursor(c); ++_cursorPos; } if (_cursorPos == TEXT_BUF_SIZE) scrollUp(); }
void AdlEngine_v2::printString(const Common::String &str) { Common::String s(str); byte endPos = TEXT_WIDTH - 1; byte pos = 0; while (true) { while (pos <= endPos && pos != s.size()) { s.setChar(APPLECHAR(s[pos]), pos); ++pos; } if (pos == s.size()) break; while (s[pos] != APPLECHAR(' ') && s[pos] != APPLECHAR('\r')) --pos; s.setChar(APPLECHAR('\r'), pos); endPos = pos + TEXT_WIDTH; ++pos; } pos = 0; while (pos != s.size()) { checkTextOverflow(s[pos]); _display->printChar(s[pos]); ++pos; } checkTextOverflow(APPLECHAR('\r')); _display->printChar(APPLECHAR('\r')); _display->updateTextScreen(); }
void Display::printString(const Common::String &str) { Common::String::const_iterator c; for (c = str.begin(); c != str.end(); ++c) { byte b = *c; if (*c == APPLECHAR('\r')) _cursorPos = (_cursorPos / TEXT_WIDTH + 1) * TEXT_WIDTH; else if (b < 0x80 || b >= 0xa0) { setCharAtCursor(b); ++_cursorPos; } if (_cursorPos == TEXT_BUF_SIZE) scrollUp(); } updateTextScreen(); }
void Display::home() { memset(_textBuf, (byte)APPLECHAR(' '), TEXT_BUF_SIZE); _cursorPos = 0; }
void HiRes1Engine::runIntro() const { StreamPtr stream(_files->createReadStream(IDS_HR1_EXE_0)); stream->seek(IDI_HR1_OFS_LOGO_0); _display->setMode(DISPLAY_MODE_HIRES); _display->loadFrameBuffer(*stream); _display->updateHiResScreen(); delay(4000); if (shouldQuit()) return; _display->setMode(DISPLAY_MODE_TEXT); StreamPtr basic(_files->createReadStream(IDS_HR1_LOADER)); Common::String str; str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_0, '"'); _display->printAsciiString(str + '\r'); str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_1, '"'); _display->printAsciiString(str + "\r\r"); str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_2, '"'); _display->printAsciiString(str + "\r\r"); str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_3, '"'); _display->printAsciiString(str + '\r'); inputKey(); if (g_engine->shouldQuit()) return; _display->setMode(DISPLAY_MODE_MIXED); str = readStringAt(*stream, IDI_HR1_OFS_GAME_OR_HELP); bool instructions = false; while (1) { _display->printString(str); Common::String s = inputString(); if (g_engine->shouldQuit()) break; if (s.empty()) continue; if (s[0] == APPLECHAR('I')) { instructions = true; break; } else if (s[0] == APPLECHAR('G')) { break; } }; if (instructions) { _display->setMode(DISPLAY_MODE_TEXT); stream->seek(IDI_HR1_OFS_INTRO_TEXT); const uint pages[] = { 6, 6, 4, 5, 8, 7, 0 }; uint page = 0; while (pages[page] != 0) { _display->home(); uint count = pages[page++]; for (uint i = 0; i < count; ++i) { str = readString(*stream); _display->printString(str); stream->seek(3, SEEK_CUR); } inputString(); if (g_engine->shouldQuit()) return; stream->seek(6, SEEK_CUR); } } _display->printAsciiString("\r"); _display->setMode(DISPLAY_MODE_MIXED); // Title screen shown during loading stream.reset(_files->createReadStream(IDS_HR1_EXE_1)); stream->seek(IDI_HR1_OFS_LOGO_1); _display->loadFrameBuffer(*stream); _display->updateHiResScreen(); delay(2000); }
Common::String HiRes1Engine::loadMessage(uint idx) const { StreamPtr stream(_messages[idx]->createReadStream()); return readString(*stream, APPLECHAR('\r')) + APPLECHAR('\r'); }