FS13585: Display corruption in robotfindskitten game

When you're using a "large" screen device, and the message doesn't need
to scroll, parts of the previous mesage are left behind.

Work around this by explicitly clearing the messgage with a loooong
blank string.

Change-Id: I02f7789eb6567e92ecca174c40dabc4b580ac045
This commit is contained in:
Solomon Peachy 2025-09-06 12:44:11 -04:00
parent e4e50e36f1
commit d51d49550c

View file

@ -9,7 +9,7 @@
* *
* robotfindskitten: A Zen simulation * robotfindskitten: A Zen simulation
* *
* Copyright (C) 1997,2000 Leonard Richardson * Copyright (C) 1997,2000 Leonard Richardson
* leonardr@segfault.org * leonardr@segfault.org
* http://www.crummy.com/devel/ * http://www.crummy.com/devel/
* *
@ -39,8 +39,8 @@
/*Be sure to change MESSAGES when you change the array, or bad things /*Be sure to change MESSAGES when you change the array, or bad things
will happen.*/ will happen.*/
/*Also, take note that robotfindskitten.c and configure.in /*Also, take note that robotfindskitten.c and configure.in
currently have the version number hardcoded into them, and they currently have the version number hardcoded into them, and they
should reflect MESSAGES. */ should reflect MESSAGES. */
/* Watch out for fenceposts.*/ /* Watch out for fenceposts.*/
@ -327,7 +327,7 @@ static char* messages[] =
"A discredited cosmology, relic of a bygone era.", "A discredited cosmology, relic of a bygone era.",
"A hollow voice says \"Plugh\".", "A hollow voice says \"Plugh\".",
"A knight who says \"Either I am an insane knave, or you will find kitten.\"", "A knight who says \"Either I am an insane knave, or you will find kitten.\"",
"The secret meeting place of the Knights of the Lambda Calculus.", "The secret meeting place of the Knights of the Lambda Calculus.",
"A neural net -- maybe it's trying to recognize kitten.", "A neural net -- maybe it's trying to recognize kitten.",
"A screwdriver.", "A screwdriver.",
"A statue of a girl holding a goose like the one in Gottingen, Germany.", "A statue of a girl holding a goose like the one in Gottingen, Germany.",
@ -350,18 +350,18 @@ static char* messages[] =
"Sutro Tower is visible at some distance through the fog.", "Sutro Tower is visible at some distance through the fog.",
"The Digital Millennium Copyright Act of 1998.", "The Digital Millennium Copyright Act of 1998.",
"The United States Court of Appeals for the Federal Circuit.", "The United States Court of Appeals for the Federal Circuit.",
"The non-kitten item like this but with \"false\" and \"true\" switched is true.", "The non-kitten item like this but with \"false\" and \"true\" switched is true.",
"The non-kitten item like this but with \"true\" and \"false\" switched is false.", "The non-kitten item like this but with \"true\" and \"false\" switched is false.",
"This is the chapter called \"A Map of the Cat?\" from Feynman's autobiography.", "This is the chapter called \"A Map of the Cat?\" from Feynman's autobiography.",
"This is the forest primeval.", "This is the forest primeval.",
"Werner's \"Pocket Field Guide to Things That Are Not Kitten\".", "Werner's \"Pocket Field Guide to Things That Are Not Kitten\".",
"You found nettik, but that's backwards.", "You found nettik, but that's backwards.",
"You have found some zinc, but you must not stop here, for you must find kitten.", "You have found some zinc, but you must not stop here, for you must find kitten.",
"\"50 Years Among the Non-Kitten Items\", by Ann Droyd.", "\"50 Years Among the Non-Kitten Items\", by Ann Droyd.",
"\"Robot may not injure kitten, or, through inaction, ...\"", "\"Robot may not injure kitten, or, through inaction, ...\"",
"\"Address Allocation for Private Internets\" by Yakov Rekhter et al.", "\"Address Allocation for Private Internets\" by Yakov Rekhter et al.",
"\"Mail Routing and the Domain System\" by Craig Partridge.", "\"Mail Routing and the Domain System\" by Craig Partridge.",
"\"The Theory and Practice of Oligarchical Collectivism\" by Emmanuel Goldstein.", "\"The Theory and Practice of Oligarchical Collectivism\" by Emmanuel Goldstein.",
"\"201 Kitten Verbs, Fully Conjugated\". You look for \"find\".", "\"201 Kitten Verbs, Fully Conjugated\". You look for \"find\".",
"A card shark sits here, practicing his Faro shuffle. He ignores you.", "A card shark sits here, practicing his Faro shuffle. He ignores you.",
"A copy of DeCSS. They're a dime a dozen these days.", "A copy of DeCSS. They're a dime a dozen these days.",
@ -645,25 +645,27 @@ static void play_game()
while (input != RFK_QUIT && exit_rfk == false) while (input != RFK_QUIT && exit_rfk == false)
{ {
process_input(input); process_input(input);
/*Redraw robot, where applicable. We're your station, robot.*/ /*Redraw robot, where applicable. We're your station, robot.*/
if (!(old_x == robot.x && old_y == robot.y)) if (!(old_x == robot.x && old_y == robot.y))
{ {
/*Get rid of the old robot*/ /*Get rid of the old robot*/
drawchar(old_x, old_y, ' '); drawchar(old_x, old_y, ' ');
screen[old_x][old_y] = EMPTY; screen[old_x][old_y] = EMPTY;
/*Meet the new robot, same as the old robot.*/ /*Meet the new robot, same as the old robot.*/
draw(robot); draw(robot);
refresh(); refresh();
screen[robot.x][robot.y] = ROBOT; screen[robot.x][robot.y] = ROBOT;
old_x = robot.x; old_x = robot.x;
old_y = robot.y; old_y = robot.y;
} }
input = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts, input = pluginlib_getaction(TIMEOUT_BLOCK, plugin_contexts,
ARRAYLEN(plugin_contexts)); ARRAYLEN(plugin_contexts));
} }
message(" ");
message("Bye!"); message("Bye!");
refresh(); refresh();
} }
@ -696,19 +698,13 @@ static void process_input(int input)
check_x++; check_x++;
break; break;
} }
/*Check for going off the edge of the screen.*/ /*Check for going off the edge of the screen.*/
if (check_y < Y_MIN || check_y > Y_MAX || check_x < X_MIN || check_x > X_MAX) if (check_y < Y_MIN || check_y > Y_MAX || check_x < X_MIN || check_x > X_MAX)
{ {
return; /*Do nothing.*/ return; /*Do nothing.*/
} }
/*
* Clear textline
* disabled because it breaks the scrolling for some reason
*/
/* rb->lcd_puts_scroll(0, ADV_ROW, " "); */
/*Check for collision*/ /*Check for collision*/
if (screen[check_x][check_y] != EMPTY) if (screen[check_x][check_y] != EMPTY)
{ {
@ -724,6 +720,7 @@ static void process_input(int input)
rfkpause(); rfkpause();
break; break;
default: /*We hit a bogus object; print its message.*/ default: /*We hit a bogus object; print its message.*/
message(" ");
message(messages[bogus_messages[screen[check_x][check_y]-2]]); message(messages[bogus_messages[screen[check_x][check_y]-2]]);
refresh(); refresh();
break; break;
@ -776,7 +773,7 @@ static void play_animation(int input)
{ {
int counter; int counter;
/* Clear the message line */ /* Clear the message line */
message(" "); message(" ");
struct screen_object left; struct screen_object left;
struct screen_object right; struct screen_object right;
/*The grand cinema scene.*/ /*The grand cinema scene.*/
@ -810,6 +807,7 @@ static void play_animation(int input)
rb->sleep(HZ); rb->sleep(HZ);
} }
message(" ");
message("You found kitten! Way to go, robot!"); message("You found kitten! Way to go, robot!");
refresh(); refresh();
finish(0); finish(0);
@ -857,7 +855,7 @@ static void initialize_arrays()
#endif #endif
empty.bold = false; empty.bold = false;
empty.character = ' '; empty.character = ' ';
for (counter = 0; counter <= X_MAX; counter++) for (counter = 0; counter <= X_MAX; counter++)
{ {
for (counter2 = 0; counter2 <= Y_MAX; counter2++) for (counter2 = 0; counter2 <= Y_MAX; counter2++)
@ -865,7 +863,7 @@ static void initialize_arrays()
screen[counter][counter2] = EMPTY; screen[counter][counter2] = EMPTY;
} }
} }
/*Initialize the other arrays.*/ /*Initialize the other arrays.*/
for (counter = 0; counter < MESSAGES; counter++) for (counter = 0; counter < MESSAGES; counter++)
{ {
@ -899,7 +897,7 @@ static void initialize_kitten()
kitten.x = randx(); kitten.x = randx();
kitten.y = randy(); kitten.y = randy();
} while (screen[kitten.x][kitten.y] != EMPTY); } while (screen[kitten.x][kitten.y] != EMPTY);
/*Assign the kitten a character and a color.*/ /*Assign the kitten a character and a color.*/
do { do {
kitten.character = randchar(); kitten.character = randchar();
@ -919,12 +917,12 @@ static void initialize_bogus()
/*Give it a color.*/ /*Give it a color.*/
bogus[counter].color = colors[randcolor()]; bogus[counter].color = colors[randcolor()];
bogus[counter].bold = randbold(); bogus[counter].bold = randbold();
/*Give it a character.*/ /*Give it a character.*/
do { do {
bogus[counter].character = randchar(); bogus[counter].character = randchar();
} while (!(validchar(bogus[counter].character))); } while (!(validchar(bogus[counter].character)));
/*Give it a position.*/ /*Give it a position.*/
do { do {
bogus[counter].x = randx(); bogus[counter].x = randx();
@ -932,7 +930,7 @@ static void initialize_bogus()
} while (screen[bogus[counter].x][bogus[counter].y] != EMPTY); } while (screen[bogus[counter].x][bogus[counter].y] != EMPTY);
screen[bogus[counter].x][bogus[counter].y] = counter+2; screen[bogus[counter].x][bogus[counter].y] = counter+2;
/*Find a message for this object.*/ /*Find a message for this object.*/
do { do {
index = rb->rand() % MESSAGES; index = rb->rand() % MESSAGES;
@ -957,7 +955,7 @@ static void initialize_screen()
rb->snprintf(buf, sizeof(buf), "robotfindskitten %s", RFK_VERSION); rb->snprintf(buf, sizeof(buf), "robotfindskitten %s", RFK_VERSION);
rb->lcd_puts_scroll(0, 0, buf); rb->lcd_puts_scroll(0, 0, buf);
refresh(); refresh();
/*Draw a line across the screen.*/ /*Draw a line across the screen.*/
for (counter = X_MIN; counter <= X_MAX + 1; counter++) for (counter = X_MIN; counter <= X_MAX + 1; counter++)
{ {