Skip to content

Commit

Permalink
TEENAGENT: Add symbols for object callback tables in Inventory class.
Browse files Browse the repository at this point in the history
Also, removed one ptr usage, replacing with direct get_byte / get_word
accesses.
  • Loading branch information
digitall committed Jul 27, 2012
1 parent 7dce94c commit b19c164
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
13 changes: 7 additions & 6 deletions engines/teenagent/inventory.cpp
Expand Up @@ -140,13 +140,14 @@ void Inventory::add(byte item) {
}

bool Inventory::tryObjectCallback(InventoryObject *obj) {
byte id = obj->id;
uint i = 0;
for (byte *table = _vm->res->dseg.ptr(0xbb6f + 3); table[0] != 0 && i < 7; table += 3, ++i) {
if (table[0] == id) {
byte objId = obj->id;
for (uint i = 0; i < 7; ++i) {
byte tableId = _vm->res->dseg.get_byte(dsAddr_objCallbackTablePtr + (3 * i));
uint16 callbackAddr = _vm->res->dseg.get_word(dsAddr_objCallbackTablePtr + (3 * i) + 1);
if (tableId == objId) {
resetSelectedObject();
activate(false);
if (_vm->processCallback(READ_LE_UINT16(table + 1)))
if (_vm->processCallback(callbackAddr))
return true;
}
}
Expand Down Expand Up @@ -209,7 +210,7 @@ bool Inventory::processEvent(const Common::Event &event) {
return true;

debugC(0, kDebugInventory, "combine(%u, %u)!", id1, id2);
byte *table = _vm->res->dseg.ptr(0xc335);
byte *table = _vm->res->dseg.ptr(dsAddr_objCombiningTablePtr);
while (table[0] != 0 && table[1] != 0) {
if ((id1 == table[0] && id2 == table[1]) || (id2 == table[0] && id1 == table[1])) {
byte new_obj = table[2];
Expand Down
7 changes: 7 additions & 0 deletions engines/teenagent/resources.h
Expand Up @@ -642,6 +642,13 @@ const uint16 dsAddr_egoY = 0x64b1; // 2 bytes
// Current Scene Id : 0xb4f3
const uint16 dsAddr_currentScene = 0xb4f3; // 1 byte

// Inventory Object Callback Table (3 byte (id, callbackAddr) * 7) : 0xbb72 to 0xbb86
const uint16 dsAddr_objCallbackTablePtr = 0xbb72;

// Inventory Object Combining Table (5 byte (id, id, new object id, msgAddr) * 34) : 0xc335 to 0xc3de
const uint16 dsAddr_objCombiningTablePtr = 0xc335;
// 3 byte null terminator for Combining table 0xc3df to 0xc3e1

// Object Combine Error Message : 0xc3e2 to 0xc41e
const uint16 dsAddr_objCombineErrorMsg = 0xc3e2; // "Using these two objects ..."

Expand Down

0 comments on commit b19c164

Please sign in to comment.