diff options
author | Matthew Hoops | 2009-12-21 14:32:54 +0000 |
---|---|---|
committer | Matthew Hoops | 2009-12-21 14:32:54 +0000 |
commit | ef79d7f017610e15df5ea6b4c6d6a3b218d4d39f (patch) | |
tree | 72c129cb6b65f4286166d265edc88537ad9fb8cf /engines/sci/engine/seg_manager.cpp | |
parent | 2a3cbcbc57bbb960e678b40692cffce69c88149b (diff) | |
download | scummvm-rg350-ef79d7f017610e15df5ea6b4c6d6a3b218d4d39f.tar.gz scummvm-rg350-ef79d7f017610e15df5ea6b4c6d6a3b218d4d39f.tar.bz2 scummvm-rg350-ef79d7f017610e15df5ea6b4c6d6a3b218d4d39f.zip |
SCI32:
- Fully implement kArray and kIsHiRes and mostly implement kString (printf and atoi subfunctions still missing).
- Add a dummy SciGui class for SCI32 to bypass the views. Gabriel Knight 1 will now play the Sierra logo music and the main menu music.
- Some other minor SCI32 changes.
svn-id: r46462
Diffstat (limited to 'engines/sci/engine/seg_manager.cpp')
-rw-r--r-- | engines/sci/engine/seg_manager.cpp | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp index 79f2e88f9e..5db6b88136 100644 --- a/engines/sci/engine/seg_manager.cpp +++ b/engines/sci/engine/seg_manager.cpp @@ -53,6 +53,11 @@ SegManager::SegManager(ResourceManager *resMan) { Lists_seg_id = 0; Nodes_seg_id = 0; Hunks_seg_id = 0; + +#ifdef ENABLE_SCI32 + Arrays_seg_id = 0; + String_seg_id = 0; +#endif _exportsAreWide = false; _resMan = resMan; @@ -1250,4 +1255,85 @@ void SegManager::createClassTable() { _resMan->unlockResource(vocab996); } +#ifdef ENABLE_SCI32 +SciArray<reg_t> *SegManager::allocateArray(reg_t *addr) { + ArrayTable *table; + int offset; + + if (!Arrays_seg_id) { + table = (ArrayTable *)allocSegment(new ArrayTable(), &(Arrays_seg_id)); + } else + table = (ArrayTable *)_heap[Arrays_seg_id]; + + offset = table->allocEntry(); + + *addr = make_reg(Arrays_seg_id, offset); + return &(table->_table[offset]); +} + +SciArray<reg_t> *SegManager::lookupArray(reg_t addr) { + if (_heap[addr.segment]->getType() != SEG_TYPE_ARRAY) + error("Attempt to use non-array %04x:%04x as array", PRINT_REG(addr)); + + ArrayTable *arrayTable = (ArrayTable *)_heap[addr.segment]; + + if (!arrayTable->isValidEntry(addr.offset)) + error("Attempt to use non-array %04x:%04x as array", PRINT_REG(addr)); + + return &(arrayTable->_table[addr.offset]); +} + +void SegManager::freeArray(reg_t addr) { + if (_heap[addr.segment]->getType() != SEG_TYPE_ARRAY) + error("Attempt to use non-array %04x:%04x as array", PRINT_REG(addr)); + + ArrayTable *arrayTable = (ArrayTable *)_heap[addr.segment]; + + if (!arrayTable->isValidEntry(addr.offset)) + error("Attempt to use non-array %04x:%04x as array", PRINT_REG(addr)); + + arrayTable->freeEntry(addr.offset); +} + +SciString *SegManager::allocateString(reg_t *addr) { + StringTable *table; + int offset; + + if (!String_seg_id) { + table = (StringTable *)allocSegment(new StringTable(), &(String_seg_id)); + } else + table = (StringTable *)_heap[String_seg_id]; + + offset = table->allocEntry(); + + *addr = make_reg(String_seg_id, offset); + return &(table->_table[offset]); +} + +SciString *SegManager::lookupString(reg_t addr) { + if (_heap[addr.segment]->getType() != SEG_TYPE_STRING) + error("Attempt to use non-string %04x:%04x as string", PRINT_REG(addr)); + + StringTable *stringTable = (StringTable *)_heap[addr.segment]; + + if (!stringTable->isValidEntry(addr.offset)) + error("Attempt to use non-string %04x:%04x as string", PRINT_REG(addr)); + + return &(stringTable->_table[addr.offset]); +} + +void SegManager::freeString(reg_t addr) { + if (_heap[addr.segment]->getType() != SEG_TYPE_STRING) + error("Attempt to use non-string %04x:%04x as string", PRINT_REG(addr)); + + StringTable *stringTable = (StringTable *)_heap[addr.segment]; + + if (!stringTable->isValidEntry(addr.offset)) + error("Attempt to use non-string %04x:%04x as string", PRINT_REG(addr)); + + stringTable->freeEntry(addr.offset); +} + +#endif + } // End of namespace Sci |