aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/text.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/agi/text.cpp')
-rw-r--r--engines/agi/text.cpp98
1 files changed, 58 insertions, 40 deletions
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 63b109ee83..04af531809 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -24,7 +24,7 @@
*/
#include "agi/agi.h"
-#include "agi/sprite.h" /* for commit_both() */
+#include "agi/sprite.h" // for commit_both()
#include "agi/graphics.h"
#include "agi/keyboard.h"
@@ -35,7 +35,7 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
int x1, y1;
int maxx, minx, ofoff;
int update;
- /* Note: Must be unsigned to use AGDS cyrillic characters! */
+ // Note: Must be unsigned to use AGDS cyrillic characters!
#ifdef __DS__
// On the DS, a compiler bug causes the text to render incorrectly, because
// GCC tries to optimisie out writes to this pointer (tested on DevkitARM v19b and v20)
@@ -45,20 +45,19 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
const unsigned char *m;
#endif
- /* kludge! */
+ // kludge!
update = 1;
if (l == 2) {
update = l = 0;
}
- /* FR: strings with len == 1 were not printed
- */
+ // FR: strings with len == 1 were not printed
if (len == 1) {
_gfx->putTextCharacter(l, xoff + foff, yoff, *msg, fg, bg, checkerboard);
maxx = 1;
minx = 0;
ofoff = foff;
- y1 = 0; /* Check this */
+ y1 = 0; // Check this
} else {
maxx = 0;
minx = GFX_WIDTH;
@@ -69,7 +68,7 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
if (*m >= 0x20 || *m == 1 || *m == 2 || *m == 3) {
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
// needs fixing, or remove it!
- /* FIXME */
+ // FIXME
int ypos;
ypos = (y1 * CHAR_LINES) + yoff;
@@ -92,7 +91,7 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
x1++;
- /* DF: changed the len-1 to len... */
+ // DF: changed the len-1 to len...
if (x1 == len && m[len] != '\n')
y1++, x1 = foff = 0;
} else {
@@ -114,17 +113,18 @@ void AgiEngine::printText2(int l, const char *msg, int foff, int xoff, int yoff,
if (update) {
_gfx->scheduleUpdate(foff + xoff + minx, yoff, ofoff + xoff + maxx + CHAR_COLS - 1,
yoff + y1 * CHAR_LINES + CHAR_LINES + 1);
- /* Making synchronous text updates reduces CPU load
- * when updating status line and input area
- */
+
+ // Making synchronous text updates reduces CPU load
+ // when updating status line and input area
_gfx->doUpdate();
}
}
-/* len is in characters, not pixels!!
- */
+//
+// len is in characters, not pixels!!
+//
void AgiEngine::blitTextbox(const char *p, int y, int x, int len) {
- /* if x | y = -1, then centre the box */
+ // if x | y = -1, then center the box
int xoff, yoff, lin, h, w;
char *msg, *m;
@@ -144,7 +144,7 @@ void AgiEngine::blitTextbox(const char *p, int y, int x, int len) {
m = msg = wordWrapString(agiSprintf(p), &len);
for (lin = 1; *m; m++) {
- /* Test \r for MacOS 8 */
+ // Test \r for MacOS 8
if (*m == '\n' || *m == '\r')
lin++;
}
@@ -301,9 +301,9 @@ void AgiEngine::closeWindow() {
debugC(4, kDebugLevelText, "closeWindow()");
_sprites->eraseBoth();
- eraseTextbox(); /* remove window, if any */
+ eraseTextbox(); // remove window, if any
_sprites->blitBoth();
- _sprites->commitBoth(); /* redraw sprites */
+ _sprites->commitBoth(); // redraw sprites
_game.hasWindow = false;
}
@@ -340,7 +340,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
int rc = -1;
int bx[5], by[5];
- setflag(fNoSaveLoadAllowed, true);
+ _noSaveLoadAllowed = true;
_sprites->eraseBoth();
blitTextbox(m, -1, -1, -1);
@@ -350,7 +350,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
s = _game.window.x2 - _game.window.x1 + 1 - 5 * CHAR_COLS;
debugC(3, kDebugLevelText, "selectionBox(): s = %d", s);
- /* Automatically position buttons */
+ // Automatically position buttons
for (i = 0; b[i]; i++) {
numButtons++;
s -= CHAR_COLS * strlen(b[i]);
@@ -371,19 +371,16 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
_sprites->blitBoth();
- /* clear key queue */
- while (_gfx->keypress()) {
- _gfx->getKey();
- }
+ clearKeyQueue();
AllowSyntheticEvents on(this);
debugC(4, kDebugLevelText, "selectionBox(): waiting...");
- while (!(shouldQuit() || restartGame)) {
+ while (!(shouldQuit() || _restartGame)) {
for (i = 0; b[i]; i++)
_gfx->drawCurrentStyleButton(bx[i], by[i], b[i], i == active, false, i == 0);
- _gfx->pollTimer(); /* msdos driver -> does nothing */
+ pollTimer();
key = doPollKeyboard();
switch (key) {
case KEY_ENTER:
@@ -410,7 +407,7 @@ int AgiEngine::selectionBox(const char *m, const char **b) {
}
}
break;
- case 0x09: /* Tab */
+ case 0x09: // Tab
debugC(3, kDebugLevelText, "selectionBox(): Focus change");
active++;
active %= i;
@@ -426,7 +423,7 @@ getout:
closeWindow();
debugC(2, kDebugLevelText, "selectionBox(): Result = %d", rc);
- setflag(fNoSaveLoadAllowed, false);
+ _noSaveLoadAllowed = false;
return rc;
}
@@ -449,14 +446,14 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
blitTextbox(p, lin, col, len);
if (getflag(fOutputMode)) {
- /* non-blocking window */
+ // non-blocking window
setflag(fOutputMode, false);
return 1;
}
- /* blocking */
+ // blocking
- setflag(fNoSaveLoadAllowed, true);
+ _noSaveLoadAllowed = true;
if (_game.vars[vWindowReset] == 0) {
int k;
@@ -464,21 +461,26 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
k = waitKey();
closeWindow();
- setflag(fNoSaveLoadAllowed, false);
+ _noSaveLoadAllowed = false;
return k;
}
- /* timed window */
+ // timed window
debugC(3, kDebugLevelText, "f15==0, v21==%d => timed", getvar(21));
_game.msgBoxTicks = getvar(vWindowReset) * 10;
setvar(vKey, 0);
+ _menuSelected = false;
+
do {
if (getflag(fRestoreJustRan))
break;
+ if (_menuSelected)
+ break;
+
mainCycle();
if (_game.keypress == KEY_ENTER) {
debugC(4, kDebugLevelText, "KEY_ENTER");
@@ -492,7 +494,7 @@ int AgiEngine::print(const char *p, int lin, int col, int len) {
closeWindow();
- setflag(fNoSaveLoadAllowed, false);
+ _noSaveLoadAllowed = false;
return 0;
}
@@ -561,8 +563,8 @@ char *AgiEngine::agiSprintf(const char *s) {
}
if (i == 99) {
- /* remove all leading 0 */
- /* don't remove the 3rd zero if 000 */
+ // remove all leading 0
+ // don't remove the 3rd zero if 000
for (i = 0; z[i] == '0' && i < 14; i++)
;
} else {
@@ -630,10 +632,14 @@ void AgiEngine::writeStatus() {
clearLines(_game.lineStatus, _game.lineStatus, 0);
flushLines(_game.lineStatus, _game.lineStatus);
+#if 0
+ // FIXME: Breaks wrist watch prompt in SQ2
+
// Clear the user input line as well when clearing the status line
// Fixes bug #1893564 - AGI: Texts messed out in Naturette 1
clearLines(_game.lineUserInput, _game.lineUserInput, 0);
flushLines(_game.lineUserInput, _game.lineUserInput);
+#endif
return;
}
@@ -656,8 +662,11 @@ void AgiEngine::writePrompt() {
int l, fg, bg, pos;
int promptLength = strlen(agiSprintf(_game.strings[0]));
- if (!_game.inputEnabled || _game.inputMode != INPUT_NORMAL)
+ if (!_game.inputEnabled || _game.inputMode != INPUT_NORMAL) {
+ clearPrompt();
+
return;
+ }
l = _game.lineUserInput;
fg = _game.colorFg;
@@ -676,6 +685,16 @@ void AgiEngine::writePrompt() {
_gfx->doUpdate();
}
+void AgiEngine::clearPrompt() {
+ int l;
+
+ l = _game.lineUserInput;
+ clearLines(l, l, _game.colorBg);
+ flushLines(l, l);
+
+ _gfx->doUpdate();
+}
+
/**
* Clear text lines in the screen.
* @param l1 start line
@@ -683,10 +702,9 @@ void AgiEngine::writePrompt() {
* @param c color
*/
void AgiEngine::clearLines(int l1, int l2, int c) {
- /* do we need to adjust for +8 on topline?
- * inc for endline so it matches the correct num
- * ie, from 22 to 24 is 3 lines, not 2 lines.
- */
+ // do we need to adjust for +8 on topline?
+ // inc for endline so it matches the correct num
+ // ie, from 22 to 24 is 3 lines, not 2 lines.
l1 *= CHAR_LINES;
l2 *= CHAR_LINES;