[Scummvm-git-logs] scummvm master -> 1344c1621f7134b732def5f2c319d9d7ba1f3722
dreammaster
paulfgilbert at gmail.com
Sat Jun 13 22:38:24 UTC 2020
This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f3f32e073f GLK: COMPREHEND: Remove unneeded FIXME from MOVE_TO_ROOM
cf1f157f9f GLK: COMPREHEND: Implement Game Over failure
2527b97605 GLK: COMPREHEND: Field renamings for Transylvania monsters
82012b78d3 GLK: COMPREHEND: Field renamings
06e9e826d1 GLK: COMPREHEND: Debugger commands for rooms
2f6e1e1d87 GLK: COMPREHEND: Added findstring debugger command
649ab3ffa9 GLK: COMPREHEND: Implementing all original monster logic
1344c1621f GLK: COMPREHEND: Cleanup of eagle/mice random events
Commit: f3f32e073fd4b6acc4c2829594afc94329cb4988
https://github.com/scummvm/scummvm/commit/f3f32e073fd4b6acc4c2829594afc94329cb4988
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-13T15:37:28-07:00
Commit Message:
GLK: COMPREHEND: Remove unneeded FIXME from MOVE_TO_ROOM
The original's MOVE_TO_ROOM opcode simply uses FF as a room
number to skip changing rooms
Changed paths:
engines/glk/comprehend/game.cpp
diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index 7b968f9433..38ea406a56 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -597,17 +597,8 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
break;
case OPCODE_MOVE_TO_ROOM:
- if (instr->operand[0] == 0xff) {
- /*
- * FIXME - Not sure what this is for. Transylvania
- * uses it in the 'go north' case when in room
- * 0x01 or 0x0c, and Oo-Topos uses it when you shoot
- * the alien. Ignore it for now.
- */
- break;
- }
-
- move_to(instr->operand[0]);
+ if (instr->operand[0] != 0xff)
+ move_to(instr->operand[0]);
break;
case OPCODE_MOVE:
Commit: cf1f157f9f0cc198b5b2f5e991c7f7f6daf42ed7
https://github.com/scummvm/scummvm/commit/cf1f157f9f0cc198b5b2f5e991c7f7f6daf42ed7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-13T15:37:28-07:00
Commit Message:
GLK: COMPREHEND: Implement Game Over failure
Changed paths:
engines/glk/comprehend/game_tr.cpp
diff --git a/engines/glk/comprehend/game_tr.cpp b/engines/glk/comprehend/game_tr.cpp
index 3ce95c35b3..0d4e0b1b1f 100644
--- a/engines/glk/comprehend/game_tr.cpp
+++ b/engines/glk/comprehend/game_tr.cpp
@@ -114,42 +114,51 @@ bool TransylvaniaGame::beforeTurn() {
void TransylvaniaGame::handleSpecialOpcode(uint8 operand) {
switch (operand) {
- case 0x01:
+ case 1:
// FIXME: Called when the mice are dropped and the cat chases them.
break;
- case 0x02:
+ case 2:
// FIXME: Called when the gun is fired
break;
- case 0x06:
+ case 3:
+ case 4:
+ // Game over - failure
+ console_println(_strings2[138].c_str());
+ if (tolower(console_get_key()) == 'r')
+ game_restart();
+ else
+ g_comprehend->quitGame();
+ break;
+
+ case 0x05:
+ // Won the game
+ break;
+
+ case 6:
game_save();
break;
- case 0x07:
+ case 7:
game_restore();
break;
- case 0x03:
- // Game over - failure
- // fall through
- case 0x05:
- // Won the game
- // fall through
- case 0x08:
+ case 8:
// Restart game
game_restart();
break;
- case 0x09:
- /*
- * Show the Zin screen in reponse to doing 'sing some enchanted
- * evening' in his cabin.
- */
+ case 9:
+ // Show the Zin screen in reponse to doing
+ // 'sing some enchanted evening' in his cabin.
g_comprehend->drawLocationPicture(41);
console_get_key();
_updateFlags |= UPDATE_GRAPHICS;
break;
+
+ default:
+ break;
}
}
Commit: 2527b9760541d1e764ce1ed46338be719a83dfd3
https://github.com/scummvm/scummvm/commit/2527b9760541d1e764ce1ed46338be719a83dfd3
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-13T15:37:28-07:00
Commit Message:
GLK: COMPREHEND: Field renamings for Transylvania monsters
Changed paths:
engines/glk/adrift/scprotos.h
engines/glk/comprehend/game_tr.cpp
engines/glk/comprehend/game_tr.h
diff --git a/engines/glk/adrift/scprotos.h b/engines/glk/adrift/scprotos.h
index efd7bb2ed3..0a742b921f 100644
--- a/engines/glk/adrift/scprotos.h
+++ b/engines/glk/adrift/scprotos.h
@@ -315,22 +315,22 @@ extern void gs_set_object_seen(sc_gameref_t gs, sc_int object, sc_bool seen);
extern void gs_set_object_unmoved(sc_gameref_t gs,
sc_int object, sc_bool unmoved);
extern void gs_set_object_static_unmoved(sc_gameref_t gs,
- sc_int object, sc_bool unmoved);
+ sc_int _object, sc_bool unmoved);
extern sc_int gs_object_openness(sc_gameref_t gs, sc_int object);
-extern sc_int gs_object_state(sc_gameref_t gs, sc_int object);
-extern sc_bool gs_object_seen(sc_gameref_t gs, sc_int object);
-extern sc_bool gs_object_unmoved(sc_gameref_t gs, sc_int object);
-extern sc_bool gs_object_static_unmoved(sc_gameref_t gs, sc_int object);
-extern sc_int gs_object_position(sc_gameref_t gs, sc_int object);
-extern sc_int gs_object_parent(sc_gameref_t gs, sc_int object);
-extern void gs_object_move_onto(sc_gameref_t gs, sc_int object, sc_int onto);
-extern void gs_object_move_into(sc_gameref_t gs, sc_int object, sc_int into);
-extern void gs_object_make_hidden(sc_gameref_t gs, sc_int object);
-extern void gs_object_player_get(sc_gameref_t gs, sc_int object);
+extern sc_int gs_object_state(sc_gameref_t gs, sc_int _object);
+extern sc_bool gs_object_seen(sc_gameref_t gs, sc_int _object);
+extern sc_bool gs_object_unmoved(sc_gameref_t gs, sc_int _object);
+extern sc_bool gs_object_static_unmoved(sc_gameref_t gs, sc_int _object);
+extern sc_int gs_object_position(sc_gameref_t gs, sc_int _object);
+extern sc_int gs_object_parent(sc_gameref_t gs, sc_int _object);
+extern void gs_object_move_onto(sc_gameref_t gs, sc_int _object, sc_int onto);
+extern void gs_object_move_into(sc_gameref_t gs, sc_int _object, sc_int into);
+extern void gs_object_make_hidden(sc_gameref_t gs, sc_int _object);
+extern void gs_object_player_get(sc_gameref_t gs, sc_int _object);
extern void gs_object_npc_get(sc_gameref_t gs, sc_int object, sc_int npc);
extern void gs_object_player_wear(sc_gameref_t gs, sc_int object);
extern void gs_object_npc_wear(sc_gameref_t gs, sc_int object, sc_int npc);
-extern void gs_object_to_room(sc_gameref_t gs, sc_int object, sc_int room);
+extern void gs_object_to_room(sc_gameref_t gs, sc_int _object, sc_int room);
extern sc_int gs_npc_count(sc_gameref_t gs);
extern void gs_set_npc_location(sc_gameref_t gs, sc_int npc, sc_int _location);
extern sc_int gs_npc_location(sc_gameref_t gs, sc_int npc);
@@ -707,31 +707,31 @@ enum {
};
extern sc_bool obj_is_static(sc_gameref_t game, sc_int object);
-extern sc_bool obj_is_container(sc_gameref_t game, sc_int object);
+extern sc_bool obj_is_container(sc_gameref_t game, sc_int _object);
extern sc_bool obj_is_surface(sc_gameref_t game, sc_int object);
extern sc_int obj_container_object(sc_gameref_t game, sc_int n);
extern sc_int obj_surface_object(sc_gameref_t game, sc_int n);
extern sc_bool obj_indirectly_in_room(sc_gameref_t game,
- sc_int object, sc_int Room);
+ sc_int _object, sc_int Room);
extern sc_bool obj_indirectly_held_by_player(sc_gameref_t game, sc_int object);
extern sc_bool obj_directly_in_room(sc_gameref_t game,
- sc_int object, sc_int Room);
+ sc_int _object, sc_int Room);
extern sc_int obj_stateful_object(sc_gameref_t game, sc_int n);
extern sc_int obj_dynamic_object(sc_gameref_t game, sc_int n);
extern sc_int obj_wearable_object(sc_gameref_t game, sc_int n);
extern sc_int obj_standable_object(sc_gameref_t game, sc_int n);
extern sc_int obj_get_size(sc_gameref_t game, sc_int object);
-extern sc_int obj_get_weight(sc_gameref_t game, sc_int object);
+extern sc_int obj_get_weight(sc_gameref_t game, sc_int _object);
extern sc_int obj_get_player_size_limit(sc_gameref_t game);
extern sc_int obj_get_player_weight_limit(sc_gameref_t game);
extern sc_int obj_get_container_maxsize(sc_gameref_t game, sc_int object);
extern sc_int obj_get_container_capacity(sc_gameref_t game, sc_int object);
extern sc_int obj_lieable_object(sc_gameref_t game, sc_int n);
-extern sc_bool obj_appears_plural(sc_gameref_t game, sc_int object);
+extern sc_bool obj_appears_plural(sc_gameref_t game, sc_int _object);
extern void obj_setup_initial(sc_gameref_t game);
extern sc_int obj_container_index(sc_gameref_t game, sc_int object);
extern sc_int obj_surface_index(sc_gameref_t game, sc_int object);
-extern sc_int obj_stateful_index(sc_gameref_t game, sc_int object);
+extern sc_int obj_stateful_index(sc_gameref_t game, sc_int _object);
extern sc_char *obj_state_name(sc_gameref_t game, sc_int object);
extern sc_bool obj_shows_initial_description(sc_gameref_t game, sc_int object);
extern void obj_turn_update(sc_gameref_t game);
diff --git a/engines/glk/comprehend/game_tr.cpp b/engines/glk/comprehend/game_tr.cpp
index 0d4e0b1b1f..a787a4f77e 100644
--- a/engines/glk/comprehend/game_tr.cpp
+++ b/engines/glk/comprehend/game_tr.cpp
@@ -70,21 +70,21 @@ void TransylvaniaGame::updateMonster(const TransylvaniaMonster *monsterInfo) {
room = &_rooms[_currentRoom];
turn_count = _variables[VAR_TURN_COUNT];
- monster = get_item(monsterInfo->object);
+ monster = get_item(monsterInfo->_object);
if (monster->room == _currentRoom) {
// The monster is in the current room - leave it there
return;
}
- if ((room->flags & monsterInfo->room_allow_flag) &&
- !_flags[monsterInfo->dead_flag] &&
- turn_count > monsterInfo->min_turns_before) {
+ if ((room->flags & monsterInfo->_roomAllowFlag) &&
+ !_flags[monsterInfo->_deadFlag] &&
+ turn_count > monsterInfo->_minTurnsBefore) {
/*
* The monster is alive and allowed to move to the current
* room. Randomly decide whether on not to. If not, move
* it back to limbo.
*/
- if ((g_comprehend->getRandomNumber(0x7fffffff) % monsterInfo->randomness) == 0) {
+ if ((g_comprehend->getRandomNumber(0x7fffffff) % monsterInfo->_randomness) == 0) {
move_object(monster, _currentRoom);
_variables[0xf] = turn_count + 1;
} else {
diff --git a/engines/glk/comprehend/game_tr.h b/engines/glk/comprehend/game_tr.h
index 1de67d729e..e89db32dec 100644
--- a/engines/glk/comprehend/game_tr.h
+++ b/engines/glk/comprehend/game_tr.h
@@ -29,11 +29,11 @@ namespace Glk {
namespace Comprehend {
struct TransylvaniaMonster {
- uint8 object;
- uint8 dead_flag;
- unsigned min_turns_before;
- unsigned room_allow_flag;
- unsigned randomness;
+ uint8 _object;
+ uint8 _deadFlag;
+ unsigned _minTurnsBefore;
+ unsigned _roomAllowFlag;
+ unsigned _randomness;
};
class TransylvaniaGame : public ComprehendGame {
Commit: 82012b78d3c8eef48245abc41279cacc02aad6ed
https://github.com/scummvm/scummvm/commit/82012b78d3c8eef48245abc41279cacc02aad6ed
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-13T15:37:28-07:00
Commit Message:
GLK: COMPREHEND: Field renamings
Changed paths:
engines/glk/comprehend/debugger_dumper.cpp
engines/glk/comprehend/game.cpp
engines/glk/comprehend/game_data.cpp
engines/glk/comprehend/game_data.h
engines/glk/comprehend/game_oo.cpp
engines/glk/comprehend/game_tr.cpp
diff --git a/engines/glk/comprehend/debugger_dumper.cpp b/engines/glk/comprehend/debugger_dumper.cpp
index 2b9d0ab232..c234bb2af9 100644
--- a/engines/glk/comprehend/debugger_dumper.cpp
+++ b/engines/glk/comprehend/debugger_dumper.cpp
@@ -112,24 +112,24 @@ Common::String DebuggerDumper::dumpInstruction(ComprehendGame *game,
if (func_state)
line = Common::String::format("[or=%d,and=%d,test=%d,else=%d]",
- func_state->or_count, func_state->_and,
- func_state->test_result, func_state->else_result);
+ func_state->_orCount, func_state->_and,
+ func_state->_testResult, func_state->_elseResult);
opcode_map = game->_opcodeMap;
- opcode = opcode_map[instr->opcode];
+ opcode = opcode_map[instr->_opcode];
- line += Common::String::format(" [%.2x] ", instr->opcode);
+ line += Common::String::format(" [%.2x] ", instr->_opcode);
if (_opcodes.contains(opcode))
line += _opcodes[opcode];
else
line += "unknown";
- if (instr->nr_operands) {
+ if (instr->_nr_operands) {
line += "(";
- for (i = 0; i < instr->nr_operands; i++)
+ for (i = 0; i < instr->_nr_operands; i++)
line += Common::String::format("%.2x%s",
- instr->operand[i],
- i == (instr->nr_operands - 1) ? ")" : ", ");
+ instr->_operand[i],
+ i == (instr->_nr_operands - 1) ? ")" : ", ");
}
switch (opcode) {
@@ -139,18 +139,18 @@ Common::String DebuggerDumper::dumpInstruction(ComprehendGame *game,
case OPCODE_SET_OBJECT_LONG_DESCRIPTION:
if (opcode == OPCODE_PRINT) {
- str_index = instr->operand[0];
- str_table = instr->operand[1];
+ str_index = instr->_operand[0];
+ str_table = instr->_operand[1];
} else {
- str_index = instr->operand[1];
- str_table = instr->operand[2];
+ str_index = instr->_operand[1];
+ str_table = instr->_operand[2];
}
line += Common::String::format(" %s", game->instrStringLookup(str_index, str_table).c_str());
break;
case OPCODE_SET_STRING_REPLACEMENT:
- line += Common::String::format(" %s", game->_replaceWords[instr->operand[0] - 1].c_str());
+ line += Common::String::format(" %s", game->_replaceWords[instr->_operand[0] - 1].c_str());
break;
}
@@ -166,9 +166,9 @@ void DebuggerDumper::dumpFunctions() {
for (i = 0; i < _game->_functions.size(); i++) {
func = &_game->_functions[i];
- print("[%.4x] (%u instructions)\n", i, (uint)func->nr_instructions);
- for (j = 0; j < func->nr_instructions; j++) {
- Common::String line = dumpInstruction(_game, NULL, &func->instructions[j]);
+ print("[%.4x] (%u instructions)\n", i, (uint)func->_nr_instructions);
+ for (j = 0; j < func->_nr_instructions; j++) {
+ Common::String line = dumpInstruction(_game, NULL, &func->_instructions[j]);
print("%s", line.c_str());
}
print("\n");
@@ -186,8 +186,8 @@ void DebuggerDumper::dumpActionTable() {
print("(");
for (j = 0; j < 4; j++) {
- if (j < action->nr_words) {
- switch (action->word_type[j]) {
+ if (j < action->_nr_words) {
+ switch (action->_wordType[j]) {
case WORD_TYPE_VERB:
print("v");
break;
@@ -208,23 +208,23 @@ void DebuggerDumper::dumpActionTable() {
print(") [%.4x] ", i);
- for (j = 0; j < action->nr_words; j++)
+ for (j = 0; j < action->_nr_words; j++)
print("%.2x:%.2x ",
- action->word[j], action->word_type[j]);
+ action->_word[j], action->_wordType[j]);
print("| ");
- for (j = 0; j < action->nr_words; j++) {
- word = find_dict_word_by_index(_game, action->word[j],
- action->word_type[j]);
+ for (j = 0; j < action->_nr_words; j++) {
+ word = find_dict_word_by_index(_game, action->_word[j],
+ action->_wordType[j]);
if (word)
print("%-6s ", word->_word);
else
- print("%.2x:%.2x ", action->word[j],
- action->word_type[j]);
+ print("%.2x:%.2x ", action->_word[j],
+ action->_wordType[j]);
}
- print("-> %.4x\n", action->function);
+ print("-> %.4x\n", action->_function);
}
}
@@ -272,13 +272,13 @@ void DebuggerDumper::dumpWordMap() {
for (j = 0; j < 3; j++) {
word[j] = dict_find_word_by_index_type(
- _game, map->word[j].index, map->word[j].type);
+ _game, map->_word[j]._index, map->_word[j]._type);
if (word[j])
snprintf(str[j], sizeof(str[j]),
"%s", word[j]->_word);
else
snprintf(str[j], sizeof(str[j]), "%.2x:%.2x ",
- map->word[j].index, map->word[j].type);
+ map->_word[j]._index, map->_word[j]._type);
}
print(" [%.2x] %-6s %-6s -> %-6s\n",
@@ -296,18 +296,18 @@ void DebuggerDumper::dumpRooms() {
room = &_game->_rooms[i];
print(" [%.2x] flags=%.2x, graphic=%.2x\n",
- i, room->flags, room->graphic);
- print(" %s\n", _game->stringLookup(room->string_desc).c_str());
+ i, room->_flags, room->_graphic);
+ print(" %s\n", _game->stringLookup(room->_stringDesc).c_str());
print(" n: %.2x s: %.2x e: %.2x w: %.2x\n",
- room->direction[DIRECTION_NORTH],
- room->direction[DIRECTION_SOUTH],
- room->direction[DIRECTION_EAST],
- room->direction[DIRECTION_WEST]);
+ room->_direction[DIRECTION_NORTH],
+ room->_direction[DIRECTION_SOUTH],
+ room->_direction[DIRECTION_EAST],
+ room->_direction[DIRECTION_WEST]);
print(" u: %.2x d: %.2x i: %.2x o: %.2x\n",
- room->direction[DIRECTION_UP],
- room->direction[DIRECTION_DOWN],
- room->direction[DIRECTION_IN],
- room->direction[DIRECTION_OUT]);
+ room->_direction[DIRECTION_UP],
+ room->_direction[DIRECTION_DOWN],
+ room->_direction[DIRECTION_IN],
+ room->_direction[DIRECTION_OUT]);
print("\n");
}
}
@@ -321,22 +321,22 @@ void DebuggerDumper::dumpItems() {
item = &_game->_items[i];
print(" [%.2x] %s\n", i + 1,
- item->string_desc ? _game->stringLookup(item->string_desc).c_str() : "");
+ item->_stringDesc ? _game->stringLookup(item->_stringDesc).c_str() : "");
if (_game->_comprehendVersion == 2)
print(" long desc: %s\n",
- _game->stringLookup(item->long_string).c_str());
+ _game->stringLookup(item->_longString).c_str());
print(" words: ");
for (j = 0; j < _game->_nr_words; j++)
- if (_game->_words[j]._index == item->word &&
+ if (_game->_words[j]._index == item->_word &&
(_game->_words[j]._type & WORD_TYPE_NOUN_MASK))
print("%s ", _game->_words[j]._word);
print("\n");
print(" flags=%.2x (takeable=%d, weight=%d)\n",
- item->flags, !!(item->flags & ITEMF_CAN_TAKE),
- (item->flags & ITEMF_WEIGHT_MASK));
+ item->_flags, !!(item->_flags & ITEMF_CAN_TAKE),
+ (item->_flags & ITEMF_WEIGHT_MASK));
print(" room=%.2x, graphic=%.2x\n",
- item->room, item->graphic);
+ item->_room, item->_graphic);
print("\n");
}
}
diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index 38ea406a56..3f55b7f74a 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -78,12 +78,12 @@ void ComprehendGame::synchronizeSave(Common::Serializer &s) {
assert(nr_rooms == _rooms.size());
for (i = 1; i < _rooms.size(); ++i) {
- s.syncAsUint16LE(_rooms[i].string_desc);
+ s.syncAsUint16LE(_rooms[i]._stringDesc);
for (dir = 0; dir < NR_DIRECTIONS; dir++)
- s.syncAsByte(_rooms[i].direction[dir]);
+ s.syncAsByte(_rooms[i]._direction[dir]);
- s.syncAsByte(_rooms[i].flags);
- s.syncAsByte(_rooms[i].graphic);
+ s.syncAsByte(_rooms[i]._flags);
+ s.syncAsByte(_rooms[i]._graphic);
}
// Objects
@@ -298,11 +298,11 @@ WordIndex *ComprehendGame::is_word_pair(Word *word1, Word *word2) {
for (i = 0; i < _wordMaps.size(); i++) {
map = &_wordMaps[i];
- if (map->word[0].index == word1->_index &&
- map->word[0].type == word1->_type &&
- map->word[1].index == word2->_index &&
- map->word[1].type == word2->_type)
- return &map->word[2];
+ if (map->_word[0]._index == word1->_index &&
+ map->_word[0]._type == word1->_type &&
+ map->_word[1]._index == word2->_index &&
+ map->_word[1]._type == word2->_type)
+ return &map->_word[2];
}
return nullptr;
@@ -320,7 +320,7 @@ Item *ComprehendGame::get_item_by_noun(Word *noun) {
* to drop the latter because this will match the former.
*/
for (i = 0; i < _items.size(); i++)
- if (_items[i].word == noun->_index)
+ if (_items[i]._word == noun->_index)
return &_items[i];
return NULL;
@@ -351,7 +351,7 @@ void ComprehendGame::update_graphics() {
default:
if (_updateFlags & UPDATE_GRAPHICS) {
room = get_room(_currentRoom);
- g_comprehend->drawLocationPicture(room->graphic - 1);
+ g_comprehend->drawLocationPicture(room->_graphic - 1);
}
if ((_updateFlags & UPDATE_GRAPHICS) ||
@@ -359,9 +359,9 @@ void ComprehendGame::update_graphics() {
for (i = 0; i < _items.size(); i++) {
item = &_items[i];
- if (item->room == _currentRoom &&
- item->graphic != 0)
- g_comprehend->drawItemPicture(item->graphic - 1);
+ if (item->_room == _currentRoom &&
+ item->_graphic != 0)
+ g_comprehend->drawItemPicture(item->_graphic - 1);
}
}
break;
@@ -376,8 +376,8 @@ void ComprehendGame::describe_objects_in_current_room() {
for (i = 0; i < _items.size(); i++) {
item = &_items[i];
- if (item->room == _currentRoom &&
- item->string_desc != 0)
+ if (item->_room == _currentRoom &&
+ item->_stringDesc != 0)
count++;
}
@@ -387,9 +387,9 @@ void ComprehendGame::describe_objects_in_current_room() {
for (i = 0; i < _items.size(); i++) {
item = &_items[i];
- if (item->room == _currentRoom &&
- item->string_desc != 0)
- console_println(stringLookup(item->string_desc).c_str());
+ if (item->_room == _currentRoom &&
+ item->_stringDesc != 0)
+ console_println(stringLookup(item->_stringDesc).c_str());
}
}
}
@@ -401,7 +401,7 @@ void ComprehendGame::update() {
update_graphics();
/* Check if the room is special (dark, too bright, etc) */
- room_desc_string = room->string_desc;
+ room_desc_string = room->_stringDesc;
room_type = roomIsSpecial(_currentRoom,
&room_desc_string);
@@ -427,20 +427,20 @@ void ComprehendGame::move_to(uint8 room) {
}
void ComprehendGame::func_set_test_result(FunctionState *func_state, bool value) {
- if (func_state->or_count == 0) {
+ if (func_state->_orCount == 0) {
/* And */
if (func_state->_and) {
if (!value)
- func_state->test_result = false;
+ func_state->_testResult = false;
} else {
- func_state->test_result = value;
+ func_state->_testResult = value;
func_state->_and = true;
}
} else {
/* Or */
if (value)
- func_state->test_result = value;
+ func_state->_testResult = value;
}
}
@@ -448,19 +448,19 @@ size_t ComprehendGame::num_objects_in_room(int room) {
size_t count = 0, i;
for (i = 0; i < _items.size(); i++)
- if (_items[i].room == room)
+ if (_items[i]._room == room)
count++;
return count;
}
void ComprehendGame::move_object(Item *item, int new_room) {
- unsigned obj_weight = item->flags & ITEMF_WEIGHT_MASK;
+ unsigned obj_weight = item->_flags & ITEMF_WEIGHT_MASK;
- if (item->room == new_room)
+ if (item->_room == new_room)
return;
- if (item->room == ROOM_INVENTORY) {
+ if (item->_room == ROOM_INVENTORY) {
/* Removed from player's inventory */
_variables[VAR_INVENTORY_WEIGHT] -= obj_weight;
}
@@ -469,7 +469,7 @@ void ComprehendGame::move_object(Item *item, int new_room) {
_variables[VAR_INVENTORY_WEIGHT] += obj_weight;
}
- if (item->room == _currentRoom) {
+ if (item->_room == _currentRoom) {
/* Item moved away from the current room */
_updateFlags |= UPDATE_GRAPHICS;
@@ -482,7 +482,7 @@ void ComprehendGame::move_object(Item *item, int new_room) {
UPDATE_ITEM_LIST);
}
- item->room = new_room;
+ item->_room = new_room;
}
void ComprehendGame::eval_instruction(FunctionState *func_state,
@@ -499,10 +499,10 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
if (DebugMan.isDebugChannelEnabled(kDebugScripts)) {
Common::String line;
- if (!instr->is_command) {
+ if (!instr->_isCommand) {
line += "? ";
} else {
- if (func_state->test_result)
+ if (func_state->_testResult)
line += "+ ";
else
line += "- ";
@@ -512,58 +512,58 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
debugC(kDebugScripts, "%s", line.c_str());
}
- if (func_state->or_count)
- func_state->or_count--;
+ if (func_state->_orCount)
+ func_state->_orCount--;
- if (instr->is_command) {
+ if (instr->_isCommand) {
bool do_command;
- func_state->in_command = true;
- do_command = func_state->test_result;
+ func_state->_inCommand = true;
+ do_command = func_state->_testResult;
- if (func_state->or_count != 0)
+ if (func_state->_orCount != 0)
g_comprehend->print("Warning: or_count == %d\n",
- func_state->or_count);
- func_state->or_count = 0;
+ func_state->_orCount);
+ func_state->_orCount = 0;
if (!do_command)
return;
- func_state->else_result = false;
- func_state->executed = true;
+ func_state->_elseResult = false;
+ func_state->_executed = true;
} else {
- if (func_state->in_command) {
+ if (func_state->_inCommand) {
/* Finished command sequence - clear test result */
- func_state->in_command = false;
- func_state->test_result = false;
+ func_state->_inCommand = false;
+ func_state->_testResult = false;
func_state->_and = false;
}
}
- switch (opcode_map[instr->opcode]) {
+ switch (opcode_map[instr->_opcode]) {
case OPCODE_VAR_ADD:
- _variables[instr->operand[0]] +=
- _variables[instr->operand[1]];
+ _variables[instr->_operand[0]] +=
+ _variables[instr->_operand[1]];
break;
case OPCODE_VAR_SUB:
- _variables[instr->operand[0]] -=
- _variables[instr->operand[1]];
+ _variables[instr->_operand[0]] -=
+ _variables[instr->_operand[1]];
break;
case OPCODE_VAR_INC:
- _variables[instr->operand[0]]++;
+ _variables[instr->_operand[0]]++;
break;
case OPCODE_VAR_DEC:
- _variables[instr->operand[0]]--;
+ _variables[instr->_operand[0]]--;
break;
case OPCODE_VAR_EQ:
func_set_test_result(func_state,
- _variables[instr->operand[0]] ==
- _variables[instr->operand[1]]);
+ _variables[instr->_operand[0]] ==
+ _variables[instr->_operand[1]]);
break;
case OPCODE_TURN_TICK:
@@ -572,33 +572,33 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
case OPCODE_PRINT:
console_println(instrStringLookup(
- instr->operand[0], instr->operand[1])
+ instr->_operand[0], instr->_operand[1])
.c_str());
break;
case OPCODE_TEST_NOT_ROOM_FLAG:
func_set_test_result(func_state,
- !(room->flags & instr->operand[0]));
+ !(room->_flags & instr->_operand[0]));
break;
case OPCODE_TEST_ROOM_FLAG:
func_set_test_result(func_state,
- room->flags & instr->operand[0]);
+ room->_flags & instr->_operand[0]);
break;
case OPCODE_NOT_IN_ROOM:
func_set_test_result(func_state,
- _currentRoom != instr->operand[0]);
+ _currentRoom != instr->_operand[0]);
break;
case OPCODE_IN_ROOM:
func_set_test_result(func_state,
- _currentRoom == instr->operand[0]);
+ _currentRoom == instr->_operand[0]);
break;
case OPCODE_MOVE_TO_ROOM:
- if (instr->operand[0] != 0xff)
- move_to(instr->operand[0]);
+ if (instr->_operand[0] != 0xff)
+ move_to(instr->_operand[0]);
break;
case OPCODE_MOVE:
@@ -607,50 +607,50 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
error("Bad verb %d:%d in move",
verb->_index, verb->_type);
- if (room->direction[verb->_index - 1])
- move_to(room->direction[verb->_index - 1]);
+ if (room->_direction[verb->_index - 1])
+ move_to(room->_direction[verb->_index - 1]);
else
console_println(stringLookup(STRING_CANT_GO).c_str());
break;
case OPCODE_MOVE_DIRECTION:
- if (room->direction[instr->operand[0] - 1])
- move_to(room->direction[instr->operand[0] - 1]);
+ if (room->_direction[instr->_operand[0] - 1])
+ move_to(room->_direction[instr->_operand[0] - 1]);
else
console_println(stringLookup(STRING_CANT_GO).c_str());
break;
case OPCODE_ELSE:
- func_state->test_result = func_state->else_result;
+ func_state->_testResult = func_state->_elseResult;
break;
case OPCODE_MOVE_OBJECT_TO_CURRENT_ROOM:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
move_object(item, _currentRoom);
break;
case OPCODE_OBJECT_IN_ROOM:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
func_set_test_result(func_state,
- item->room == instr->operand[1]);
+ item->_room == instr->_operand[1]);
break;
case OPCODE_OBJECT_NOT_IN_ROOM:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
func_set_test_result(func_state,
- item->room != instr->operand[1]);
+ item->_room != instr->_operand[1]);
break;
case OPCODE_MOVE_OBJECT_TO_ROOM:
- item = get_item(instr->operand[0] - 1);
- move_object(item, instr->operand[1]);
+ item = get_item(instr->_operand[0] - 1);
+ move_object(item, instr->_operand[1]);
break;
case OPCODE_INVENTORY_FULL:
item = get_item_by_noun(noun);
func_set_test_result(func_state,
_variables[VAR_INVENTORY_WEIGHT] +
- (item->flags & ITEMF_WEIGHT_MASK) >
+ (item->_flags & ITEMF_WEIGHT_MASK) >
_variables[VAR_INVENTORY_LIMIT]);
break;
@@ -660,7 +660,7 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
* FIXME - unsure what the single operand is for.
*/
item = get_item_by_noun(noun);
- g_comprehend->print("%s\n", stringLookup(item->long_string).c_str());
+ g_comprehend->print("%s\n", stringLookup(item->_longString).c_str());
break;
case OPCODE_CURRENT_OBJECT_IN_ROOM:
@@ -671,8 +671,8 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
for (i = 0; i < _items.size(); i++) {
Item *itemP = &_items[i];
- if (itemP->word == noun->_index &&
- itemP->room == instr->operand[0]) {
+ if (itemP->_word == noun->_index &&
+ itemP->_room == instr->_operand[0]) {
test = true;
break;
}
@@ -687,7 +687,7 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
item = get_item_by_noun(noun);
if (item)
func_set_test_result(func_state,
- item->room != _currentRoom);
+ item->_room != _currentRoom);
else
func_set_test_result(func_state, true);
break;
@@ -696,33 +696,33 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
item = get_item_by_noun(noun);
if (item)
func_set_test_result(func_state,
- item->room == _currentRoom);
+ item->_room == _currentRoom);
else
func_set_test_result(func_state, false);
break;
case OPCODE_HAVE_OBJECT:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
func_set_test_result(func_state,
- item->room == ROOM_INVENTORY);
+ item->_room == ROOM_INVENTORY);
break;
case OPCODE_NOT_HAVE_CURRENT_OBJECT:
item = get_item_by_noun(noun);
func_set_test_result(func_state,
- !item || item->room != ROOM_INVENTORY);
+ !item || item->_room != ROOM_INVENTORY);
break;
case OPCODE_HAVE_CURRENT_OBJECT:
item = get_item_by_noun(noun);
func_set_test_result(func_state,
- item->room == ROOM_INVENTORY);
+ item->_room == ROOM_INVENTORY);
break;
case OPCODE_NOT_HAVE_OBJECT:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
func_set_test_result(func_state,
- item->room != ROOM_INVENTORY);
+ item->_room != ROOM_INVENTORY);
break;
case OPCODE_CURRENT_OBJECT_TAKEABLE:
@@ -731,7 +731,7 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
func_set_test_result(func_state, false);
else
func_set_test_result(func_state,
- (item->flags & ITEMF_CAN_TAKE));
+ (item->_flags & ITEMF_CAN_TAKE));
break;
case OPCODE_CURRENT_OBJECT_NOT_TAKEABLE:
@@ -740,7 +740,7 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
func_set_test_result(func_state, true);
else
func_set_test_result(func_state,
- !(item->flags & ITEMF_CAN_TAKE));
+ !(item->_flags & ITEMF_CAN_TAKE));
break;
case OPCODE_CURRENT_OBJECT_IS_NOWHERE:
@@ -749,31 +749,31 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
func_set_test_result(func_state, false);
else
func_set_test_result(func_state,
- item->room == ROOM_NOWHERE);
+ item->_room == ROOM_NOWHERE);
break;
case OPCODE_OBJECT_IS_NOWHERE:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
func_set_test_result(func_state,
- item->room == ROOM_NOWHERE);
+ item->_room == ROOM_NOWHERE);
break;
case OPCODE_OBJECT_IS_NOT_NOWHERE:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
func_set_test_result(func_state,
- item->room != ROOM_NOWHERE);
+ item->_room != ROOM_NOWHERE);
break;
case OPCODE_OBJECT_NOT_PRESENT:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
func_set_test_result(func_state,
- item->room != _currentRoom);
+ item->_room != _currentRoom);
break;
case OPCODE_OBJECT_PRESENT:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
func_set_test_result(func_state,
- item->room == _currentRoom);
+ item->_room == _currentRoom);
break;
case OPCODE_OBJECT_NOT_VALID:
@@ -793,7 +793,7 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
break;
case OPCODE_REMOVE_OBJECT:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
move_object(item, ROOM_NOWHERE);
break;
@@ -812,25 +812,25 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
console_println(stringLookup(STRING_INVENTORY).c_str());
for (i = 0; i < _items.size(); i++) {
item = &_items[i];
- if (item->room == ROOM_INVENTORY)
+ if (item->_room == ROOM_INVENTORY)
g_comprehend->print("%s\n",
- stringLookup(item->string_desc).c_str());
+ stringLookup(item->_stringDesc).c_str());
}
break;
case OPCODE_INVENTORY_ROOM:
- count = num_objects_in_room(instr->operand[0]);
+ count = num_objects_in_room(instr->_operand[0]);
if (count == 0) {
- console_println(stringLookup(instr->operand[1] + 1).c_str());
+ console_println(stringLookup(instr->_operand[1] + 1).c_str());
break;
}
- console_println(stringLookup(instr->operand[1]).c_str());
+ console_println(stringLookup(instr->_operand[1]).c_str());
for (i = 0; i < _items.size(); i++) {
item = &_items[i];
- if (item->room == instr->operand[0])
+ if (item->_room == instr->_operand[0])
g_comprehend->print("%s\n",
- stringLookup(item->string_desc).c_str());
+ stringLookup(item->_stringDesc).c_str());
}
break;
@@ -839,11 +839,11 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
if (!item)
error("Bad current object\n");
- move_object(item, instr->operand[0]);
+ move_object(item, instr->_operand[0]);
break;
case OPCODE_DROP_OBJECT:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
move_object(item, _currentRoom);
break;
@@ -864,83 +864,83 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
break;
case OPCODE_TAKE_OBJECT:
- item = get_item(instr->operand[0] - 1);
+ item = get_item(instr->_operand[0] - 1);
move_object(item, ROOM_INVENTORY);
break;
case OPCODE_TEST_FLAG:
func_set_test_result(func_state,
- _flags[instr->operand[0]]);
+ _flags[instr->_operand[0]]);
break;
case OPCODE_TEST_NOT_FLAG:
func_set_test_result(func_state,
- !_flags[instr->operand[0]]);
+ !_flags[instr->_operand[0]]);
break;
case OPCODE_CLEAR_FLAG:
- _flags[instr->operand[0]] = false;
+ _flags[instr->_operand[0]] = false;
break;
case OPCODE_SET_FLAG:
- _flags[instr->operand[0]] = true;
+ _flags[instr->_operand[0]] = true;
break;
case OPCODE_OR:
- if (func_state->or_count) {
- func_state->or_count += 2;
+ if (func_state->_orCount) {
+ func_state->_orCount += 2;
} else {
- func_state->test_result = false;
- func_state->or_count += 3;
+ func_state->_testResult = false;
+ func_state->_orCount += 3;
}
break;
case OPCODE_SET_OBJECT_DESCRIPTION:
- item = get_item(instr->operand[0] - 1);
- item->string_desc = (instr->operand[2] << 8) | instr->operand[1];
+ item = get_item(instr->_operand[0] - 1);
+ item->_stringDesc = (instr->_operand[2] << 8) | instr->_operand[1];
break;
case OPCODE_SET_OBJECT_LONG_DESCRIPTION:
- item = get_item(instr->operand[0] - 1);
- item->long_string = (instr->operand[2] << 8) | instr->operand[1];
+ item = get_item(instr->_operand[0] - 1);
+ item->_longString = (instr->_operand[2] << 8) | instr->_operand[1];
break;
case OPCODE_SET_ROOM_DESCRIPTION:
- room = get_room(instr->operand[0]);
- switch (instr->operand[2]) {
+ room = get_room(instr->_operand[0]);
+ switch (instr->_operand[2]) {
case 0x80:
- room->string_desc = instr->operand[1];
+ room->_stringDesc = instr->_operand[1];
break;
case 0x81:
- room->string_desc = instr->operand[1] + 0x100;
+ room->_stringDesc = instr->_operand[1] + 0x100;
break;
case 0x82:
- room->string_desc = instr->operand[1] + 0x200;
+ room->_stringDesc = instr->_operand[1] + 0x200;
break;
default:
error("Bad string desc %.2x:%.2x\n",
- instr->operand[1], instr->operand[2]);
+ instr->_operand[1], instr->_operand[2]);
break;
}
break;
case OPCODE_SET_OBJECT_GRAPHIC:
- item = get_item(instr->operand[0] - 1);
- item->graphic = instr->operand[1];
- if (item->room == _currentRoom)
+ item = get_item(instr->_operand[0] - 1);
+ item->_graphic = instr->_operand[1];
+ if (item->_room == _currentRoom)
_updateFlags |= UPDATE_GRAPHICS;
break;
case OPCODE_SET_ROOM_GRAPHIC:
- room = get_room(instr->operand[0]);
- room->graphic = instr->operand[1];
- if (instr->operand[0] == _currentRoom)
+ room = get_room(instr->_operand[0]);
+ room->_graphic = instr->_operand[1];
+ if (instr->_operand[0] == _currentRoom)
_updateFlags |= UPDATE_GRAPHICS;
break;
case OPCODE_CALL_FUNC:
- index = instr->operand[0];
- if (instr->operand[1] == 0x81)
+ index = instr->_operand[0];
+ if (instr->_operand[1] == 0x81)
index += 256;
if (index >= _functions.size())
error("Bad function %.4x >= %.4x\n",
@@ -974,7 +974,7 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
break;
case OPCODE_SET_STRING_REPLACEMENT:
- _currentReplaceWord = instr->operand[0] - 1;
+ _currentReplaceWord = instr->_operand[0] - 1;
break;
case OPCODE_SET_CURRENT_NOUN_STRING_REPLACEMENT:
@@ -993,11 +993,11 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
break;
case OPCODE_DRAW_ROOM:
- g_comprehend->drawLocationPicture(instr->operand[0] - 1);
+ g_comprehend->drawLocationPicture(instr->_operand[0] - 1);
break;
case OPCODE_DRAW_OBJECT:
- g_comprehend->drawItemPicture(instr->operand[0] - 1);
+ g_comprehend->drawItemPicture(instr->_operand[0] - 1);
break;
case OPCODE_WAIT_KEY:
@@ -1006,18 +1006,18 @@ void ComprehendGame::eval_instruction(FunctionState *func_state,
case OPCODE_SPECIAL:
/* Game specific opcode */
- handleSpecialOpcode(instr->operand[0]);
+ handleSpecialOpcode(instr->_operand[0]);
break;
default:
- if (instr->opcode & 0x80) {
+ if (instr->_opcode & 0x80) {
debugC(kDebugScripts,
"Unhandled command opcode %.2x",
- instr->opcode);
+ instr->_opcode);
} else {
debugC(kDebugScripts,
"Unhandled test opcode %.2x - returning false",
- instr->opcode);
+ instr->_opcode);
func_set_test_result(func_state, false);
}
break;
@@ -1029,11 +1029,11 @@ void ComprehendGame::eval_function(Function *func,
FunctionState func_state;
uint i;
- func_state.else_result = true;
- func_state.executed = false;
+ func_state._elseResult = true;
+ func_state._executed = false;
- for (i = 0; i < func->nr_instructions; i++) {
- if (func_state.executed && !func->instructions[i].is_command) {
+ for (i = 0; i < func->_nr_instructions; i++) {
+ if (func_state._executed && !func->_instructions[i]._isCommand) {
/*
* At least one command has been executed and the
* current instruction is a test. Exit the function.
@@ -1041,7 +1041,7 @@ void ComprehendGame::eval_function(Function *func,
break;
}
- eval_instruction(&func_state, &func->instructions[i],
+ eval_instruction(&func_state, &func->_instructions[i],
verb, noun);
}
}
@@ -1073,28 +1073,28 @@ bool ComprehendGame::handle_sentence(Sentence *sentence) {
for (i = 0; i < _actions.size(); i++) {
action = &_actions[i];
- if (action->type == ACTION_VERB_OPT_NOUN &&
- sentence->_nr_words > action->nr_words + 1)
+ if (action->_type == ACTION_VERB_OPT_NOUN &&
+ sentence->_nr_words > action->_nr_words + 1)
continue;
- if (action->type != ACTION_VERB_OPT_NOUN &&
- sentence->_nr_words != action->nr_words)
+ if (action->_type != ACTION_VERB_OPT_NOUN &&
+ sentence->_nr_words != action->_nr_words)
continue;
/*
* If all words in a sentence match those for an action then
* run that action's function.
*/
- for (j = 0; j < action->nr_words; j++) {
- if (sentence->_words[j]._index == action->word[j] &&
- (sentence->_words[j]._type & action->word_type[j]))
+ for (j = 0; j < action->_nr_words; j++) {
+ if (sentence->_words[j]._index == action->_word[j] &&
+ (sentence->_words[j]._type & action->_wordType[j]))
continue;
/* Word didn't match */
break;
}
- if (j == action->nr_words) {
+ if (j == action->_nr_words) {
/* Match */
- func = &_functions[action->function];
+ func = &_functions[action->_function];
eval_function(func,
&sentence->_words[0], &sentence->_words[1]);
return true;
@@ -1147,8 +1147,8 @@ void ComprehendGame::read_sentence(char **line,
pair = is_word_pair(&sentence->_words[index - 2],
&sentence->_words[index - 1]);
if (pair) {
- sentence->_words[index - 2]._index = pair->index;
- sentence->_words[index - 2]._type = pair->type;
+ sentence->_words[index - 2]._index = pair->_index;
+ sentence->_words[index - 2]._type = pair->_type;
strcpy(sentence->_words[index - 2]._word,
"[PAIR]");
sentence->_nr_words--;
diff --git a/engines/glk/comprehend/game_data.cpp b/engines/glk/comprehend/game_data.cpp
index 0de5ebc00a..73fb3b595b 100644
--- a/engines/glk/comprehend/game_data.cpp
+++ b/engines/glk/comprehend/game_data.cpp
@@ -35,41 +35,41 @@ static const char CHARSET[] = "..abcdefghijklmnopqrstuvwxyz .";
static const char SPECIAL_CHARSET[] = "[]\n!\"#$%&'(),-/0123456789:;?<>";
void FunctionState::clear() {
- test_result = true;
- else_result = false;
- or_count = 0;
+ _testResult = true;
+ _elseResult = false;
+ _orCount = 0;
_and = false;
- in_command = false;
- executed = false;
+ _inCommand = false;
+ _executed = false;
}
/*-------------------------------------------------------*/
void Room::clear() {
- flags = 0;
- graphic = 0;
- string_desc = 0;
- Common::fill(&direction[0], &direction[NR_DIRECTIONS], 0);
+ _flags = 0;
+ _graphic = 0;
+ _stringDesc = 0;
+ Common::fill(&_direction[0], &_direction[NR_DIRECTIONS], 0);
}
/*-------------------------------------------------------*/
void Item::clear() {
- string_desc = 0;
- long_string = 0;
- room = 0;
- flags = 0;
- word = 0;
- graphic = 0;
+ _stringDesc = 0;
+ _longString = 0;
+ _room = 0;
+ _flags = 0;
+ _word = 0;
+ _graphic = 0;
}
void Item::synchronize(Common::Serializer &s) {
- s.syncAsUint16LE(string_desc);
- s.syncAsUint16LE(long_string);
- s.syncAsByte(room);
- s.syncAsByte(flags);
- s.syncAsByte(word);
- s.syncAsByte(graphic);
+ s.syncAsUint16LE(_stringDesc);
+ s.syncAsUint16LE(_longString);
+ s.syncAsByte(_room);
+ s.syncAsByte(_flags);
+ s.syncAsByte(_word);
+ s.syncAsByte(_graphic);
}
/*-------------------------------------------------------*/
@@ -95,36 +95,36 @@ void Word::load(FileBuffer *fb) {
/*-------------------------------------------------------*/
void WordMap::clear() {
- flags = 0;
+ _flags = 0;
for (int idx = 0; idx < 3; ++idx)
- word[idx].clear();
+ _word[idx].clear();
}
/*-------------------------------------------------------*/
void Action::clear() {
- type = 0;
- nr_words = 0;
- function = 0;
- Common::fill(&word[0], &word[4], 0);
- Common::fill(&word_type[0], &word_type[4], 0);
+ _type = 0;
+ _nr_words = 0;
+ _function = 0;
+ Common::fill(&_word[0], &_word[4], 0);
+ Common::fill(&_wordType[0], &_wordType[4], 0);
}
/*-------------------------------------------------------*/
void Instruction::clear() {
- opcode = 0;
- nr_operands = 0;
- is_command = false;
- Common::fill(&operand[0], &operand[3], 0);
+ _opcode = 0;
+ _nr_operands = 0;
+ _isCommand = false;
+ Common::fill(&_operand[0], &_operand[3], 0);
}
/*-------------------------------------------------------*/
void Function::clear() {
- nr_instructions = 0;
+ _nr_instructions = 0;
for (int idx = 0; idx < 0x100; ++idx)
- instructions[idx].clear();
+ _instructions[idx].clear();
}
/*-------------------------------------------------------*/
@@ -193,16 +193,16 @@ uint8 GameData::parse_vm_instruction(FileBuffer *fb,
uint i;
/* Get the opcode */
- instr->opcode = fb->readByte();
- instr->nr_operands = opcode_nr_operands(instr->opcode);
+ instr->_opcode = fb->readByte();
+ instr->_nr_operands = opcode_nr_operands(instr->_opcode);
/* Get the operands */
- for (i = 0; i < instr->nr_operands; i++)
- instr->operand[i] = fb->readByte();
+ for (i = 0; i < instr->_nr_operands; i++)
+ instr->_operand[i] = fb->readByte();
- instr->is_command = opcode_is_command(instr->opcode);
+ instr->_isCommand = opcode_is_command(instr->_opcode);
- return instr->opcode;
+ return instr->_opcode;
}
void GameData::parse_function(FileBuffer *fb, Function *func) {
@@ -215,14 +215,14 @@ void GameData::parse_function(FileBuffer *fb, Function *func) {
error("bad function @ %.4x", fb->pos());
while (1) {
- instruction = &func->instructions[func->nr_instructions];
+ instruction = &func->_instructions[func->_nr_instructions];
opcode = parse_vm_instruction(fb, instruction);
if (opcode == 0)
break;
- func->nr_instructions++;
- if (func->nr_instructions >= ARRAY_SIZE(func->instructions))
+ func->_nr_instructions++;
+ if (func->_nr_instructions >= ARRAY_SIZE(func->_instructions))
error("Function has too many instructions");
}
}
@@ -234,7 +234,7 @@ void GameData::parse_vm(FileBuffer *fb) {
Function func;
parse_function(fb, &func);
- if (func.nr_instructions == 0)
+ if (func._nr_instructions == 0)
break;
_functions.push_back(func);
@@ -264,19 +264,19 @@ void GameData::parse_action_table_vvnn(FileBuffer *fb) {
for (i = 0; i < count; i++) {
Action action;
- action.type = ACTION_VERB_VERB_NOUN_NOUN;
+ action._type = ACTION_VERB_VERB_NOUN_NOUN;
- action.nr_words = 4;
- action.word_type[0] = WORD_TYPE_VERB;
- action.word_type[1] = WORD_TYPE_VERB;
- action.word_type[2] = WORD_TYPE_NOUN_MASK;
- action.word_type[3] = WORD_TYPE_NOUN_MASK;
+ action._nr_words = 4;
+ action._wordType[0] = WORD_TYPE_VERB;
+ action._wordType[1] = WORD_TYPE_VERB;
+ action._wordType[2] = WORD_TYPE_NOUN_MASK;
+ action._wordType[3] = WORD_TYPE_NOUN_MASK;
- action.word[0] = verb;
+ action._word[0] = verb;
for (j = 0; j < 3; j++)
- action.word[j + 1] = fb->readByte();
- action.function = fb->readUint16LE();
+ action._word[j + 1] = fb->readByte();
+ action._function = fb->readUint16LE();
_actions.push_back(action);
}
@@ -306,20 +306,20 @@ void GameData::parse_action_table_vnjn(FileBuffer *fb) {
for (i = 0; i < count; i++) {
Action action;
- action.type = ACTION_VERB_NOUN_JOIN_NOUN;
+ action._type = ACTION_VERB_NOUN_JOIN_NOUN;
- action.nr_words = 4;
- action.word_type[0] = WORD_TYPE_VERB;
- action.word_type[1] = WORD_TYPE_NOUN_MASK;
- action.word_type[2] = WORD_TYPE_JOIN;
- action.word_type[3] = WORD_TYPE_NOUN_MASK;
+ action._nr_words = 4;
+ action._wordType[0] = WORD_TYPE_VERB;
+ action._wordType[1] = WORD_TYPE_NOUN_MASK;
+ action._wordType[2] = WORD_TYPE_JOIN;
+ action._wordType[3] = WORD_TYPE_NOUN_MASK;
- action.word[2] = join;
+ action._word[2] = join;
- action.word[0] = fb->readByte();
- action.word[1] = fb->readByte();
- action.word[3] = fb->readByte();
- action.function = fb->readUint16LE();
+ action._word[0] = fb->readByte();
+ action._word[1] = fb->readByte();
+ action._word[3] = fb->readByte();
+ action._function = fb->readUint16LE();
_actions.push_back(action);
}
@@ -348,17 +348,17 @@ void GameData::parse_action_table_vjn(FileBuffer *fb) {
for (i = 0; i < count; i++) {
Action action;
- action.type = ACTION_VERB_JOIN_NOUN;
- action.word[1] = join;
+ action._type = ACTION_VERB_JOIN_NOUN;
+ action._word[1] = join;
- action.nr_words = 3;
- action.word_type[0] = WORD_TYPE_VERB;
- action.word_type[1] = WORD_TYPE_JOIN;
- action.word_type[2] = WORD_TYPE_NOUN_MASK;
+ action._nr_words = 3;
+ action._wordType[0] = WORD_TYPE_VERB;
+ action._wordType[1] = WORD_TYPE_JOIN;
+ action._wordType[2] = WORD_TYPE_NOUN_MASK;
- action.word[0] = fb->readByte();
- action.word[2] = fb->readByte();
- action.function = fb->readUint16LE();
+ action._word[0] = fb->readByte();
+ action._word[2] = fb->readByte();
+ action._function = fb->readUint16LE();
_actions.push_back(action);
}
@@ -387,17 +387,17 @@ void GameData::parse_action_table_vdn(FileBuffer *fb) {
for (i = 0; i < count; i++) {
Action action;
- action.type = ACTION_VERB_JOIN_NOUN;
- action.word[0] = verb;
+ action._type = ACTION_VERB_JOIN_NOUN;
+ action._word[0] = verb;
- action.nr_words = 3;
- action.word_type[0] = WORD_TYPE_VERB;
- action.word_type[1] = WORD_TYPE_VERB;
- action.word_type[2] = WORD_TYPE_NOUN_MASK;
+ action._nr_words = 3;
+ action._wordType[0] = WORD_TYPE_VERB;
+ action._wordType[1] = WORD_TYPE_VERB;
+ action._wordType[2] = WORD_TYPE_NOUN_MASK;
- action.word[1] = fb->readByte();
- action.word[2] = fb->readByte();
- action.function = fb->readUint16LE();
+ action._word[1] = fb->readByte();
+ action._word[2] = fb->readByte();
+ action._function = fb->readUint16LE();
_actions.push_back(action);
}
@@ -427,17 +427,17 @@ void GameData::parse_action_table_vnn(FileBuffer *fb) {
for (i = 0; i < count; i++) {
Action action;
- action.type = ACTION_VERB_NOUN_NOUN;
- action.word[0] = verb;
+ action._type = ACTION_VERB_NOUN_NOUN;
+ action._word[0] = verb;
- action.nr_words = 3;
- action.word_type[0] = WORD_TYPE_VERB;
- action.word_type[1] = WORD_TYPE_NOUN_MASK;
- action.word_type[2] = WORD_TYPE_NOUN_MASK;
+ action._nr_words = 3;
+ action._wordType[0] = WORD_TYPE_VERB;
+ action._wordType[1] = WORD_TYPE_NOUN_MASK;
+ action._wordType[2] = WORD_TYPE_NOUN_MASK;
- action.word[1] = fb->readByte();
- action.word[2] = fb->readByte();
- action.function = fb->readUint16LE();
+ action._word[1] = fb->readByte();
+ action._word[2] = fb->readByte();
+ action._function = fb->readUint16LE();
_actions.push_back(action);
}
@@ -466,15 +466,15 @@ void GameData::parse_action_table_vn(FileBuffer *fb) {
for (i = 0; i < count; i++) {
Action action;
- action.type = ACTION_VERB_NOUN;
- action.word[0] = verb;
+ action._type = ACTION_VERB_NOUN;
+ action._word[0] = verb;
- action.nr_words = 2;
- action.word_type[0] = WORD_TYPE_VERB;
- action.word_type[1] = WORD_TYPE_NOUN_MASK;
+ action._nr_words = 2;
+ action._wordType[0] = WORD_TYPE_VERB;
+ action._wordType[1] = WORD_TYPE_NOUN_MASK;
- action.word[1] = fb->readByte();
- action.function = fb->readUint16LE();
+ action._word[1] = fb->readByte();
+ action._function = fb->readUint16LE();
_actions.push_back(action);
}
@@ -500,12 +500,12 @@ void GameData::parse_action_table_v(FileBuffer *fb) {
break;
Action action;
- action.type = ACTION_VERB_OPT_NOUN;
- action.word[0] = verb;
+ action._type = ACTION_VERB_OPT_NOUN;
+ action._word[0] = verb;
/* Can take an optional noun (nr_words here is maximum) */
- action.nr_words = 1;
- action.word_type[0] = WORD_TYPE_VERB;
+ action._nr_words = 1;
+ action._wordType[0] = WORD_TYPE_VERB;
/*
* Default actions can have more than one function, but only
@@ -515,7 +515,7 @@ void GameData::parse_action_table_v(FileBuffer *fb) {
for (i = 0; i < nr_funcs; i++) {
func = fb->readUint16LE();
if (i == 0)
- action.function = func;
+ action._function = func;
}
_actions.push_back(action);
@@ -571,11 +571,11 @@ void GameData::parse_word_map(FileBuffer *fb) {
break;
}
- map.word[0].index = index;
- map.word[0].type = type;
- map.flags = fb->readByte();
- map.word[1].index = fb->readByte();
- map.word[1].type = fb->readByte();
+ map._word[0]._index = index;
+ map._word[0]._type = type;
+ map._flags = fb->readByte();
+ map._word[1]._index = fb->readByte();
+ map._word[1]._type = fb->readByte();
_wordMaps.push_back(map);
}
@@ -591,8 +591,8 @@ void GameData::parse_word_map(FileBuffer *fb) {
for (i = 0; i < _wordMaps.size(); i++) {
WordMap &map = _wordMaps[i];
- map.word[2].index = fb->readByte();
- map.word[2].type = fb->readByte();
+ map._word[2]._index = fb->readByte();
+ map._word[2]._type = fb->readByte();
}
}
@@ -602,30 +602,30 @@ void GameData::parse_items(FileBuffer *fb) {
/* Item descriptions */
fb->seek(_header.addr_item_strings);
- file_buf_get_array_le16(fb, 0, _items, string_desc, nr_items);
+ file_buf_get_array_le16(fb, 0, _items, _stringDesc, nr_items);
if (_comprehendVersion == 2) {
/* Comprehend version 2 adds long string descriptions */
fb->seek(_header.addr_item_strings +
(_items.size() * sizeof(uint16)));
- file_buf_get_array_le16(fb, 0, _items, long_string, nr_items);
+ file_buf_get_array_le16(fb, 0, _items, _longString, nr_items);
}
/* Item flags */
fb->seek(_header.addr_item_flags);
- file_buf_get_array_u8(fb, 0, _items, flags, nr_items);
+ file_buf_get_array_u8(fb, 0, _items, _flags, nr_items);
/* Item word */
fb->seek(_header.addr_item_word);
- file_buf_get_array_u8(fb, 0, _items, word, nr_items);
+ file_buf_get_array_u8(fb, 0, _items, _word, nr_items);
/* Item locations */
fb->seek(_header.addr_item_locations);
- file_buf_get_array_u8(fb, 0, _items, room, nr_items);
+ file_buf_get_array_u8(fb, 0, _items, _room, nr_items);
/* Item graphic */
fb->seek(_header.addr_item_graphics);
- file_buf_get_array_u8(fb, 0, _items, graphic, nr_items);
+ file_buf_get_array_u8(fb, 0, _items, _graphic, nr_items);
}
void GameData::parse_rooms(FileBuffer *fb) {
@@ -635,21 +635,20 @@ void GameData::parse_rooms(FileBuffer *fb) {
/* Room exit directions */
for (i = 0; i < NR_DIRECTIONS; i++) {
fb->seek(_header.room_direction_table[i]);
- file_buf_get_array_u8(fb, 1, _rooms,
- direction[i], nr_rooms);
+ file_buf_get_array_u8(fb, 1, _rooms, _direction[i], nr_rooms);
}
/* Room string descriptions */
fb->seek(_header.room_desc_table);
- file_buf_get_array_le16(fb, 1, _rooms, string_desc, nr_rooms);
+ file_buf_get_array_le16(fb, 1, _rooms, _stringDesc, nr_rooms);
/* Room flags */
fb->seek(_header.room_flags_table);
- file_buf_get_array_u8(fb, 1, _rooms, flags, nr_rooms);
+ file_buf_get_array_u8(fb, 1, _rooms, _flags, nr_rooms);
/* Room graphic */
fb->seek(_header.room_graphics_table);
- file_buf_get_array_u8(fb, 1, _rooms, graphic, nr_rooms);
+ file_buf_get_array_u8(fb, 1, _rooms, _graphic, nr_rooms);
}
uint64 GameData::string_get_chunk(uint8 *string) {
@@ -912,15 +911,15 @@ void GameData::parse_header(FileBuffer *fb) {
}
void GameData::load_extra_string_file(StringFile *string_file) {
- FileBuffer fb(string_file->filename);
+ FileBuffer fb(string_file->_filename);
unsigned end;
- if (string_file->end_offset)
- end = string_file->end_offset;
+ if (string_file->_endOffset)
+ end = string_file->_endOffset;
else
end = fb.size();
- parse_string_table(&fb, string_file->base_offset,
+ parse_string_table(&fb, string_file->_baseOffset,
end, &_strings2);
}
diff --git a/engines/glk/comprehend/game_data.h b/engines/glk/comprehend/game_data.h
index 0edb5775eb..593c577319 100644
--- a/engines/glk/comprehend/game_data.h
+++ b/engines/glk/comprehend/game_data.h
@@ -172,12 +172,12 @@ enum {
WORD_TYPE_NOUN | WORD_TYPE_NOUN_PLURAL)
struct FunctionState {
- bool test_result;
- bool else_result;
- unsigned or_count;
+ bool _testResult;
+ bool _elseResult;
+ uint _orCount;
bool _and;
- bool in_command;
- bool executed;
+ bool _inCommand;
+ bool _executed;
FunctionState() {
clear();
@@ -187,10 +187,10 @@ struct FunctionState {
};
struct Room {
- uint8 direction[NR_DIRECTIONS];
- uint8 flags;
- uint8 graphic;
- uint16 string_desc;
+ uint8 _direction[NR_DIRECTIONS];
+ uint8 _flags;
+ uint8 _graphic;
+ uint16 _stringDesc;
Room() {
clear();
@@ -200,12 +200,12 @@ struct Room {
};
struct Item {
- uint16 string_desc;
- uint16 long_string; /* Only used by version 2 */
- uint8 room;
- uint8 flags;
- uint8 word;
- uint8 graphic;
+ uint16 _stringDesc;
+ uint16 _longString; /* Only used by version 2 */
+ uint8 _room;
+ uint8 _flags;
+ uint8 _word;
+ uint8 _graphic;
Item() {
clear();
@@ -231,22 +231,22 @@ struct Word {
};
struct WordIndex {
- uint8 index;
- uint8 type;
+ uint8 _index;
+ uint8 _type;
WordIndex() {
clear();
}
void clear() {
- index = type = 0;
+ _index = _type = 0;
}
};
struct WordMap {
/* <word[0]>, <word[1]> == <word[2]> */
- WordIndex word[3];
- uint8 flags;
+ WordIndex _word[3];
+ uint8 _flags;
WordMap() {
clear();
@@ -256,12 +256,12 @@ struct WordMap {
};
struct Action {
- int type;
- size_t nr_words;
+ int _type;
+ size_t _nr_words;
// FIXME - use struct word_index here.
- uint8 word[4];
- uint8 word_type[4];
- uint16 function;
+ uint8 _word[4];
+ uint8 _wordType[4];
+ uint16 _function;
Action() {
clear();
@@ -271,10 +271,10 @@ struct Action {
};
struct Instruction {
- uint8 opcode;
- size_t nr_operands;
- uint8 operand[3];
- bool is_command;
+ uint8 _opcode;
+ size_t _nr_operands;
+ uint8 _operand[3];
+ bool _isCommand;
Instruction() {
clear();
@@ -284,8 +284,8 @@ struct Instruction {
};
struct Function {
- Instruction instructions[0x100];
- size_t nr_instructions;
+ Instruction _instructions[0x100];
+ size_t _nr_instructions;
Function() {
clear();
@@ -297,13 +297,13 @@ struct Function {
typedef Common::StringArray StringTable;
struct StringFile {
- Common::String filename;
- uint32 base_offset;
- uint32 end_offset;
+ Common::String _filename;
+ uint32 _baseOffset;
+ uint32 _endOffset;
- StringFile() : base_offset(0), end_offset(0) {
+ StringFile() : _baseOffset(0), _endOffset(0) {
}
- StringFile(const Common::String &fname, uint32 baseOfs, uint32 endO = 0) : filename(fname), base_offset(baseOfs), end_offset(endO) {
+ StringFile(const Common::String &fname, uint32 baseOfs, uint32 endO = 0) : _filename(fname), _baseOffset(baseOfs), _endOffset(endO) {
}
};
@@ -360,7 +360,7 @@ protected:
public:
GameHeader _header;
- unsigned _comprehendVersion;
+ uint _comprehendVersion;
Common::Array<Room> _rooms;
uint8 _currentRoom;
@@ -427,7 +427,7 @@ private:
*/
Common::String parseString(FileBuffer *fb);
- void parse_string_table(FileBuffer *fb, unsigned start_addr,
+ void parse_string_table(FileBuffer *fb, uint start_addr,
uint32 end_addr, StringTable *table);
void parse_variables(FileBuffer *fb);
void parse_flags(FileBuffer *fb);
diff --git a/engines/glk/comprehend/game_oo.cpp b/engines/glk/comprehend/game_oo.cpp
index d5a9db601b..bf16862776 100644
--- a/engines/glk/comprehend/game_oo.cpp
+++ b/engines/glk/comprehend/game_oo.cpp
@@ -61,7 +61,7 @@ int OOToposGame::roomIsSpecial(unsigned room_index,
Room *room = &_rooms[room_index];
// Is the room dark
- if ((room->flags & OO_ROOM_FLAG_DARK) &&
+ if ((room->_flags & OO_ROOM_FLAG_DARK) &&
!(_flags[OO_FLAG_FLASHLIGHT_ON])) {
if (roomDescString)
*roomDescString = 0xb3;
@@ -89,7 +89,7 @@ bool OOToposGame::beforeTurn() {
* was switch off or on.
*/
if (_flags[OO_FLAG_FLASHLIGHT_ON] != flashlight_was_on &&
- (room->flags & OO_ROOM_FLAG_DARK)) {
+ (room->_flags & OO_ROOM_FLAG_DARK)) {
flashlight_was_on = _flags[OO_FLAG_FLASHLIGHT_ON];
_updateFlags |= UPDATE_GRAPHICS | UPDATE_ROOM_DESC;
}
diff --git a/engines/glk/comprehend/game_tr.cpp b/engines/glk/comprehend/game_tr.cpp
index a787a4f77e..c1ab7808a7 100644
--- a/engines/glk/comprehend/game_tr.cpp
+++ b/engines/glk/comprehend/game_tr.cpp
@@ -71,12 +71,12 @@ void TransylvaniaGame::updateMonster(const TransylvaniaMonster *monsterInfo) {
turn_count = _variables[VAR_TURN_COUNT];
monster = get_item(monsterInfo->_object);
- if (monster->room == _currentRoom) {
+ if (monster->_room == _currentRoom) {
// The monster is in the current room - leave it there
return;
}
- if ((room->flags & monsterInfo->_roomAllowFlag) &&
+ if ((room->_flags & monsterInfo->_roomAllowFlag) &&
!_flags[monsterInfo->_deadFlag] &&
turn_count > monsterInfo->_minTurnsBefore) {
/*
@@ -99,7 +99,7 @@ int TransylvaniaGame::roomIsSpecial(unsigned room_index,
if (room_index == 0x28) {
if (roomDescString)
- *roomDescString = room->string_desc;
+ *roomDescString = room->_stringDesc;
return ROOM_IS_DARK;
}
Commit: 06e9e826d168dcbcad1c2b5c1500c871088d7add
https://github.com/scummvm/scummvm/commit/06e9e826d168dcbcad1c2b5c1500c871088d7add
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-13T15:37:28-07:00
Commit Message:
GLK: COMPREHEND: Debugger commands for rooms
Changed paths:
engines/glk/comprehend/comprehend.h
engines/glk/comprehend/debugger.cpp
engines/glk/comprehend/debugger.h
engines/glk/comprehend/game.h
diff --git a/engines/glk/comprehend/comprehend.h b/engines/glk/comprehend/comprehend.h
index 7dd01b15e6..593ffc2e4e 100644
--- a/engines/glk/comprehend/comprehend.h
+++ b/engines/glk/comprehend/comprehend.h
@@ -166,6 +166,10 @@ public:
bool isGraphicsEnabled() const {
return _graphicsEnabled;
}
+
+ ComprehendGame *getGame() const {
+ return _game;
+ }
};
extern Comprehend *g_comprehend;
diff --git a/engines/glk/comprehend/debugger.cpp b/engines/glk/comprehend/debugger.cpp
index bbd9b0555e..90c454999b 100644
--- a/engines/glk/comprehend/debugger.cpp
+++ b/engines/glk/comprehend/debugger.cpp
@@ -33,6 +33,8 @@ Debugger::Debugger() : Glk::Debugger() {
g_debugger = this;
registerCmd("dump", WRAP_METHOD(Debugger, cmdDump));
registerCmd("floodfills", WRAP_METHOD(Debugger, cmdFloodfills));
+ registerCmd("room", WRAP_METHOD(Debugger, cmdRoom));
+ registerCmd("itemroom", WRAP_METHOD(Debugger, cmdItemRoom));
}
Debugger::~Debugger() {
@@ -70,5 +72,49 @@ bool Debugger::cmdFloodfills(int argc, const char **argv) {
return true;
}
+bool Debugger::cmdRoom(int argc, const char **argv) {
+ ComprehendGame *game = g_comprehend->getGame();
+
+ if (argc == 1) {
+ debugPrintf("Current room = %d\n", game->_currentRoom);
+ return true;
+ } else {
+ game->move_to(strToInt(argv[1]));
+ game->update_graphics();
+ return false;
+ }
+}
+
+bool Debugger::cmdItemRoom(int argc, const char **argv) {
+ ComprehendGame *game = g_comprehend->getGame();
+
+ if (argc == 1) {
+ debugPrintf("itemroom <item> [<room>]\n");
+ } else {
+ Item *item = game->get_item(strToInt(argv[1]));
+
+ if (argc == 2) {
+ debugPrintf("Item room = %d\n", item->_room);
+ } else {
+ int room = strToInt(argv[2]);
+ if (room == 0)
+ room = game->_currentRoom;
+ bool visibleChange = item->_room == game->_currentRoom ||
+ room == game->_currentRoom;
+
+ item->_room = room;
+
+ if (visibleChange) {
+ game->_updateFlags |= UPDATE_GRAPHICS_ITEMS;
+ game->update_graphics();
+ }
+
+ return false;
+ }
+ }
+
+ return true;
+}
+
} // namespace Comprehend
} // namespace Glk
diff --git a/engines/glk/comprehend/debugger.h b/engines/glk/comprehend/debugger.h
index ec6fcf8e13..a9b08e252c 100644
--- a/engines/glk/comprehend/debugger.h
+++ b/engines/glk/comprehend/debugger.h
@@ -41,6 +41,16 @@ private:
*/
bool cmdFloodfills(int argc, const char **argv);
+ /**
+ * Sets or lists the current room
+ */
+ bool cmdRoom(int argc, const char **argv);
+
+ /**
+ * Sets or lists the room for an item
+ */
+ bool cmdItemRoom(int argc, const char **argv);
+
protected:
void print(const char *fmt, ...) override;
diff --git a/engines/glk/comprehend/game.h b/engines/glk/comprehend/game.h
index 8ced85b30b..8a5a92a251 100644
--- a/engines/glk/comprehend/game.h
+++ b/engines/glk/comprehend/game.h
@@ -45,10 +45,8 @@ public:
private:
WordIndex *is_word_pair(Word *word1, Word *word2);
Item *get_item_by_noun(Word *noun);
- void update_graphics();
void describe_objects_in_current_room();
void update();
- void move_to(uint8 room);
void func_set_test_result(FunctionState *func_state, bool value);
size_t num_objects_in_room(int room);
void eval_instruction(FunctionState *func_state, Instruction *instr,
@@ -67,8 +65,6 @@ protected:
void game_restart();
int console_get_key();
void console_println(const char *text);
- Room *get_room(uint16 index);
- Item *get_item(uint16 index);
void move_object(Item *item, int new_room);
/*
@@ -110,20 +106,12 @@ public:
Common::String instrStringLookup(uint8 index, uint8 table);
void playGame();
-};
-
-void console_println(ComprehendGame *game, const char *text);
-int console_get_key(void);
-Item *get_item(ComprehendGame *game, uint16 index);
-void move_object(ComprehendGame *game, Item *item, int new_room);
-void eval_function(ComprehendGame *game, Function *func,
- Word *verb, Word *noun);
-
-void comprehend_play_game(ComprehendGame *game);
-void game_save(ComprehendGame *game);
-void game_restore(ComprehendGame *game);
-void game_restart(ComprehendGame *game);
+ void move_to(uint8 room);
+ Room *get_room(uint16 index);
+ Item *get_item(uint16 index);
+ void update_graphics();
+};
} // namespace Comprehend
} // namespace Glk
Commit: 2f6e1e1d87f7b3263935e7546cd6bcfafc4f4e7f
https://github.com/scummvm/scummvm/commit/2f6e1e1d87f7b3263935e7546cd6bcfafc4f4e7f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-13T15:37:28-07:00
Commit Message:
GLK: COMPREHEND: Added findstring debugger command
Changed paths:
engines/glk/comprehend/debugger.cpp
engines/glk/comprehend/debugger.h
diff --git a/engines/glk/comprehend/debugger.cpp b/engines/glk/comprehend/debugger.cpp
index 90c454999b..8950abc861 100644
--- a/engines/glk/comprehend/debugger.cpp
+++ b/engines/glk/comprehend/debugger.cpp
@@ -35,6 +35,7 @@ Debugger::Debugger() : Glk::Debugger() {
registerCmd("floodfills", WRAP_METHOD(Debugger, cmdFloodfills));
registerCmd("room", WRAP_METHOD(Debugger, cmdRoom));
registerCmd("itemroom", WRAP_METHOD(Debugger, cmdItemRoom));
+ registerCmd("findstring", WRAP_METHOD(Debugger, cmdFindString));
}
Debugger::~Debugger() {
@@ -116,5 +117,26 @@ bool Debugger::cmdItemRoom(int argc, const char **argv) {
return true;
}
+bool Debugger::cmdFindString(int argc, const char **argv) {
+ ComprehendGame *game = g_comprehend->getGame();
+
+ if (argc == 1) {
+ debugPrintf("findstring <string>\n");
+
+ } else {
+ for (int arrNum = 0; arrNum < 2; ++arrNum) {
+ const StringTable &table = (arrNum == 0) ? game->_strings : game->_strings2;
+ const char *name = (arrNum == 0) ? "_strings" : "_strings2";
+
+ for (uint idx = 0; idx < table.size(); ++idx) {
+ if (table[idx].contains(argv[1]))
+ debugPrintf("%s[%u] = %s\n", name, idx, table[idx].c_str());
+ }
+ }
+ }
+
+ return true;
+}
+
} // namespace Comprehend
} // namespace Glk
diff --git a/engines/glk/comprehend/debugger.h b/engines/glk/comprehend/debugger.h
index a9b08e252c..d658e94da5 100644
--- a/engines/glk/comprehend/debugger.h
+++ b/engines/glk/comprehend/debugger.h
@@ -51,6 +51,11 @@ private:
*/
bool cmdItemRoom(int argc, const char **argv);
+ /**
+ * Find a string given a partial specified
+ */
+ bool cmdFindString(int argc, const char **argv);
+
protected:
void print(const char *fmt, ...) override;
Commit: 649ab3ffa9ca0b821411479674e6febd038eda3f
https://github.com/scummvm/scummvm/commit/649ab3ffa9ca0b821411479674e6febd038eda3f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-13T15:37:28-07:00
Commit Message:
GLK: COMPREHEND: Implementing all original monster logic
Changed paths:
engines/glk/comprehend/game.cpp
engines/glk/comprehend/game.h
engines/glk/comprehend/game_tr.cpp
engines/glk/comprehend/game_tr.h
diff --git a/engines/glk/comprehend/game.cpp b/engines/glk/comprehend/game.cpp
index 3f55b7f74a..6934a76adf 100644
--- a/engines/glk/comprehend/game.cpp
+++ b/engines/glk/comprehend/game.cpp
@@ -1235,5 +1235,9 @@ void ComprehendGame::playGame() {
read_input();
}
+uint ComprehendGame::getRandomNumber(uint max) const {
+ return g_comprehend->getRandomNumber(max);
+}
+
} // namespace Comprehend
} // namespace Glk
diff --git a/engines/glk/comprehend/game.h b/engines/glk/comprehend/game.h
index 8a5a92a251..1067bb8b3c 100644
--- a/engines/glk/comprehend/game.h
+++ b/engines/glk/comprehend/game.h
@@ -111,6 +111,11 @@ public:
Room *get_room(uint16 index);
Item *get_item(uint16 index);
void update_graphics();
+
+ /**
+ * Gets a random number
+ */
+ uint getRandomNumber(uint max) const;
};
} // namespace Comprehend
diff --git a/engines/glk/comprehend/game_tr.cpp b/engines/glk/comprehend/game_tr.cpp
index c1ab7808a7..09474aec3b 100644
--- a/engines/glk/comprehend/game_tr.cpp
+++ b/engines/glk/comprehend/game_tr.cpp
@@ -28,12 +28,39 @@
namespace Glk {
namespace Comprehend {
+enum RoomId {
+ ROOM_CLAY_HUT = 7,
+ ROOM_FIELD = 26
+};
+
+enum RoomFlag {
+ ROOMFLAG_OUTSIDE = 1 << 0,
+ ROOMFLAG_WEREWOLF = 1 << 6,
+ ROOMFLAG_VAMPIRE = 1 << 7
+};
+
+enum ItemId {
+ ITEM_GOBLIN = 9,
+ ITEM_BLACK_CAT = 23,
+ ITEM_WEREWOLF = 33,
+ ITEM_VAMPIRE = 38
+};
+
+struct TransylvaniaMonster {
+ uint8 _object;
+ uint8 _deadFlag;
+ uint _roomAllowFlag;
+ uint _minTurnsBefore;
+ uint _randomness;
+};
+
+
const TransylvaniaMonster TransylvaniaGame::WEREWOLF = {
- 0x21, 7, (1 << 6), 5, 5
+ ITEM_WEREWOLF, 7, ROOMFLAG_WEREWOLF, 10, 172
};
const TransylvaniaMonster TransylvaniaGame::VAMPIRE = {
- 0x26, 5, (1 << 7), 0, 5
+ ITEM_VAMPIRE, 5, ROOMFLAG_VAMPIRE, 0, 200
};
static const GameStrings TR_STRINGS = {
@@ -41,7 +68,8 @@ static const GameStrings TR_STRINGS = {
};
-TransylvaniaGame::TransylvaniaGame() : ComprehendGame() {
+TransylvaniaGame::TransylvaniaGame() : ComprehendGame(),
+ _randomActionThreshold(39) {
_gameDataFile = "tr.gda";
_stringFiles.push_back(StringFile("MA.MS1", 0x88));
@@ -62,7 +90,7 @@ TransylvaniaGame::TransylvaniaGame() : ComprehendGame() {
_gameStrings = &TR_STRINGS;
}
-void TransylvaniaGame::updateMonster(const TransylvaniaMonster *monsterInfo) {
+bool TransylvaniaGame::updateMonster(const TransylvaniaMonster *monsterInfo) {
Item *monster;
Room *room;
uint16 turn_count;
@@ -73,7 +101,7 @@ void TransylvaniaGame::updateMonster(const TransylvaniaMonster *monsterInfo) {
monster = get_item(monsterInfo->_object);
if (monster->_room == _currentRoom) {
// The monster is in the current room - leave it there
- return;
+ return true;
}
if ((room->_flags & monsterInfo->_roomAllowFlag) &&
@@ -84,13 +112,22 @@ void TransylvaniaGame::updateMonster(const TransylvaniaMonster *monsterInfo) {
* room. Randomly decide whether on not to. If not, move
* it back to limbo.
*/
- if ((g_comprehend->getRandomNumber(0x7fffffff) % monsterInfo->_randomness) == 0) {
+ if ((getRandomNumber(0x7fffffff) % monsterInfo->_randomness) == 0) {
move_object(monster, _currentRoom);
- _variables[0xf] = turn_count + 1;
+ _variables[15] = turn_count + 1;
} else {
move_object(monster, ROOM_NOWHERE);
}
+
+ return true;
}
+
+ return false;
+}
+
+bool TransylvaniaGame::isMonsterInRoom(const TransylvaniaMonster *monsterInfo) {
+ Item *monster = get_item(monsterInfo->_object);
+ return monster->_room == _currentRoom;
}
int TransylvaniaGame::roomIsSpecial(unsigned room_index,
@@ -107,15 +144,56 @@ int TransylvaniaGame::roomIsSpecial(unsigned room_index,
}
bool TransylvaniaGame::beforeTurn() {
- updateMonster(&WEREWOLF);
- updateMonster(&VAMPIRE);
+ if (!isMonsterInRoom(&WEREWOLF) && !isMonsterInRoom(&VAMPIRE)) {
+ if (_currentRoom == ROOM_CLAY_HUT) {
+ Item *blackCat = get_item(ITEM_BLACK_CAT);
+ if (blackCat->_room == _currentRoom && getRandomNumber(255) >= 128)
+ console_println(_strings2[109].c_str());
+ return true;
+
+ } else if (_currentRoom == ROOM_FIELD) {
+ Item *goblin = get_item(ITEM_GOBLIN);
+ if (goblin->_room == _currentRoom)
+ console_println(_strings2[94 + getRandomNumber(3)].c_str());
+ return true;
+
+ }
+ }
+
+ if (updateMonster(&WEREWOLF) || updateMonster(&VAMPIRE))
+ return true;
+
+ Room *room = &_rooms[_currentRoom];
+ if (!(room->_flags & ROOMFLAG_OUTSIDE) && (_variables[VAR_TURN_COUNT] % 255) >= 4
+ && getRandomNumber(255) < _randomActionThreshold) {
+ // TODO: This looks suspect in the original. Since the threshold is only
+ // ever 39 or 43.. was still meant to be a random range of possible responses
+ int stringNum = 98 + (_randomActionThreshold / 4);
+ console_println(_strings[stringNum].c_str());
+
+ // Extra stuff for eagle seizing player
+ if (stringNum == 107) {
+ // Get new room to get moved to
+ int roomNum = getRandomNumber(3) + 1;
+ if (roomNum == _currentRoom)
+ roomNum += 15;
+
+ move_to(roomNum);
+
+ // Make sure Werwolf and Vampire aren't present
+ get_item(ITEM_WEREWOLF)->_room = 0xff;
+ get_item(ITEM_VAMPIRE)->_room = 0xff;
+ }
+ }
+
return false;
}
void TransylvaniaGame::handleSpecialOpcode(uint8 operand) {
switch (operand) {
case 1:
- // FIXME: Called when the mice are dropped and the cat chases them.
+ // Called when the mice are dropped and the cat chases them
+ _randomActionThreshold = 43;
break;
case 2:
diff --git a/engines/glk/comprehend/game_tr.h b/engines/glk/comprehend/game_tr.h
index e89db32dec..1301310909 100644
--- a/engines/glk/comprehend/game_tr.h
+++ b/engines/glk/comprehend/game_tr.h
@@ -28,21 +28,16 @@
namespace Glk {
namespace Comprehend {
-struct TransylvaniaMonster {
- uint8 _object;
- uint8 _deadFlag;
- unsigned _minTurnsBefore;
- unsigned _roomAllowFlag;
- unsigned _randomness;
-};
+struct TransylvaniaMonster;
class TransylvaniaGame : public ComprehendGame {
private:
static const TransylvaniaMonster WEREWOLF;
static const TransylvaniaMonster VAMPIRE;
+ byte _randomActionThreshold;
- void updateMonster(const TransylvaniaMonster *monsterInfo);
-
+ bool updateMonster(const TransylvaniaMonster *monsterInfo);
+ bool isMonsterInRoom(const TransylvaniaMonster *monsterInfo);
public:
TransylvaniaGame();
~TransylvaniaGame() override {}
Commit: 1344c1621f7134b732def5f2c319d9d7ba1f3722
https://github.com/scummvm/scummvm/commit/1344c1621f7134b732def5f2c319d9d7ba1f3722
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-06-13T15:37:28-07:00
Commit Message:
GLK: COMPREHEND: Cleanup of eagle/mice random events
Changed paths:
engines/glk/comprehend/game.h
engines/glk/comprehend/game_oo.cpp
engines/glk/comprehend/game_oo.h
engines/glk/comprehend/game_tr.cpp
engines/glk/comprehend/game_tr.h
diff --git a/engines/glk/comprehend/game.h b/engines/glk/comprehend/game.h
index 1067bb8b3c..95f0efd1cb 100644
--- a/engines/glk/comprehend/game.h
+++ b/engines/glk/comprehend/game.h
@@ -89,9 +89,7 @@ public:
virtual void beforeGame() {}
virtual void beforePrompt() {}
- virtual bool beforeTurn() {
- return false;
- }
+ virtual void beforeTurn() {}
virtual bool afterTurn() {
return false;
}
@@ -100,7 +98,7 @@ public:
}
virtual void handleSpecialOpcode(uint8 operand) {}
- void synchronizeSave(Common::Serializer &s);
+ virtual void synchronizeSave(Common::Serializer &s);
Common::String stringLookup(uint16 index);
Common::String instrStringLookup(uint8 index, uint8 table);
diff --git a/engines/glk/comprehend/game_oo.cpp b/engines/glk/comprehend/game_oo.cpp
index bf16862776..0496bd0b05 100644
--- a/engines/glk/comprehend/game_oo.cpp
+++ b/engines/glk/comprehend/game_oo.cpp
@@ -79,7 +79,7 @@ int OOToposGame::roomIsSpecial(unsigned room_index,
return ROOM_IS_NORMAL;
}
-bool OOToposGame::beforeTurn() {
+void OOToposGame::beforeTurn() {
// FIXME: Probably doesn't work correctly with restored games
static bool flashlight_was_on = false, googles_were_worn = false;
Room *room = &_rooms[_currentRoom];
@@ -103,8 +103,6 @@ bool OOToposGame::beforeTurn() {
googles_were_worn = _flags[OO_FLAG_WEARING_GOGGLES];
_updateFlags |= UPDATE_GRAPHICS | UPDATE_ROOM_DESC;
}
-
- return false;
}
void OOToposGame::handleSpecialOpcode(uint8 operand) {
diff --git a/engines/glk/comprehend/game_oo.h b/engines/glk/comprehend/game_oo.h
index c24efb4149..3de4d24327 100644
--- a/engines/glk/comprehend/game_oo.h
+++ b/engines/glk/comprehend/game_oo.h
@@ -33,7 +33,7 @@ public:
OOToposGame();
~OOToposGame() override {}
- bool beforeTurn() override;
+ void beforeTurn() override;
int roomIsSpecial(unsigned room_index, unsigned *room_desc_string) override;
void handleSpecialOpcode(uint8 operand) override;
};
diff --git a/engines/glk/comprehend/game_tr.cpp b/engines/glk/comprehend/game_tr.cpp
index 09474aec3b..dd85c27b48 100644
--- a/engines/glk/comprehend/game_tr.cpp
+++ b/engines/glk/comprehend/game_tr.cpp
@@ -34,7 +34,7 @@ enum RoomId {
};
enum RoomFlag {
- ROOMFLAG_OUTSIDE = 1 << 0,
+ ROOMFLAG_FOREST = 1 << 0,
ROOMFLAG_WEREWOLF = 1 << 6,
ROOMFLAG_VAMPIRE = 1 << 7
};
@@ -69,7 +69,7 @@ static const GameStrings TR_STRINGS = {
TransylvaniaGame::TransylvaniaGame() : ComprehendGame(),
- _randomActionThreshold(39) {
+ _miceReleased(false) {
_gameDataFile = "tr.gda";
_stringFiles.push_back(StringFile("MA.MS1", 0x88));
@@ -143,36 +143,34 @@ int TransylvaniaGame::roomIsSpecial(unsigned room_index,
return ROOM_IS_NORMAL;
}
-bool TransylvaniaGame::beforeTurn() {
+void TransylvaniaGame::beforeTurn() {
if (!isMonsterInRoom(&WEREWOLF) && !isMonsterInRoom(&VAMPIRE)) {
if (_currentRoom == ROOM_CLAY_HUT) {
Item *blackCat = get_item(ITEM_BLACK_CAT);
if (blackCat->_room == _currentRoom && getRandomNumber(255) >= 128)
- console_println(_strings2[109].c_str());
- return true;
+ console_println(_strings[109].c_str());
+ return;
} else if (_currentRoom == ROOM_FIELD) {
Item *goblin = get_item(ITEM_GOBLIN);
if (goblin->_room == _currentRoom)
- console_println(_strings2[94 + getRandomNumber(3)].c_str());
- return true;
+ console_println(_strings[94 + getRandomNumber(3)].c_str());
+ return;
}
}
if (updateMonster(&WEREWOLF) || updateMonster(&VAMPIRE))
- return true;
+ return;
Room *room = &_rooms[_currentRoom];
- if (!(room->_flags & ROOMFLAG_OUTSIDE) && (_variables[VAR_TURN_COUNT] % 255) >= 4
- && getRandomNumber(255) < _randomActionThreshold) {
- // TODO: This looks suspect in the original. Since the threshold is only
- // ever 39 or 43.. was still meant to be a random range of possible responses
- int stringNum = 98 + (_randomActionThreshold / 4);
+ if (!(room->_flags & ROOMFLAG_FOREST) && (_variables[VAR_TURN_COUNT] % 255) >= 4
+ && getRandomNumber(255) < 40) {
+ int stringNum = _miceReleased ? 108 : 107;
console_println(_strings[stringNum].c_str());
- // Extra stuff for eagle seizing player
- if (stringNum == 107) {
+ // Until the mice are released, an eagle moves player to a random room
+ if (!_miceReleased) {
// Get new room to get moved to
int roomNum = getRandomNumber(3) + 1;
if (roomNum == _currentRoom)
@@ -185,15 +183,18 @@ bool TransylvaniaGame::beforeTurn() {
get_item(ITEM_VAMPIRE)->_room = 0xff;
}
}
+}
- return false;
+void TransylvaniaGame::synchronizeSave(Common::Serializer &s) {
+ ComprehendGame::synchronizeSave(s);
+ s.syncAsByte(_miceReleased);
}
void TransylvaniaGame::handleSpecialOpcode(uint8 operand) {
switch (operand) {
case 1:
- // Called when the mice are dropped and the cat chases them
- _randomActionThreshold = 43;
+ // Flag that the mice have been released
+ _miceReleased = true;
break;
case 2:
diff --git a/engines/glk/comprehend/game_tr.h b/engines/glk/comprehend/game_tr.h
index 1301310909..70e4a059e5 100644
--- a/engines/glk/comprehend/game_tr.h
+++ b/engines/glk/comprehend/game_tr.h
@@ -34,7 +34,7 @@ class TransylvaniaGame : public ComprehendGame {
private:
static const TransylvaniaMonster WEREWOLF;
static const TransylvaniaMonster VAMPIRE;
- byte _randomActionThreshold;
+ bool _miceReleased;
bool updateMonster(const TransylvaniaMonster *monsterInfo);
bool isMonsterInRoom(const TransylvaniaMonster *monsterInfo);
@@ -43,7 +43,8 @@ public:
~TransylvaniaGame() override {}
void beforeGame() override;
- bool beforeTurn() override;
+ void beforeTurn() override;
+ void synchronizeSave(Common::Serializer &s) override;
int roomIsSpecial(unsigned room_index, unsigned *roomDescString) override;
void handleSpecialOpcode(uint8 operand) override;
};
More information about the Scummvm-git-logs
mailing list