mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-05 00:36:57 +00:00
AGI: More misc cleanup
This commit is contained in:
parent
74e4973b43
commit
f4201eeda8
@ -610,12 +610,10 @@ uint16 AgiEngine::artificialDelay_SearchTable(AgiArtificialDelayTriggerType trig
|
||||
}
|
||||
|
||||
void AgiEngine::artificialDelayTrigger_NewRoom(int16 newRoomNr) {
|
||||
uint16 millisecondsDelay = 0;
|
||||
|
||||
//warning("artificial delay trigger: room %d -> new room %d", _artificialDelayCurrentRoom, newRoomNr);
|
||||
|
||||
if (!_game.automaticRestoreGame) {
|
||||
millisecondsDelay = artificialDelay_SearchTable(ARTIFICIALDELAYTYPE_NEWROOM, _artificialDelayCurrentRoom, newRoomNr);
|
||||
uint16 millisecondsDelay = artificialDelay_SearchTable(ARTIFICIALDELAYTYPE_NEWROOM, _artificialDelayCurrentRoom, newRoomNr);
|
||||
|
||||
if (_game.nonBlockingTextShown) {
|
||||
if (newRoomNr != _artificialDelayCurrentRoom) {
|
||||
@ -636,12 +634,10 @@ void AgiEngine::artificialDelayTrigger_NewRoom(int16 newRoomNr) {
|
||||
}
|
||||
|
||||
void AgiEngine::artificialDelayTrigger_DrawPicture(int16 newPictureNr) {
|
||||
uint16 millisecondsDelay = 0;
|
||||
|
||||
//warning("artificial delay trigger: picture %d -> new picture %d", _artificialDelayCurrentPicture, newPictureNr);
|
||||
|
||||
if (!_game.automaticRestoreGame) {
|
||||
millisecondsDelay = artificialDelay_SearchTable(ARTIFICIALDELAYTYPE_NEWPICTURE, _artificialDelayCurrentPicture, newPictureNr);
|
||||
uint16 millisecondsDelay = artificialDelay_SearchTable(ARTIFICIALDELAYTYPE_NEWPICTURE, _artificialDelayCurrentPicture, newPictureNr);
|
||||
|
||||
if (_game.nonBlockingTextShown) {
|
||||
if (newPictureNr != _artificialDelayCurrentPicture) {
|
||||
|
@ -752,7 +752,6 @@ public:
|
||||
Common::Platform getPlatform() const;
|
||||
const char *getGameMD5() const;
|
||||
void initFeatures();
|
||||
void setFeature(uint32 feature);
|
||||
void initVersion();
|
||||
|
||||
const char *getDiskName(uint16 id);
|
||||
|
@ -209,8 +209,8 @@ void AgiEngine::updatePosition() {
|
||||
|
||||
// If object has moved, update its position
|
||||
if (!(screenObj->flags & fUpdatePos)) {
|
||||
int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
|
||||
int dy[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 };
|
||||
const int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
|
||||
const int dy[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 };
|
||||
x += screenObj->stepSize * dx[screenObj->direction];
|
||||
y += screenObj->stepSize * dy[screenObj->direction];
|
||||
}
|
||||
|
@ -181,8 +181,7 @@ bool Console::Cmd_Version(int argc, const char **argv) {
|
||||
if ((curChar == 'V') || (curChar == 'v')) {
|
||||
// "V" gefunden, ggf. beginning of version?
|
||||
const char *wordStartPtr = wordScanPtr;
|
||||
bool wordFound = false;
|
||||
|
||||
|
||||
do {
|
||||
curChar = *wordScanPtr;
|
||||
if (curChar == ' ') {
|
||||
@ -193,8 +192,8 @@ bool Console::Cmd_Version(int argc, const char **argv) {
|
||||
|
||||
if (curChar) {
|
||||
// end of "version" found
|
||||
bool wordFound = false;
|
||||
int wordLen = wordScanPtr - wordStartPtr;
|
||||
|
||||
if (wordLen >= 3) {
|
||||
if (strncmp(wordStartPtr, "ver", wordLen) == 0)
|
||||
wordFound = true;
|
||||
@ -527,8 +526,6 @@ bool Console::Cmd_VmVars(int argc, const char **argv) {
|
||||
}
|
||||
|
||||
int varNr = 0;
|
||||
int newValue = 0;
|
||||
|
||||
if (!parseInteger(argv[1], varNr))
|
||||
return true;
|
||||
|
||||
@ -541,6 +538,7 @@ bool Console::Cmd_VmVars(int argc, const char **argv) {
|
||||
// show contents
|
||||
debugPrintf("variable %d == %d\n", varNr, _vm->getVar(varNr));
|
||||
} else {
|
||||
int newValue = 0;
|
||||
if (!parseInteger(argv[2], newValue))
|
||||
return true;
|
||||
|
||||
@ -559,7 +557,6 @@ bool Console::Cmd_VmFlags(int argc, const char **argv) {
|
||||
}
|
||||
|
||||
int flagNr = 0;
|
||||
int newFlagState = 0;
|
||||
|
||||
if (!parseInteger(argv[1], flagNr))
|
||||
return true;
|
||||
@ -577,6 +574,7 @@ bool Console::Cmd_VmFlags(int argc, const char **argv) {
|
||||
debugPrintf("flag %d == not set\n", flagNr);
|
||||
}
|
||||
} else {
|
||||
int newFlagState = 0;
|
||||
if (!parseInteger(argv[2], newFlagState))
|
||||
return true;
|
||||
|
||||
|
@ -226,12 +226,10 @@ uint16 AgiEngine::processAGIEvents() {
|
||||
|
||||
if (key) {
|
||||
if (!handleController(key)) {
|
||||
if (key) {
|
||||
// Only set VAR_KEY, when no controller/direction was detected
|
||||
setVar(VM_VAR_KEY, key & 0xFF);
|
||||
if (_text->promptIsEnabled()) {
|
||||
_text->promptKeyPress(key);
|
||||
}
|
||||
// Only set VAR_KEY, when no controller/direction was detected
|
||||
setVar(VM_VAR_KEY, key & 0xFF);
|
||||
if (_text->promptIsEnabled()) {
|
||||
_text->promptKeyPress(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,11 +39,12 @@ namespace Agi {
|
||||
#include "agi/font.h"
|
||||
|
||||
GfxMgr::GfxMgr(AgiBase *vm, GfxFont *font) : _vm(vm), _font(font) {
|
||||
_agipalFileNum = 0;
|
||||
|
||||
memset(&_paletteGfxMode, 0, sizeof(_paletteGfxMode));
|
||||
memset(&_paletteTextMode, 0, sizeof(_paletteTextMode));
|
||||
|
||||
memset(&_agipalPalette, 0, sizeof(_agipalPalette));
|
||||
_agipalFileNum = 0;
|
||||
|
||||
memset(&_mouseCursor, 0, sizeof(_mouseCursor));
|
||||
memset(&_mouseCursorBusy, 0, sizeof(_mouseCursorBusy));
|
||||
|
||||
@ -104,7 +105,7 @@ void GfxMgr::initVideo() {
|
||||
initPalette(_paletteGfxMode, PALETTE_AMIGA_V1, 16, 4);
|
||||
else if (_vm->getVersion() == 0x2936)
|
||||
initPalette(_paletteGfxMode, PALETTE_AMIGA_V2, 16, 4);
|
||||
else if (_vm->getVersion() > 0x2936)
|
||||
else
|
||||
initPalette(_paletteGfxMode, PALETTE_AMIGA_V3, 16, 4);
|
||||
} else {
|
||||
// Set the old common alternative Amiga palette
|
||||
@ -585,13 +586,12 @@ bool GfxMgr::render_Clip(int16 &x, int16 &y, int16 &width, int16 &height, int16
|
||||
void GfxMgr::render_BlockEGA(int16 x, int16 y, int16 width, int16 height) {
|
||||
uint32 offsetVisual = SCRIPT_WIDTH * y + x;
|
||||
uint32 offsetDisplay = getDisplayOffsetToGameScreenPos(x, y);
|
||||
int16 remainingWidth = width;
|
||||
int16 remainingHeight = height;
|
||||
byte curColor = 0;
|
||||
int16 displayWidth = width * (2 + _displayWidthMulAdjust);
|
||||
|
||||
while (remainingHeight) {
|
||||
remainingWidth = width;
|
||||
int16 remainingWidth = width;
|
||||
|
||||
switch (_upscaledHires) {
|
||||
case DISPLAY_UPSCALED_DISABLED:
|
||||
@ -634,13 +634,12 @@ void GfxMgr::render_BlockEGA(int16 x, int16 y, int16 width, int16 height) {
|
||||
void GfxMgr::render_BlockCGA(int16 x, int16 y, int16 width, int16 height) {
|
||||
uint32 offsetVisual = SCRIPT_WIDTH * y + x;
|
||||
uint32 offsetDisplay = getDisplayOffsetToGameScreenPos(x, y);
|
||||
int16 remainingWidth = width;
|
||||
int16 remainingHeight = height;
|
||||
byte curColor = 0;
|
||||
int16 displayWidth = width * (2 + _displayWidthMulAdjust);
|
||||
|
||||
while (remainingHeight) {
|
||||
remainingWidth = width;
|
||||
int16 remainingWidth = width;
|
||||
|
||||
switch (_upscaledHires) {
|
||||
case DISPLAY_UPSCALED_DISABLED:
|
||||
@ -709,7 +708,6 @@ static const uint8 herculesColorMapping[] = {
|
||||
void GfxMgr::render_BlockHercules(int16 x, int16 y, int16 width, int16 height) {
|
||||
uint32 offsetVisual = SCRIPT_WIDTH * y + x;
|
||||
uint32 offsetDisplay = getDisplayOffsetToGameScreenPos(x, y);
|
||||
int16 remainingWidth = width;
|
||||
int16 remainingHeight = height;
|
||||
byte curColor = 0;
|
||||
int16 displayWidth = width * (2 + _displayWidthMulAdjust);
|
||||
@ -723,7 +721,7 @@ void GfxMgr::render_BlockHercules(int16 x, int16 y, int16 width, int16 height) {
|
||||
byte herculesColors2 = 0;
|
||||
|
||||
while (remainingHeight) {
|
||||
remainingWidth = width;
|
||||
int16 remainingWidth = width;
|
||||
|
||||
lookupOffset1 = (lookupOffset1 + 0) & 0x07;
|
||||
lookupOffset2 = (lookupOffset1 + 1) & 0x07;
|
||||
@ -1080,7 +1078,6 @@ void GfxMgr::drawDisplayRectEGA(int16 x, int16 y, int16 width, int16 height, byt
|
||||
void GfxMgr::drawDisplayRectCGA(int16 x, int16 y, int16 width, int16 height, byte color) {
|
||||
uint32 offsetDisplay = (y * _displayScreenWidth) + x;
|
||||
int16 remainingHeight = height;
|
||||
int16 remainingWidth = width;
|
||||
byte CGAMixtureColor = getCGAMixtureColor(color);
|
||||
byte *displayScreen = nullptr;
|
||||
|
||||
@ -1088,7 +1085,7 @@ void GfxMgr::drawDisplayRectCGA(int16 x, int16 y, int16 width, int16 height, byt
|
||||
assert((width & 1) == 0);
|
||||
|
||||
while (remainingHeight) {
|
||||
remainingWidth = width;
|
||||
int16 remainingWidth = width;
|
||||
|
||||
// set up pointer
|
||||
displayScreen = _displayScreen + offsetDisplay;
|
||||
|
@ -617,7 +617,7 @@ bool AgiEngine::showPredictiveDialog() {
|
||||
|
||||
Common::String predictiveResult(predictiveDialog.getResult());
|
||||
uint16 predictiveResultLen = predictiveResult.size();
|
||||
if (predictiveResult.size()) {
|
||||
if (predictiveResultLen) {
|
||||
// User actually entered something
|
||||
for (int16 resultPos = 0; resultPos < predictiveResultLen; resultPos++) {
|
||||
keyEnqueue(predictiveResult[resultPos]);
|
||||
|
@ -164,13 +164,6 @@ void GfxMenu::addMenuItem(const char *menuItemText, uint16 controllerSlot) {
|
||||
}
|
||||
|
||||
void GfxMenu::submit() {
|
||||
GuiMenuEntry *menuEntry = nullptr;
|
||||
GuiMenuItemEntry *menuItemEntry = nullptr;
|
||||
int16 menuCount = _array.size();
|
||||
int16 menuNr = 0;
|
||||
int16 menuItemNr = 0;
|
||||
int16 menuItemLastNr = 0;
|
||||
|
||||
if ((_array.size() == 0) || (_itemArray.size() == 0))
|
||||
return;
|
||||
|
||||
@ -204,15 +197,16 @@ void GfxMenu::submit() {
|
||||
// Atari ST SQ1 had one bad menu entry as well, we fix that too.
|
||||
switch (_vm->getPlatform()) {
|
||||
case Common::kPlatformApple2GS:
|
||||
case Common::kPlatformAtariST:
|
||||
case Common::kPlatformAtariST: {
|
||||
// Go through all menus
|
||||
for (menuNr = 0; menuNr < menuCount; menuNr++) {
|
||||
menuEntry = _array[menuNr];
|
||||
menuItemLastNr = menuEntry->firstItemNr + menuEntry->itemCount;
|
||||
int16 menuCount = _array.size();
|
||||
for (int16 menuNr = 0; menuNr < menuCount; menuNr++) {
|
||||
GuiMenuEntry *menuEntry = _array[menuNr];
|
||||
int16 menuItemLastNr = menuEntry->firstItemNr + menuEntry->itemCount;
|
||||
|
||||
// Go through all items of current menu
|
||||
for (menuItemNr = menuEntry->firstItemNr; menuItemNr < menuItemLastNr; menuItemNr++) {
|
||||
menuItemEntry = _itemArray[menuItemNr];
|
||||
for (int16 menuItemNr = menuEntry->firstItemNr; menuItemNr < menuItemLastNr; menuItemNr++) {
|
||||
GuiMenuItemEntry *menuItemEntry = _itemArray[menuItemNr];
|
||||
|
||||
if (menuItemEntry->textLen < menuEntry->maxItemTextLen) {
|
||||
// current item text is shorter than the maximum?
|
||||
@ -270,6 +264,7 @@ void GfxMenu::submit() {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -284,32 +279,28 @@ void GfxMenu::itemDisable(uint16 controllerSlot) {
|
||||
}
|
||||
|
||||
void GfxMenu::itemEnableDisable(uint16 controllerSlot, bool enabled) {
|
||||
GuiMenuItemArray::iterator listIterator;
|
||||
GuiMenuItemArray::iterator listIterator = _itemArray.begin();
|
||||
GuiMenuItemArray::iterator listEnd = _itemArray.end();
|
||||
GuiMenuItemEntry *menuItemEntry;
|
||||
|
||||
listIterator = _itemArray.begin();
|
||||
while (listIterator != listEnd) {
|
||||
menuItemEntry = *listIterator;
|
||||
GuiMenuItemEntry *menuItemEntry = *listIterator;
|
||||
if (menuItemEntry->controllerSlot == controllerSlot) {
|
||||
menuItemEntry->enabled = enabled;
|
||||
}
|
||||
|
||||
listIterator++;
|
||||
++listIterator;
|
||||
}
|
||||
}
|
||||
|
||||
void GfxMenu::itemEnableAll() {
|
||||
GuiMenuItemArray::iterator listIterator;
|
||||
GuiMenuItemArray::iterator listIterator = _itemArray.begin();
|
||||
GuiMenuItemArray::iterator listEnd = _itemArray.end();
|
||||
GuiMenuItemEntry *menuItemEntry;
|
||||
|
||||
listIterator = _itemArray.begin();
|
||||
while (listIterator != listEnd) {
|
||||
menuItemEntry = *listIterator;
|
||||
GuiMenuItemEntry *menuItemEntry = *listIterator;
|
||||
menuItemEntry->enabled = true;
|
||||
|
||||
listIterator++;
|
||||
++listIterator;
|
||||
}
|
||||
}
|
||||
|
||||
@ -336,7 +327,7 @@ void GfxMenu::delayedExecuteViaMouse() {
|
||||
}
|
||||
|
||||
bool GfxMenu::delayedExecuteActive() {
|
||||
return _delayedExecuteViaKeyboard | _delayedExecuteViaMouse;
|
||||
return _delayedExecuteViaKeyboard || _delayedExecuteViaMouse;
|
||||
}
|
||||
|
||||
void GfxMenu::execute() {
|
||||
|
@ -83,10 +83,6 @@ void AgiBase::initFeatures() {
|
||||
_gameFeatures = _gameDescription->features;
|
||||
}
|
||||
|
||||
void AgiBase::setFeature(uint32 feature) {
|
||||
_gameFeatures |= feature;
|
||||
}
|
||||
|
||||
void AgiBase::initVersion() {
|
||||
_gameVersion = _gameDescription->version;
|
||||
}
|
||||
|
@ -39,14 +39,12 @@ bool AgiEngine::checkBlock(int16 x, int16 y) {
|
||||
}
|
||||
|
||||
void AgiEngine::changePos(ScreenObjEntry *screenObj) {
|
||||
bool insideBlock;
|
||||
int16 x, y;
|
||||
int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
|
||||
int dy[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 };
|
||||
const int dx[9] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };
|
||||
const int dy[9] = { 0, -1, -1, 0, 1, 1, 1, 0, -1 };
|
||||
|
||||
x = screenObj->xPos;
|
||||
y = screenObj->yPos;
|
||||
insideBlock = checkBlock(x, y);
|
||||
int16 x = screenObj->xPos;
|
||||
int16 y = screenObj->yPos;
|
||||
bool insideBlock = checkBlock(x, y);
|
||||
|
||||
x += screenObj->stepSize * dx[screenObj->direction];
|
||||
y += screenObj->stepSize * dy[screenObj->direction];
|
||||
@ -301,7 +299,7 @@ void AgiEngine::moveObj(ScreenObjEntry *screenObj) {
|
||||
* @param s step size
|
||||
*/
|
||||
int AgiEngine::getDirection(int16 objX, int16 objY, int16 destX, int16 destY, int16 stepSize) {
|
||||
int dirTable[9] = { 8, 1, 2, 7, 0, 3, 6, 5, 4 };
|
||||
const int dirTable[9] = { 8, 1, 2, 7, 0, 3, 6, 5, 4 };
|
||||
return dirTable[checkStep(destX - objX, stepSize) + 3 * checkStep(destY - objY, stepSize)];
|
||||
}
|
||||
|
||||
|
@ -1921,15 +1921,15 @@ void cmdDistance(AgiGame *state, AgiEngine *vm, uint8 *parameter) {
|
||||
uint16 objectNr1 = parameter[0];
|
||||
uint16 objectNr2 = parameter[1];
|
||||
uint16 destVarNr = parameter[2];
|
||||
int16 x1, y1, x2, y2, d;
|
||||
ScreenObjEntry *screenObj1 = &state->screenObjTable[objectNr1];
|
||||
ScreenObjEntry *screenObj2 = &state->screenObjTable[objectNr2];
|
||||
|
||||
int d;
|
||||
if (screenObj1->flags & fDrawn && screenObj2->flags & fDrawn) {
|
||||
x1 = screenObj1->xPos + screenObj1->xSize / 2;
|
||||
y1 = screenObj1->yPos;
|
||||
x2 = screenObj2->xPos + screenObj2->xSize / 2;
|
||||
y2 = screenObj2->yPos;
|
||||
int16 x1 = screenObj1->xPos + screenObj1->xSize / 2;
|
||||
int16 y1 = screenObj1->yPos;
|
||||
int16 x2 = screenObj2->xPos + screenObj2->xSize / 2;
|
||||
int16 y2 = screenObj2->yPos;
|
||||
d = ABS(x1 - x2) + ABS(y1 - y2);
|
||||
if (d > 0xfe)
|
||||
d = 0xfe;
|
||||
|
@ -216,7 +216,7 @@ void PictureMgr::plotPattern(int x, int y) {
|
||||
circle_ptr = &circle_data[circle_list[pen_size]];
|
||||
|
||||
// SGEORGE : Fix v3 picture data for drawing circles. Manifests in goldrush
|
||||
if (_pictureVersion == 3) {
|
||||
if (_pictureVersion == AGIPIC_V2) {
|
||||
circle_data[1] = 0;
|
||||
circle_data[3] = 0;
|
||||
}
|
||||
|
@ -626,7 +626,7 @@ void SystemUI::readSavedGameSlots(bool filterNonexistant, bool withAutoSaveSlot)
|
||||
SavedGameSlotIdArray::iterator it;
|
||||
SavedGameSlotIdArray::iterator end = slotIdArray.end();
|
||||
|
||||
for (it = slotIdArray.begin(); it != end; it++) {
|
||||
for (it = slotIdArray.begin(); it != end; ++it) {
|
||||
curSlotId = *it;
|
||||
|
||||
assert(curSlotId > lastSlotId); // safety check
|
||||
|
@ -293,10 +293,9 @@ void TextMgr::displayText(const char *textPtr, bool disabledLook) {
|
||||
}
|
||||
|
||||
const char *curTextPtr = textPtr;
|
||||
byte curCharacter = 0;
|
||||
|
||||
while (1) {
|
||||
curCharacter = *curTextPtr;
|
||||
byte curCharacter = *curTextPtr;
|
||||
if (!curCharacter)
|
||||
break;
|
||||
|
||||
@ -1082,10 +1081,8 @@ char *TextMgr::stringWordWrap(const char *originalText, int16 maxWidth, int16 *c
|
||||
int16 lineWidthLeft = maxWidth; // width left of current line
|
||||
|
||||
int16 wordStartPos = 0;
|
||||
int16 wordLen = 0;
|
||||
int16 curReadPos = 0;
|
||||
int16 curWritePos = 0;
|
||||
byte wordEndChar = 0;
|
||||
|
||||
//memset(resultWrappedBuffer, 0, sizeof(resultWrappedBuffer)); for debugging
|
||||
|
||||
@ -1108,10 +1105,10 @@ char *TextMgr::stringWordWrap(const char *originalText, int16 maxWidth, int16 *c
|
||||
break;
|
||||
curReadPos++;
|
||||
}
|
||||
wordEndChar = originalText[curReadPos];
|
||||
byte wordEndChar = originalText[curReadPos];
|
||||
|
||||
// Calculate word length
|
||||
wordLen = curReadPos - wordStartPos;
|
||||
int16 wordLen = curReadPos - wordStartPos;
|
||||
|
||||
if (wordLen >= lineWidthLeft) {
|
||||
// Not enough space left
|
||||
|
@ -95,22 +95,6 @@ int AgiEngine::decodeView(byte *resourceData, uint16 resourceSize, int16 viewNr)
|
||||
uint16 headerDescriptionOffset = 0;
|
||||
bool isAGI256Data = false;
|
||||
|
||||
AgiViewLoop *loopData = nullptr;
|
||||
uint16 loopOffset = 0;
|
||||
byte loopHeaderCelCount = 0;
|
||||
|
||||
AgiViewCel *celData = nullptr;
|
||||
uint16 celOffset = 0;
|
||||
byte celHeaderWidth = 0;
|
||||
byte celHeaderHeight = 0;
|
||||
byte celHeaderTransparencyMirror = 0;
|
||||
byte celHeaderClearKey = 0;
|
||||
bool celHeaderMirrored = false;
|
||||
byte celHeaderMirrorLoop = 0;
|
||||
|
||||
byte *celCompressedData = nullptr;
|
||||
uint16 celCompressedSize = 0;
|
||||
|
||||
debugC(5, kDebugLevelResources, "decode_view(%d)", viewNr);
|
||||
|
||||
if (resourceSize < 5)
|
||||
@ -158,11 +142,11 @@ int AgiEngine::decodeView(byte *resourceData, uint16 resourceSize, int16 viewNr)
|
||||
error("unexpected end of view data for view %d", viewNr);
|
||||
|
||||
// Allocate space for loop-information
|
||||
loopData = new AgiViewLoop[headerLoopCount];
|
||||
AgiViewLoop *loopData = new AgiViewLoop[headerLoopCount];
|
||||
viewData->loop = loopData;
|
||||
|
||||
for (int16 loopNr = 0; loopNr < headerLoopCount; loopNr++) {
|
||||
loopOffset = READ_LE_UINT16(resourceData + 5 + (loopNr * 2));
|
||||
int16 loopOffset = READ_LE_UINT16(resourceData + 5 + (loopNr * 2));
|
||||
|
||||
// Check, if at least the loop-header is available
|
||||
if (resourceSize < (loopOffset + 1))
|
||||
@ -173,7 +157,7 @@ int AgiEngine::decodeView(byte *resourceData, uint16 resourceSize, int16 viewNr)
|
||||
// relativeCelOffset[0]:WORD
|
||||
// relativeCelOffset[1]:WORD
|
||||
// etc.
|
||||
loopHeaderCelCount = resourceData[loopOffset];
|
||||
int16 loopHeaderCelCount = resourceData[loopOffset];
|
||||
|
||||
loopData->celCount = loopHeaderCelCount;
|
||||
loopData->cel = nullptr;
|
||||
@ -184,11 +168,11 @@ int AgiEngine::decodeView(byte *resourceData, uint16 resourceSize, int16 viewNr)
|
||||
|
||||
if (loopHeaderCelCount) {
|
||||
// Allocate space for cel-information of current loop
|
||||
celData = new AgiViewCel[loopHeaderCelCount];
|
||||
AgiViewCel *celData = new AgiViewCel[loopHeaderCelCount];
|
||||
loopData->cel = celData;
|
||||
|
||||
for (int16 celNr = 0; celNr < loopHeaderCelCount; celNr++) {
|
||||
celOffset = READ_LE_UINT16(resourceData + loopOffset + 1 + (celNr * 2));
|
||||
int16 celOffset = READ_LE_UINT16(resourceData + loopOffset + 1 + (celNr * 2));
|
||||
celOffset += loopOffset; // cel offset is relative to loop offset, so adjust accordingly
|
||||
|
||||
// Check, if at least the cel-header is available
|
||||
@ -200,10 +184,12 @@ int AgiEngine::decodeView(byte *resourceData, uint16 resourceSize, int16 viewNr)
|
||||
// height:BYTE
|
||||
// Transparency + Mirroring:BYTE
|
||||
// celData follows
|
||||
celHeaderWidth = resourceData[celOffset + 0];
|
||||
celHeaderHeight = resourceData[celOffset + 1];
|
||||
celHeaderTransparencyMirror = resourceData[celOffset + 2];
|
||||
int16 celHeaderWidth = resourceData[celOffset + 0];
|
||||
int16 celHeaderHeight = resourceData[celOffset + 1];
|
||||
byte celHeaderTransparencyMirror = resourceData[celOffset + 2];
|
||||
|
||||
byte celHeaderClearKey;
|
||||
bool celHeaderMirrored = false;
|
||||
if (!isAGI256Data) {
|
||||
// regular AGI view data
|
||||
// Transparency + Mirroring byte is as follows:
|
||||
@ -211,19 +197,17 @@ int AgiEngine::decodeView(byte *resourceData, uint16 resourceSize, int16 viewNr)
|
||||
// Bit 4-6 - original loop, that is not supposed to be mirrored in any case
|
||||
// Bit 7 - apply mirroring
|
||||
celHeaderClearKey = celHeaderTransparencyMirror & 0x0F; // bit 0-3 is the clear key
|
||||
celHeaderMirrored = false;
|
||||
if (celHeaderTransparencyMirror & 0x80) {
|
||||
// mirror bit is set
|
||||
celHeaderMirrorLoop = (celHeaderTransparencyMirror >> 4) & 0x07;
|
||||
byte celHeaderMirrorLoop = (celHeaderTransparencyMirror >> 4) & 0x07;
|
||||
if (celHeaderMirrorLoop != loopNr) {
|
||||
// only set to mirror'd in case we are not the original loop
|
||||
// only set to mirrored in case we are not the original loop
|
||||
celHeaderMirrored = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// AGI256-2 view data
|
||||
celHeaderClearKey = celHeaderTransparencyMirror; // full 8 bits for clear key
|
||||
celHeaderMirrored = false;
|
||||
}
|
||||
|
||||
celData->width = celHeaderWidth;
|
||||
@ -235,8 +219,8 @@ int AgiEngine::decodeView(byte *resourceData, uint16 resourceSize, int16 viewNr)
|
||||
if ((celHeaderWidth == 0) && (celHeaderHeight == 0))
|
||||
error("view cel is 0x0");
|
||||
|
||||
celCompressedData = resourceData + celOffset + 3;
|
||||
celCompressedSize = resourceSize - (celOffset + 3);
|
||||
byte *celCompressedData = resourceData + celOffset + 3;
|
||||
uint16 celCompressedSize = resourceSize - (celOffset + 3);
|
||||
|
||||
if (celCompressedSize == 0)
|
||||
error("compressed size of loop within view %d is 0 bytes", viewNr);
|
||||
@ -261,7 +245,6 @@ void AgiEngine::unpackViewCelData(AgiViewCel *celData, byte *compressedData, uin
|
||||
int16 remainingHeight = celData->height;
|
||||
int16 remainingWidth = celData->width;
|
||||
bool isMirrored = celData->mirrored;
|
||||
byte curByte;
|
||||
byte curColor;
|
||||
byte curChunkLen;
|
||||
int16 adjustPreChangeSingle = 0;
|
||||
@ -279,7 +262,7 @@ void AgiEngine::unpackViewCelData(AgiViewCel *celData, byte *compressedData, uin
|
||||
if (!compressedSize)
|
||||
error("unexpected end of data, while unpacking AGI256 data");
|
||||
|
||||
curByte = *compressedData++;
|
||||
byte curByte = *compressedData++;
|
||||
compressedSize--;
|
||||
|
||||
if (curByte == 0) {
|
||||
|
@ -250,7 +250,6 @@ int16 Words::findWordInDictionary(const Common::String &userInputLowcased, uint1
|
||||
uint16 wordStartPos = userInputPos;
|
||||
int16 wordId = DICTIONARY_RESULT_UNKNOWN;
|
||||
byte firstChar = userInputLowcased[userInputPos];
|
||||
byte curUserInputChar = 0;
|
||||
|
||||
foundWordLen = 0;
|
||||
|
||||
@ -277,12 +276,11 @@ int16 Words::findWordInDictionary(const Common::String &userInputLowcased, uint1
|
||||
// dictionary word is longer or same length as the remaining user input
|
||||
uint16 curCompareLeft = dictionaryWordLen;
|
||||
uint16 dictionaryWordPos = 0;
|
||||
byte curDictionaryChar = 0;
|
||||
|
||||
userInputPos = wordStartPos;
|
||||
while (curCompareLeft) {
|
||||
curUserInputChar = userInputLowcased[userInputPos];
|
||||
curDictionaryChar = dictionaryEntry->word[dictionaryWordPos];
|
||||
byte curUserInputChar = userInputLowcased[userInputPos];
|
||||
byte curDictionaryChar = dictionaryEntry->word[dictionaryWordPos];
|
||||
|
||||
if (curUserInputChar != curDictionaryChar)
|
||||
break;
|
||||
@ -329,8 +327,6 @@ void Words::parseUsingDictionary(const char *rawUserInput) {
|
||||
const char *userInputPtr = nullptr;
|
||||
uint16 userInputLen;
|
||||
uint16 userInputPos = 0;
|
||||
uint16 foundWordPos;
|
||||
int16 foundWordId;
|
||||
uint16 foundWordLen = 0;
|
||||
uint16 wordCount = 0;
|
||||
|
||||
@ -403,8 +399,8 @@ void Words::parseUsingDictionary(const char *rawUserInput) {
|
||||
if (userInput[userInputPos] == ' ')
|
||||
userInputPos++;
|
||||
|
||||
foundWordPos = userInputPos;
|
||||
foundWordId = findWordInDictionary(userInputLowcased, userInputLen, userInputPos, foundWordLen);
|
||||
uint16 foundWordPos = userInputPos;
|
||||
int16 foundWordId = findWordInDictionary(userInputLowcased, userInputLen, userInputPos, foundWordLen);
|
||||
|
||||
if (foundWordId != DICTIONARY_RESULT_IGNORE) {
|
||||
// word not supposed to get ignored
|
||||
|
Loading…
Reference in New Issue
Block a user