void lcd_display(int16 number, int x, int y)
{
   int unitsPosition, tensPosition, hundredsPosition;

       unitsPosition =number % 10;
       tensPosition = ((number - (number % 10))%100)/10;
       hundredsPosition = ((number - (number%100))%1000)/100;

       lcd_gotoxy(x,y);
       lcd_putc(convertToASCII(hundredsPosition));
       lcd_putc(convertToASCII(tensPosition));
       lcd_putc(convertToASCII(unitsPosition));
}
Example #2
0
bool Console::cmd_dumpstaticinfo(int argc, const char **argv) {
	if (argc == 3) {
		const uint8 sceneId = atoi(argv[1]);
		const uint8 staticId = atoi(argv[2]);

		Scene *const scene = _vm->getGame().getGameData().getScene(sceneId);
		if (scene) {
			Static *const stat = scene->getStatic(staticId, true);
			if (stat) {
				debugPrintf("Active: %u\n", (unsigned int) stat->_active);
				debugPrintf("Name: '%s'\n", convertToASCII(stat->_name).c_str());
				debugPrintf("X: %u\n", (unsigned int) stat->_x);
				debugPrintf("Y: %u\n", (unsigned int) stat->_y);
				debugPrintf("Width: %u\n", (unsigned int) stat->_width);
				debugPrintf("Height: %u\n", (unsigned int) stat->_height);
				debugPrintf("WalkToX: %u\n", (unsigned int) stat->_walkToY);
				debugPrintf("WalkToY: %u\n", (unsigned int) stat->_walkToX);
				debugPrintf("WalkToFrame: %u\n", (unsigned int) stat->_walkToFrame);
			} else {
				debugPrintf("Static %u not found.\n", (unsigned int) staticId);
			}
		} else {
			debugPrintf("Scene %u not found.\n", (unsigned int) sceneId);
		}
	} else {
		debugPrintf("dumpstaticinfo <sceneid> <staticid>\n");
	}

	return true;
}
Example #3
0
bool Console::cmd_dumpdoorinfo(int argc, const char **argv) {
	if (argc == 3) {
		const uint8 sceneId = atoi(argv[1]);
		const uint8 doorId = atoi(argv[2]);

		Scene *const scene = _vm->getGame().getGameData().getScene(sceneId);
		if (scene) {
			Door *const door = scene->getDoor(doorId);
			if (door) {
				debugPrintf("Name: '%s'\n", convertToASCII(door->_name).c_str());
				debugPrintf("DestSceneId: %u\n", (unsigned int) door->_destSceneId);
				debugPrintf("DestX: %u\n", (unsigned int) door->_destX);
				debugPrintf("DestY: %u\n", (unsigned int) door->_destY);
				debugPrintf("X: %u\n", (unsigned int) door->_x);
				debugPrintf("Y: %u\n", (unsigned int) door->_y);
				debugPrintf("Width: %u\n", (unsigned int) door->_width);
				debugPrintf("Height: %u\n", (unsigned int) door->_height);
				debugPrintf("WalkToX: %u\n", (unsigned int) door->_walkToX);
				debugPrintf("WalkToY: %u\n", (unsigned int) door->_walkToY);
				debugPrintf("SP: %u\n", (unsigned int) door->_SP);
			} else {
				debugPrintf("Door %u not found.\n", (unsigned int) doorId);
			}
		} else {
			debugPrintf("Scene %u not found.\n", (unsigned int) sceneId);
		}
	} else {
		debugPrintf("dumpdoorinfo <sceneid> <doorid>\n");
	}

	return true;
}
Example #4
0
void Console::showCommands(Command *command, int indentLevel) {
	while (command) {
		showIndent(indentLevel);
		debugPrintf("%s\n", convertToASCII(command->debugString()).c_str());

		if (SeqCommand *const seqCmd = dynamic_cast<SeqCommand *>(command)) {
			command = seqCmd->next();
		} else if (ConditionalCommand *const condCmd = dynamic_cast<ConditionalCommand *>(command)) {
			showCommands(condCmd->getTrueCommand(), indentLevel + 1);
			showIndent(indentLevel);
			debugPrintf("ELSE\n");
			showCommands(condCmd->getFalseCommand(), indentLevel + 1);
			command = nullptr;
		} else if (CallMacroCommand *const callMacroCmd = dynamic_cast<CallMacroCommand *>(command)) {
			command = callMacroCmd->getReturnCommand();
		} else if (RandomCommand *const randomCmd = dynamic_cast<RandomCommand *>(command)) {
			const RandomCommand::Choices &choices = randomCmd->getChoices();
			for (RandomCommand::Choices::size_type i = 0; i < choices.size(); ++i) {
				showIndent(indentLevel + 1);
				debugPrintf("CASE %u\n", i);
				showCommands(choices[i], indentLevel + 2);
			}
			command = nullptr;
		} else {
			command = nullptr;
		}
	}
}
Example #5
0
bool Console::cmd_listinventory(int, const char **) {
	Inventory &inventory = _vm->getGame().getGameData().getInventory();
	const Inventory::Items &items = inventory.getItems();
	for (Inventory::Items::const_iterator it = items.begin(); it != items.end(); ++it) {
		debugPrintf("%s\n", convertToASCII(*it).c_str());
	}
	return true;
}
Example #6
0
/**
 * Retrieves the details for the specified location
 *
 * @param pczLocation The string containing the name/code of the location
 *
 * @return A pointer to a list of LocationInfo entries, possibly empty, 
 *         if no details were found. Caller is responsible for freeing the list.
 */
GList *
getLocationInfo(const gchar * pczLocation)
{
  gint iRetCode = 0;
  gint iDataSize = 0;

  GList * pList = NULL;

  gchar * pcEscapedLocation = convertToASCII(pczLocation); 

  gsize len = getWOEIDQueryLength(pcEscapedLocation);

  gchar * cQueryBuffer = g_malloc0(len);

  gint iRet = getWOEIDQuery(cQueryBuffer, pcEscapedLocation);

  g_free(pcEscapedLocation);

  LXW_LOG(LXW_DEBUG, "yahooutil::getLocationInfo(%s): query[%d]: %s",
          pczLocation, iRet, cQueryBuffer);

  gpointer pResponse = getURL(cQueryBuffer, &iRetCode, &iDataSize);

  if (!pResponse || iRetCode != HTTP_STATUS_OK)
    {
      LXW_LOG(LXW_ERROR, "yahooutil::getLocationInfo(%s): Failed with error code %d",
              pczLocation, iRetCode);
    }
  else
    {
      LXW_LOG(LXW_DEBUG, "yahooutil::getLocationInfo(%s): Response code: %d, size: %d",
              pczLocation, iRetCode, iDataSize);

      LXW_LOG(LXW_VERBOSE, "yahooutil::getLocation(%s): Contents: %s", 
              pczLocation, (const char *)pResponse);

      iRet = parseResponse(pResponse, &pList, NULL);
      
      LXW_LOG(LXW_DEBUG, "yahooutil::getLocation(%s): Response parsing returned %d",
              pczLocation, iRet);

      if (iRet)
        {
          // failure
          g_list_free_full(pList, freeLocation);
        }

    }

  g_free(cQueryBuffer);
  g_free(pResponse);

  return pList;
}
Example #7
0
bool Console::cmd_listsections(int argc, const char **argv) {
	if (argc == 3) {
		Script *const script = getScriptFromArg(argv[1]);
		if (script) {
			ActionInfo::Action action = ActionInfo::Look;
			const char *word = nullptr;
			if (strcmp(argv[2], "L") == 0) {
				action = ActionInfo::Look;
				word = "Look";
			} else if (strcmp(argv[2], "W") == 0) {
				action = ActionInfo::Walk;
				word = "Walk";
			} else if (strcmp(argv[2], "T") == 0) {
				action = ActionInfo::Talk;
				word = "Talk";
			} else if (strcmp(argv[2], "U") == 0) {
				action = ActionInfo::Use;
				word = "Use";
			} else if (strcmp(argv[2], "P") == 0) {
				action = ActionInfo::PickUp;
				word = "Pick up";
			} else {
				debugPrintf("Choose 'L' (look), 'W' (walk), 'T' (talk), 'U' (use) or 'P' (pick up).\n");
			}
			if (word) {
				const ActionInfos &actionInfos = script->getActionInfos(action);
				for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
					const ActionInfo &actionInfo = *it;
					if (action != ActionInfo::Use || actionInfo._entity2Name.empty()) {
						debugPrintf("%s %s\n", word, convertToASCII(actionInfo._entity1Name).c_str());
					} else {
						debugPrintf("%s %s %s\n", word, convertToASCII(actionInfo._entity1Name).c_str(), convertToASCII(actionInfo._entity2Name).c_str());
					}
				}
			}
		}
	} else {
		debugPrintf("listsections <G|L> <L|W|T|U|P>\n");
	}
	return true;
}
Example #8
0
bool Console::cmd_showsection(int argc, const char **argv) {
	if (argc >= 4) {
		Script *const script = getScriptFromArg(argv[1]);
		if (script) {
			Command *command = nullptr;
			ActionInfo::Action action = ActionInfo::Look;
			bool correctAction = true;
			bool found = false;

			if (strcmp(argv[2], "L") == 0) {
				action = ActionInfo::Look;
			} else if (strcmp(argv[2], "W") == 0) {
				action = ActionInfo::Walk;
			} else if (strcmp(argv[2], "T") == 0) {
				action = ActionInfo::Talk;
			} else if (strcmp(argv[2], "U") == 0) {
				action = ActionInfo::Use;
			} else if (strcmp(argv[2], "P") == 0) {
				action = ActionInfo::PickUp;
			} else {
				debugPrintf("Choose 'L' (look), 'W' (walk), 'T' (talk), 'U' (use) or 'P' (pick up).\n");
				correctAction = false;
			}

			if (correctAction) {
				const ActionInfos &actionInfos = script->getActionInfos(action);
				for (ActionInfos::const_iterator it = actionInfos.begin(); it != actionInfos.end(); ++it) {
					const ActionInfo &actionInfo = *it;
					if (convertToASCII(actionInfo._entity1Name) == argv[3] && (action != ActionInfo::Use || ((argc == 4 && actionInfo._entity2Name.empty()) || (argc > 4 && convertToASCII(actionInfo._entity2Name) == argv[4])))) {
						found = true;
						command = actionInfo._command;
						break;
					}
				}

				if (found) {
					if (command) {
						showCommands(command);
					}
				} else {
					debugPrintf("Section not found.\n");
				}
			}
		}
	} else {
		debugPrintf("showsection <G|L> <L|W|T|U|P> <sectionname>\n");
	}

	return true;
}
Example #9
0
bool Console::cmd_showallcommands(int argc, const char **argv) {
	if (argc == 2) {
		Script *const script = getScriptFromArg(argv[1]);
		if (script) {
			const Commands &commands = script->getAllCommands();

			for (Commands::const_iterator it = commands.begin(); it != commands.end(); ++it) {
				debugPrintf("%s\n", convertToASCII((*it)->debugString()).c_str());
			}
		}
	} else {
		debugPrintf("showallcommands <G|L>\n");
	}

	return true;
}
Example #10
0
int main (int argc, const char * argv[]) {
    char stringArray[10][100];
    int i = 0;
    char choice = 0;
    
    printf("Enter up to 10 strings of up to 100 characters each.\n");
    
    // Get the input
    while (gets(stringArray[i]) && stringArray[i][0] != '\0' && i < 10) {
        i++;
    }
    
    menu();
    while ((choice = getchar()) != '5') {
        switch (choice) {
            case('1') :
                printArray(stringArray, i);
                break;
            case('2') :
                convertToASCII(stringArray, i);
                break;
            case('3') :
                printByStringLength(stringArray, i);
                break;
            case('4') :
                printByWordLength(stringArray, i);
                break;
            default :
                continue;
                break;
        }

        menu();
    }
    return 0;
}