LILLIPUT: Some refactoring, fix a bug in fixx16x16Rect

This commit is contained in:
Strangerke 2012-05-17 11:59:54 +02:00 committed by Eugene Sandulenko
parent 6dd3a1009d
commit 29b476fc56
3 changed files with 31 additions and 34 deletions

View file

@ -289,7 +289,7 @@ bool LilliputEngine::hasFeature(EngineFeature f) const {
} }
const char *LilliputEngine::getCopyrightString() const { const char *LilliputEngine::getCopyrightString() const {
return "copyright S.L.Grand, Brainware, 1991"; return "copyright S.L.Grand, Brainware, 1991 - 1992";
} }
GameType LilliputEngine::getGameType() const { GameType LilliputEngine::getGameType() const {
@ -301,9 +301,9 @@ Common::Platform LilliputEngine::getPlatform() const {
} }
void LilliputEngine::displayCharacter(int index, Common::Point pos, int flags) { void LilliputEngine::displayCharacter(int index, Common::Point pos, int flags) {
debugC(2, kDebugEngineTBC, "displayCharacter(%d, %d - %d, %d)", index, pos.x, pos.y, flags); debugC(2, kDebugEngine, "displayCharacter(%d, %d - %d, %d)", index, pos.x, pos.y, flags);
byte *buf = _savedSurfaceGameArea1 + (pos.y << 8) + pos.x; byte *buf = _savedSurfaceGameArea1 + (pos.y * 256) + pos.x;
byte *src = _bufferMen; byte *src = _bufferMen;
if (index < 0) { if (index < 0) {
@ -314,7 +314,7 @@ void LilliputEngine::displayCharacter(int index, Common::Point pos, int flags) {
index -= 0xF0; index -= 0xF0;
} }
src += ((index & 0xFF) << 8) + (index >> 8); src += (index * 256);
if ((flags & 2) == 0) { if ((flags & 2) == 0) {
for (int y = 0; y < 16; y++) { for (int y = 0; y < 16; y++) {
@ -342,11 +342,10 @@ void LilliputEngine::displayCharacter(int index, Common::Point pos, int flags) {
void LilliputEngine::display16x16IndexedBuf(byte *buf, int index, Common::Point pos) { void LilliputEngine::display16x16IndexedBuf(byte *buf, int index, Common::Point pos) {
debugC(2, kDebugEngine, "display16x16IndexedBuf(buf, %d, %d, %d)", index, pos.x, pos.y); debugC(2, kDebugEngine, "display16x16IndexedBuf(buf, %d, %d, %d)", index, pos.x, pos.y);
int index1 = ((index & 0xFF) << 8) + (index >> 8); int index1 = index * 16 * 16;
byte *newBuf = &buf[index1]; byte *newBuf = &buf[index1];
int tmpVal = ((pos.y & 0xFF) << 8) + (pos.y >> 8); int index2 = pos.x + (pos.y * 320);
int index2 = pos.x + tmpVal + (tmpVal >> 2);
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) { for (int j = 0; j < 16; j++) {
@ -369,8 +368,7 @@ void LilliputEngine::display16x16Buf(byte *buf, Common::Point pos) {
void LilliputEngine::SaveSurfaceUnderMouseCursor(byte *buf, Common::Point pos) { void LilliputEngine::SaveSurfaceUnderMouseCursor(byte *buf, Common::Point pos) {
debugC(2, kDebugEngine, "SaveSurfaceUnderMouseCursor(buf, %d, %d)", pos.x, pos.y); debugC(2, kDebugEngine, "SaveSurfaceUnderMouseCursor(buf, %d, %d)", pos.x, pos.y);
int tmpVal = ((pos.y & 0xFF) << 8) + (pos.y >> 8); int index2 = pos.x + (pos.y * 320);
int index2 = pos.x + tmpVal + (tmpVal >> 2);
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) { for (int j = 0; j < 16; j++) {
@ -380,12 +378,10 @@ void LilliputEngine::SaveSurfaceUnderMouseCursor(byte *buf, Common::Point pos) {
} }
} }
void LilliputEngine::fill16x16Rect(int var1, int var2, int var4) { void LilliputEngine::fill16x16Rect(byte col, Common::Point pos) {
debugC(2, kDebugEngineTBC, "fill16x16Rect(%d, %d, %d)", var1, var2, var4); debugC(2, kDebugEngineTBC, "fill16x16Rect(%d, %d - %d)", col, pos.x, pos.y);
int tmpVal = ((var4 >> 8) + (var4 & 0xFF)); int index = pos.x + (pos.y * 320);
int index = var2 + tmpVal + (tmpVal >> 2);
int col = var1 & 0xFF;
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
for (int j = 0; j < 16; j++) { for (int j = 0; j < 16; j++) {
((byte *)_mainSurface->getPixels())[index + j] = col; ((byte *)_mainSurface->getPixels())[index + j] = col;
@ -421,7 +417,7 @@ void LilliputEngine::restoreSurfaceUnderMousePointer() {
} }
void LilliputEngine::saveSurfaceGameArea() { void LilliputEngine::saveSurfaceGameArea() {
debugC(2, kDebugEngineTBC, "saveSurfaceGameArea()"); debugC(2, kDebugEngine, "saveSurfaceGameArea()");
restoreSurfaceUnderMousePointer(); restoreSurfaceUnderMousePointer();
@ -467,17 +463,16 @@ void LilliputEngine::restoreSurfaceSpeech() {
void LilliputEngine::displayInterfaceHotspots() { void LilliputEngine::displayInterfaceHotspots() {
debugC(2, kDebugEngineTBC, "displayInterfaceHotspots()"); debugC(2, kDebugEngine, "displayInterfaceHotspots()");
if (_displayMap == 1) if (_displayMap == 1)
return; return;
restoreSurfaceUnderMousePointer(); restoreSurfaceUnderMousePointer();
int index = 0;
int tmpVal; int tmpVal;
for (index = 0; index < _word12F68_ERULES; index++) { for (int index = 0; index < _word12F68_ERULES; index++) {
tmpVal = ((_scriptHandler->_array122E9[index] << 2) + (_scriptHandler->_array122E9[index] << 4)) & 0xFF; tmpVal = _scriptHandler->_array122E9[index] * 20;
display16x16IndexedBuf(_bufferIdeogram, tmpVal + index, Common::Point(_interfaceHotspotsX[index], _interfaceHotspotsY[index])); display16x16IndexedBuf(_bufferIdeogram, tmpVal + index, Common::Point(_interfaceHotspotsX[index], _interfaceHotspotsY[index]));
} }
@ -592,16 +587,18 @@ void LilliputEngine::displayFunction11(byte *buf) {
displayMousePointer(); displayMousePointer();
} }
void LilliputEngine::displayFunction12() { void LilliputEngine::initGameAreaDisplay() {
debugC(1, kDebugEngineTBC, "displayFunction12()"); debugC(1, kDebugEngine, "initGameAreaDisplay()");
restoreSurfaceUnderMousePointer(); restoreSurfaceUnderMousePointer();
// display background
byte *tmpBuf = loadVGA("SCREEN.GFX", 320 * 200, true); byte *tmpBuf = loadVGA("SCREEN.GFX", 320 * 200, true);
memcpy(_mainSurface->getPixels(), tmpBuf, 320 * 200); memcpy(_mainSurface->getPixels(), tmpBuf, 320 * 200);
_system->copyRectToScreen((byte *)_mainSurface->getPixels(), 320, 0, 0, 320, 200); _system->copyRectToScreen((byte *)_mainSurface->getPixels(), 320, 0, 0, 320, 200);
_system->updateScreen(); _system->updateScreen();
// display game area on top of background
saveSurfaceGameArea(); saveSurfaceGameArea();
saveSurfaceSpeech(); saveSurfaceSpeech();
displayInterfaceHotspots(); displayInterfaceHotspots();
@ -609,6 +606,7 @@ void LilliputEngine::displayFunction12() {
prepareGameArea(); prepareGameArea();
displayGameArea(); displayGameArea();
// display mouse pointer on top of the rest
displayMousePointer(); displayMousePointer();
free(tmpBuf); free(tmpBuf);
} }
@ -760,7 +758,7 @@ void LilliputEngine::setNextDisplayCharacter(int var1) {
} }
void LilliputEngine::prepareGameArea() { void LilliputEngine::prepareGameArea() {
debugC(2, kDebugEngineTBC, "prepareGameArea()"); debugC(2, kDebugEngine, "prepareGameArea()");
moveCharacters(); moveCharacters();
_currentDisplayCharacter = 0; _currentDisplayCharacter = 0;
@ -1006,7 +1004,7 @@ void LilliputEngine::checkMapClosing(bool &forceReturnFl) {
paletteFadeOut(); paletteFadeOut();
_word15AC2 = 0; _word15AC2 = 0;
sub130B6(); sub130B6();
displayFunction12(); initGameAreaDisplay();
_scriptHandler->_heroismLevel = 0; _scriptHandler->_heroismLevel = 0;
moveCharacters(); moveCharacters();
paletteFadeIn(); paletteFadeIn();
@ -1284,7 +1282,7 @@ void LilliputEngine::viewportScrollTo(Common::Point goalPos) {
} }
void LilliputEngine::renderCharacters(byte *buf, Common::Point pos) { void LilliputEngine::renderCharacters(byte *buf, Common::Point pos) {
debugC(2, kDebugEngineTBC, "renderCharacters(buf, %d - %d)", pos.x, pos.y); debugC(2, kDebugEngine, "renderCharacters(buf, %d - %d)", pos.x, pos.y);
if (_nextDisplayCharacterPos != pos) if (_nextDisplayCharacterPos != pos)
return; return;

View file

@ -219,7 +219,7 @@ public:
void display16x16IndexedBuf(byte *buf, int var1, Common::Point pos); void display16x16IndexedBuf(byte *buf, int var1, Common::Point pos);
void display16x16Buf(byte *buf, Common::Point pos); void display16x16Buf(byte *buf, Common::Point pos);
void SaveSurfaceUnderMouseCursor(byte *buf, Common::Point pos); void SaveSurfaceUnderMouseCursor(byte *buf, Common::Point pos);
void fill16x16Rect(int var1, int var2, int var4); void fill16x16Rect(byte col, Common::Point pos);
void displayMousePointer(); void displayMousePointer();
void restoreSurfaceUnderMousePointer(); void restoreSurfaceUnderMousePointer();
void saveSurfaceGameArea(); void saveSurfaceGameArea();
@ -228,7 +228,7 @@ public:
void displayLandscape(); void displayLandscape();
void displayFunction10(); void displayFunction10();
void displayFunction11(byte *buf); void displayFunction11(byte *buf);
void displayFunction12(); void initGameAreaDisplay();
void displayIsometricBlock(byte *buf, int var1, int var2, int var3); void displayIsometricBlock(byte *buf, int var1, int var2, int var3);
void displayGameArea(); void displayGameArea();
void prepareGameArea(); void prepareGameArea();

View file

@ -1358,7 +1358,7 @@ Common::Point LilliputScript::getPosFromScript() {
} }
void LilliputScript::sub130B6() { void LilliputScript::sub130B6() {
debugC(1, kDebugScriptTBC, "sub130B6()"); debugC(1, kDebugScript, "sub130B6()");
assert(_vm->_word12F68_ERULES <= 20); assert(_vm->_word12F68_ERULES <= 20);
for (int i = 0; i < _vm->_word12F68_ERULES; i++) { for (int i = 0; i < _vm->_word12F68_ERULES; i++) {
@ -3174,7 +3174,7 @@ void LilliputScript::OC_sub1853B() {
_heroismLevel = 0; _heroismLevel = 0;
sub130B6(); sub130B6();
_vm->displayFunction12(); _vm->initGameAreaDisplay();
OC_PaletteFadeIn(); OC_PaletteFadeIn();
_byte12A09 = 0; _byte12A09 = 0;
@ -3228,14 +3228,13 @@ void LilliputScript::OC_sub186A1() {
debugC(1, kDebugScriptTBC, "OC_sub186A1()"); debugC(1, kDebugScriptTBC, "OC_sub186A1()");
int var1 = getValue1(); int var1 = getValue1();
int var2 = _currScript->readUint16LE(); int posX = _currScript->readUint16LE();
int var3 = _currScript->readUint16LE(); int posY = _currScript->readUint16LE();
int var4 = 16; Common::Point pos = Common::Point(posX, posY);
_vm->fill16x16Rect(var4, var2, var3); _vm->fill16x16Rect(16, pos);
int frame = _vm->_characterFrameArray[var1]; int frame = _vm->_characterFrameArray[var1];
byte* buf = _vm->_bufferMen; byte* buf = _vm->_bufferMen;
if (frame > 0xF0) { if (frame > 0xF0) {
@ -3243,7 +3242,7 @@ void LilliputScript::OC_sub186A1() {
frame -= 0xF0; frame -= 0xF0;
} }
_vm->display16x16IndexedBuf(buf, frame, Common::Point(var2, var3)); _vm->display16x16IndexedBuf(buf, frame, pos);
} }
void LilliputScript::OC_sub186E5_snd() { void LilliputScript::OC_sub186E5_snd() {