some fixes, some cleanup
svn-id: r24644
This commit is contained in:
parent
6c8af67b60
commit
c9cb98291d
5 changed files with 130 additions and 114 deletions
|
@ -108,7 +108,7 @@ void ToucheEngine::res_allocateTables() {
|
|||
error("Unable to allocate memory for conv kit data");
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
for (int i = 0; i < NUM_SEQUENCES; ++i) {
|
||||
_sequenceDataTable[i] = (uint8 *)malloc(16384);
|
||||
if (!_sequenceDataTable[i]) {
|
||||
error("Unable to allocate memory for sequence data %d", i);
|
||||
|
@ -429,6 +429,9 @@ void ToucheEngine::res_loadRoom(int num) {
|
|||
_fullRedrawCounter = 1;
|
||||
_roomNeedRedraw = true;
|
||||
|
||||
// uint8 *p = _backdropBuffer + _currentBitmapWidth * _currentBitmapHeight;
|
||||
// _spritesTable[5].ptr = p + 16384;
|
||||
// _spritesTable[6].ptr = p + 145728 + 16384;
|
||||
_sequenceEntryTable[5].sprNum = -1;
|
||||
_sequenceEntryTable[5].seqNum = -1;
|
||||
_sequenceEntryTable[6].sprNum = -1;
|
||||
|
|
|
@ -32,7 +32,9 @@ SpriteData ToucheEngine::_spritesTable[NUM_SPRITES] = {
|
|||
{ 0x1E848, 0, 0, 0, 0, 0 },
|
||||
{ 0x1E848, 0, 0, 0, 0, 0 },
|
||||
{ 0x23A50, 0, 0, 0, 0, 0 },
|
||||
{ 0x1E848, 0, 0, 0, 0, 0 }
|
||||
{ 0x1E848, 0, 0, 0, 0, 0 },
|
||||
{ 0x23940, 0, 0, 0, 0, 0 }, // room sprite 1
|
||||
{ 0x1E848, 0, 0, 0, 0, 0 } // room sprite 2
|
||||
};
|
||||
|
||||
const uint8 ToucheEngine::_directionsTable[] = {
|
||||
|
@ -59,26 +61,6 @@ char ToucheEngine::_saveLoadDescriptionsTable[10][33] = {
|
|||
"[Empty.9.......................]"
|
||||
};
|
||||
|
||||
void ToucheEngine::setupRect() {
|
||||
static const Common::Rect inventoryAreasTable[13] = {
|
||||
Common::Rect( 0, 354, 50, 400),
|
||||
Common::Rect( 66, 354, 124, 380),
|
||||
Common::Rect( 74, 380, 116, 398),
|
||||
Common::Rect(116, 380, 158, 398),
|
||||
Common::Rect(144, 354, 198, 380),
|
||||
Common::Rect(202, 354, 238, 396),
|
||||
Common::Rect(242, 354, 300, 396),
|
||||
Common::Rect(300, 354, 358, 396),
|
||||
Common::Rect(358, 354, 416, 396),
|
||||
Common::Rect(416, 354, 474, 396),
|
||||
Common::Rect(474, 354, 532, 396),
|
||||
Common::Rect(532, 354, 590, 396),
|
||||
Common::Rect(594, 354, 640, 395)
|
||||
};
|
||||
|
||||
_inventoryAreasTable = inventoryAreasTable;
|
||||
}
|
||||
|
||||
const uint16 Graphics::_fontOffs[] = {
|
||||
0x0000, 0x0007, 0x0024, 0x0043, 0x0072, 0x00AD, 0x00E0, 0x0113, 0x0124, 0x0141,
|
||||
0x015E, 0x0191, 0x01C4, 0x01E3, 0x01F8, 0x0215, 0x0232, 0x0269, 0x0286, 0x02BD,
|
||||
|
|
|
@ -64,7 +64,6 @@ ToucheEngine::ToucheEngine(OSystem *system, Common::Language language)
|
|||
memset(_paletteBuffer, 0, sizeof(_paletteBuffer));
|
||||
|
||||
setupOpcodes();
|
||||
setupRect();
|
||||
setupUIRect();
|
||||
|
||||
Common::addSpecialDebugLevel(kDebugEngine, "Engine", "Engine debug level");
|
||||
|
@ -157,6 +156,7 @@ void ToucheEngine::restart() {
|
|||
clearAreaTable();
|
||||
clearAnimationTable();
|
||||
|
||||
setupInventoryAreas();
|
||||
initInventoryObjectsTable();
|
||||
initInventoryLists();
|
||||
drawInventory(0, 1);
|
||||
|
@ -1189,6 +1189,7 @@ void ToucheEngine::setKeyCharRandomFrame(KeyChar *key) {
|
|||
|
||||
void ToucheEngine::setKeyCharMoney() {
|
||||
_keyCharsTable[_currentKeyCharNum].money += _currentAmountOfMoney;
|
||||
_currentAmountOfMoney = 0;
|
||||
drawAmountOfMoneyInInventory();
|
||||
}
|
||||
|
||||
|
@ -1373,83 +1374,83 @@ void ToucheEngine::updateCursor(int num) {
|
|||
}
|
||||
|
||||
void ToucheEngine::handleMouseButtonClicked() {
|
||||
for (int i = 0; i < 13; ++i) {
|
||||
if (_inventoryAreasTable[i].contains(_inp_mousePos)) {
|
||||
switch (i) {
|
||||
case 0:
|
||||
_keyCharsTable[_currentKeyCharNum].money += _currentAmountOfMoney;
|
||||
_currentAmountOfMoney = 0;
|
||||
ui_handleOptions(0);
|
||||
break;
|
||||
case 1:
|
||||
setKeyCharMoney();
|
||||
for (int area = 0; area < ARRAYSIZE(_inventoryAreasTable); ++area) {
|
||||
if (_inventoryAreasTable[area].contains(_inp_mousePos)) {
|
||||
if (area >= kInventoryObject1 && area <= kInventoryObject6) {
|
||||
int item = _inventoryVar1[area - 6 + *_inventoryVar2];
|
||||
_flagsTable[119] = _currentCursorObject;
|
||||
if (_currentCursorObject == 1) {
|
||||
setCursor(0);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (_keyCharsTable[_currentKeyCharNum].money >= 10) {
|
||||
_keyCharsTable[_currentKeyCharNum].money -= 10;
|
||||
_currentAmountOfMoney += 10;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (_keyCharsTable[_currentKeyCharNum].money != 0) {
|
||||
--_keyCharsTable[_currentKeyCharNum].money;
|
||||
++_currentAmountOfMoney;
|
||||
drawAmountOfMoneyInInventory();
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (_currentAmountOfMoney != 0) {
|
||||
updateCursor(_objectDescriptionNum);
|
||||
int money = _currentAmountOfMoney;
|
||||
setKeyCharMoney();
|
||||
_flagsTable[118] = _currentAmountOfMoney;
|
||||
_currentAmountOfMoney = 0;
|
||||
drawAmountOfMoneyInInventory();
|
||||
setCursor(1);
|
||||
_currentAmountOfMoney = money;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (*_inventoryVar2 != 0) {
|
||||
*_inventoryVar2 -= 6;
|
||||
drawInventory(_objectDescriptionNum, 1);
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if (_inventoryVar1[12 + *_inventoryVar2] != 0) {
|
||||
*_inventoryVar2 += 6;
|
||||
drawInventory(_objectDescriptionNum, 1);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (i >= 6 && i <= 11) {
|
||||
int item = _inventoryVar1[i - 6 + *_inventoryVar2];
|
||||
_flagsTable[119] = _currentCursorObject;
|
||||
if (_currentCursorObject == 1) {
|
||||
setKeyCharMoney();
|
||||
_flagsTable[118] = _currentAmountOfMoney;
|
||||
_currentAmountOfMoney = 0;
|
||||
}
|
||||
if (item != 0 && _currentCursorObject != 0) {
|
||||
if (restartKeyCharScriptOnAction(-53, item | 0x1000, 0)) {
|
||||
updateCursor(_objectDescriptionNum);
|
||||
drawInventory(_objectDescriptionNum, 1);
|
||||
}
|
||||
} else {
|
||||
_inventoryVar1[i - 6 + *_inventoryVar2] = 0;
|
||||
if (_currentCursorObject != 0) {
|
||||
updateCursor(_objectDescriptionNum);
|
||||
}
|
||||
if (item != 0) {
|
||||
setCursor(item);
|
||||
packInventoryItems(0);
|
||||
packInventoryItems(1);
|
||||
}
|
||||
if (item != 0 && _currentCursorObject != 0) {
|
||||
if (restartKeyCharScriptOnAction(-53, item | 0x1000, 0)) {
|
||||
updateCursor(_objectDescriptionNum);
|
||||
drawInventory(_objectDescriptionNum, 1);
|
||||
}
|
||||
} else {
|
||||
_inventoryVar1[area - 6 + *_inventoryVar2] = 0;
|
||||
if (_currentCursorObject != 0) {
|
||||
updateCursor(_objectDescriptionNum);
|
||||
}
|
||||
if (item != 0) {
|
||||
setCursor(item);
|
||||
packInventoryItems(0);
|
||||
packInventoryItems(1);
|
||||
}
|
||||
drawInventory(_objectDescriptionNum, 1);
|
||||
}
|
||||
} else {
|
||||
switch (area) {
|
||||
case kInventoryCharacter:
|
||||
_keyCharsTable[_currentKeyCharNum].money += _currentAmountOfMoney;
|
||||
_currentAmountOfMoney = 0;
|
||||
ui_handleOptions(0);
|
||||
break;
|
||||
case kInventoryMoneyDisplay:
|
||||
setKeyCharMoney();
|
||||
if (_currentCursorObject == 1) {
|
||||
setCursor(0);
|
||||
}
|
||||
break;
|
||||
case kInventoryGoldCoins:
|
||||
if (_keyCharsTable[_currentKeyCharNum].money >= 10) {
|
||||
_keyCharsTable[_currentKeyCharNum].money -= 10;
|
||||
_currentAmountOfMoney += 10;
|
||||
drawAmountOfMoneyInInventory();
|
||||
}
|
||||
break;
|
||||
case kInventorySilverCoins:
|
||||
if (_keyCharsTable[_currentKeyCharNum].money != 0) {
|
||||
--_keyCharsTable[_currentKeyCharNum].money;
|
||||
++_currentAmountOfMoney;
|
||||
drawAmountOfMoneyInInventory();
|
||||
}
|
||||
break;
|
||||
case kInventoryMoney:
|
||||
if (_currentAmountOfMoney != 0) {
|
||||
updateCursor(_objectDescriptionNum);
|
||||
int money = _currentAmountOfMoney;
|
||||
_currentAmountOfMoney = 0;
|
||||
drawAmountOfMoneyInInventory();
|
||||
setCursor(1);
|
||||
_currentAmountOfMoney = money;
|
||||
}
|
||||
break;
|
||||
case kInventoryScroller1:
|
||||
if (*_inventoryVar2 != 0) {
|
||||
*_inventoryVar2 -= 6;
|
||||
drawInventory(_objectDescriptionNum, 1);
|
||||
}
|
||||
break;
|
||||
case kInventoryScroller2:
|
||||
if (_inventoryVar1[6 + *_inventoryVar2] != 0) {
|
||||
*_inventoryVar2 += 6;
|
||||
drawInventory(_objectDescriptionNum, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -1457,24 +1458,22 @@ void ToucheEngine::handleMouseButtonClicked() {
|
|||
}
|
||||
|
||||
void ToucheEngine::handleMouseButtonPressed() {
|
||||
for (int pos = 0; pos < 13; ++pos) {
|
||||
const Common::Rect &r = _inventoryAreasTable[pos];
|
||||
for (int area = kInventoryObject1; area <= kInventoryObject6; ++area) {
|
||||
const Common::Rect &r = _inventoryAreasTable[area];
|
||||
if (r.contains(_inp_mousePos)) {
|
||||
if (pos >= 6 && pos <= 11) {
|
||||
int item = _inventoryVar1[pos - 6 + *_inventoryVar2] | 0x1000;
|
||||
for (uint i = 0; i < _programHitBoxTable.size(); ++i) {
|
||||
const ProgramHitBoxData *hitBox = &_programHitBoxTable[i];
|
||||
if (hitBox->item == item) {
|
||||
const int menuX = r.left + r.width() / 2;
|
||||
const int menuY = 352;
|
||||
int act = handleActionMenuUnderCursor(hitBox->actions, menuX, menuY, hitBox->str);
|
||||
if (act != 0) {
|
||||
restartKeyCharScriptOnAction(act, hitBox->item, 0);
|
||||
}
|
||||
int item = _inventoryVar1[area - 6 + *_inventoryVar2] | 0x1000;
|
||||
for (uint i = 0; i < _programHitBoxTable.size(); ++i) {
|
||||
const ProgramHitBoxData *hitBox = &_programHitBoxTable[i];
|
||||
if (hitBox->item == item) {
|
||||
const int menuX = r.left + r.width() / 2;
|
||||
const int menuY = 352;
|
||||
int act = handleActionMenuUnderCursor(hitBox->actions, menuX, menuY, hitBox->str);
|
||||
if (act != 0) {
|
||||
restartKeyCharScriptOnAction(act, hitBox->item, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1841,6 +1840,7 @@ int ToucheEngine::handleActionMenuUnderCursor(const int16 *actions, int offs, in
|
|||
break;
|
||||
}
|
||||
}
|
||||
_system->updateScreen();
|
||||
_system->delayMillis(50);
|
||||
}
|
||||
|
||||
|
@ -2025,6 +2025,22 @@ void ToucheEngine::initInventoryLists() {
|
|||
_inventoryListCount[3 * 2 + 2] = 6;
|
||||
}
|
||||
|
||||
void ToucheEngine::setupInventoryAreas() {
|
||||
_inventoryAreasTable[kInventoryCharacter] = Common::Rect( 0, 354, 50, 400);
|
||||
_inventoryAreasTable[kInventoryMoneyDisplay] = Common::Rect( 66, 354, 124, 380);
|
||||
_inventoryAreasTable[kInventoryGoldCoins] = Common::Rect( 74, 380, 116, 398);
|
||||
_inventoryAreasTable[kInventorySilverCoins] = Common::Rect(116, 380, 158, 398);
|
||||
_inventoryAreasTable[kInventoryMoney] = Common::Rect(144, 354, 198, 380);
|
||||
_inventoryAreasTable[kInventoryScroller1] = Common::Rect(202, 354, 238, 396);
|
||||
_inventoryAreasTable[kInventoryObject1] = Common::Rect(242, 354, 300, 396);
|
||||
_inventoryAreasTable[kInventoryObject2] = Common::Rect(300, 354, 358, 396);
|
||||
_inventoryAreasTable[kInventoryObject3] = Common::Rect(358, 354, 416, 396);
|
||||
_inventoryAreasTable[kInventoryObject4] = Common::Rect(416, 354, 474, 396);
|
||||
_inventoryAreasTable[kInventoryObject5] = Common::Rect(474, 354, 532, 396);
|
||||
_inventoryAreasTable[kInventoryObject6] = Common::Rect(532, 354, 590, 396);
|
||||
_inventoryAreasTable[kInventoryScroller2] = Common::Rect(594, 354, 640, 395);
|
||||
}
|
||||
|
||||
void ToucheEngine::drawInventory(int index, int flag) {
|
||||
if (_flagsTable[606] == 0) {
|
||||
if (index > 1) {
|
||||
|
|
|
@ -290,6 +290,22 @@ enum SaveLoadMode {
|
|||
kLoadGameState
|
||||
};
|
||||
|
||||
enum InventoryArea {
|
||||
kInventoryCharacter = 0,
|
||||
kInventoryMoneyDisplay,
|
||||
kInventoryGoldCoins,
|
||||
kInventorySilverCoins,
|
||||
kInventoryMoney,
|
||||
kInventoryScroller1,
|
||||
kInventoryObject1,
|
||||
kInventoryObject2,
|
||||
kInventoryObject3,
|
||||
kInventoryObject4,
|
||||
kInventoryObject5,
|
||||
kInventoryObject6,
|
||||
kInventoryScroller2
|
||||
};
|
||||
|
||||
class MidiPlayer;
|
||||
|
||||
class ToucheEngine: public Engine {
|
||||
|
@ -299,7 +315,7 @@ public:
|
|||
NUM_FLAGS = 2000,
|
||||
NUM_KEYCHARS = 32,
|
||||
NUM_AREAS = 10,
|
||||
NUM_SPRITES = 5,
|
||||
NUM_SPRITES = 7,
|
||||
NUM_SEQUENCES = 7,
|
||||
NUM_CONVERSATION_CHOICES = 40,
|
||||
NUM_TALK_ENTRIES = 16,
|
||||
|
@ -391,6 +407,7 @@ protected:
|
|||
|
||||
void initInventoryObjectsTable();
|
||||
void initInventoryLists();
|
||||
void setupInventoryAreas();
|
||||
void drawInventory(int index, int flag);
|
||||
void drawAmountOfMoneyInInventory();
|
||||
void packInventoryItems(int index);
|
||||
|
@ -618,6 +635,7 @@ protected:
|
|||
int16 *_inventoryVar1;
|
||||
int16 *_inventoryVar2;
|
||||
int _currentCursorObject;
|
||||
Common::Rect _inventoryAreasTable[13];
|
||||
|
||||
int _talkTextMode;
|
||||
int _talkListEnd;
|
||||
|
@ -687,7 +705,7 @@ protected:
|
|||
uint8 *_backdropBuffer;
|
||||
uint8 *_menuKitData;
|
||||
uint8 *_convKitData;
|
||||
uint8 *_sequenceDataTable[5];
|
||||
uint8 *_sequenceDataTable[NUM_SEQUENCES];
|
||||
uint8 *_programData;
|
||||
uint32 _programDataSize;
|
||||
uint8 *_mouseData;
|
||||
|
@ -726,8 +744,6 @@ protected:
|
|||
static const uint8 _directionsTable[];
|
||||
static char _saveLoadDescriptionsTable[10][33];
|
||||
|
||||
const Common::Rect *_inventoryAreasTable;
|
||||
void setupRect();
|
||||
void setupUIRect();
|
||||
};
|
||||
|
||||
|
|
|
@ -167,7 +167,7 @@ void ToucheEngine::ui_drawSaveGamesList(int page) {
|
|||
}
|
||||
|
||||
void ToucheEngine::ui_drawCurrentGameStateDescription() {
|
||||
const Common::Rect *r = &buttonsRectTable1[_saveLoadCurrentSlot];
|
||||
const Common::Rect *r = &buttonsRectTable1[_saveLoadCurrentSlot % 10];
|
||||
Graphics::fillRect(_offscreenBuffer, 640, r->left, r->top, r->width(), r->height(), 0xF8);
|
||||
|
||||
int y = r->top;
|
||||
|
@ -292,7 +292,6 @@ int ToucheEngine::ui_handleSaveLoad(SaveLoadMode mode) {
|
|||
button = -1;
|
||||
}
|
||||
if (mode == kSaveGameState) {
|
||||
_saveLoadCurrentPage = (_saveLoadCurrentSlot / 10) * 10;
|
||||
if (_saveLoadCurrentDescriptionLen != descriptionLen) {
|
||||
descriptionLen = _saveLoadCurrentDescriptionLen;
|
||||
ui_drawCurrentGameStateDescription();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue