Skip to content
Permalink
Browse files

LILLIPUT: Fix a regresssion in scrollToViewportCharacterTarget(), som…

…e more renaming
  • Loading branch information
Strangerke committed Apr 16, 2018
1 parent 0922d44 commit f01af1690e1e8f7169ba8b263e1c9cf71bdfe287
Showing with 81 additions and 43 deletions.
  1. +22 −12 engines/lilliput/lilliput.cpp
  2. +9 −9 engines/lilliput/script.cpp
  3. +39 −15 engines/lilliput/sound.cpp
  4. +11 −7 engines/lilliput/sound.h
@@ -253,7 +253,7 @@ void LilliputEngine::update() {
}

void LilliputEngine::newInt8() {
_soundHandler->contentFct1();
_soundHandler->refresh();

if (_byte12A05 != 0)
--_byte12A05;
@@ -1129,19 +1129,29 @@ void LilliputEngine::scrollToViewportCharacterTarget() {
Common::Point newPos = _scriptHandler->_viewportPos;

if (tileX >= 1) {
if (tileX > 6)
newPos.x = CLIP(newPos.x + 4, 0, 56);
} else
newPos.x = CLIP(newPos.x - 4, 0, 56);
if (tileX > 6){
newPos.x += 4;
if (newPos.x > 56)
newPos.x = 56;
}
} else {
newPos.x -= 4;
if (newPos.x < 0)
newPos.x = 0;
}

if ((tileY < 1) && (newPos.y < 4))
newPos.y = 0;
else if (tileY >= 1)
newPos.y = CLIP(newPos.y + 4, 0, 56);
else
// CHECKME: not clipped?
newPos.y -= 4;
else {
if (tileY < 1)
newPos.y -= 4;

if (tileY > 6) {
newPos.y += 4;
if (newPos.y >= 56)
newPos.y = 56;
}
}
viewportScrollTo(newPos);
}

@@ -1182,7 +1192,7 @@ void LilliputEngine::viewportScrollTo(Common::Point goalPos) {
dy = 0;
} while ((dx != 0) || (dy != 0));

_soundHandler->contentFct5();
_soundHandler->update();
}

void LilliputEngine::renderCharacters(byte *buf, Common::Point pos) {
@@ -1664,7 +1674,7 @@ byte LilliputEngine::sequenceSound(int index, Common::Point var1) {
debugC(2, kDebugEngine, "sequenceSound(%d, %d - %d)", index, var1.x, var1.y);

int param4x = ((index | 0xFF00) >> 8);
_soundHandler->contentFct2(var1.y, _scriptHandler->_viewportPos,
_soundHandler->play(var1.y, _scriptHandler->_viewportPos,
_scriptHandler->_characterTilePos[index], Common::Point(param4x, 0));
return kSeqRepeat;
}
@@ -2286,7 +2286,7 @@ void LilliputScript::OC_DisableCharacter() {

void LilliputScript::OC_saveAndQuit() {
warning("TODO: OC_saveAndQuit");
_vm->_soundHandler->contentFct6(); // Kill music
_vm->_soundHandler->remove(); // Kill music
// TODO: Save game
_vm->_shouldQuit = true;
}
@@ -3213,7 +3213,7 @@ void LilliputScript::OC_initGameAreaDisplay() {
OC_PaletteFadeIn();
_vm->_refreshScreenFlag = false;

_vm->_soundHandler->contentFct5();
_vm->_soundHandler->update();
}

void LilliputScript::OC_displayCharacterStatBar() {
@@ -3291,7 +3291,7 @@ void LilliputScript::OC_playObjectSound() {
Common::Point var4 = Common::Point(0xFF, index & 0xFF);
int soundId = (_currScript->readUint16LE() & 0xFF);

_vm->_soundHandler->contentFct2(soundId, _viewportPos, _characterTilePos[index], var4);
_vm->_soundHandler->play(soundId, _viewportPos, _characterTilePos[index], var4);
}

void LilliputScript::OC_startLocationSound() {
@@ -3302,29 +3302,29 @@ void LilliputScript::OC_startLocationSound() {
Common::Point var2 = _viewportPos;
int var1 = (_currScript->readUint16LE() & 0xFF);

_vm->_soundHandler->contentFct2(var1, var2, var3, var4);
_vm->_soundHandler->play(var1, var2, var3, var4);
}

void LilliputScript::OC_stopObjectSound() {
debugC(1, kDebugScript, "OC_stopObjectSound()");

Common::Point var4 = Common::Point(-1, getValue1() & 0xFF);

_vm->_soundHandler->contentFct3(var4); // Stop Sound
_vm->_soundHandler->stop(var4); // Stop Sound
}

void LilliputScript::OC_stopLocationSound() {
debugC(1, kDebugScript, "OC_stopLocationSound()");

Common::Point var4 = getPosFromScript();

_vm->_soundHandler->contentFct3(var4);
_vm->_soundHandler->stop(var4);
}

void LilliputScript::OC_toggleSound() {
debugC(1, kDebugScript, "OC_toggleSound()");

_vm->_soundHandler->contentFct4();
_vm->_soundHandler->toggleOnOff();
}

void LilliputScript::OC_playMusic() {
@@ -3336,13 +3336,13 @@ void LilliputScript::OC_playMusic() {
warning("OC_playMusic: unknown value for var3");
Common::Point var3 = Common::Point(-1, -1);

_vm->_soundHandler->contentFct2(var1, var2, var3, var4);
_vm->_soundHandler->play(var1, var2, var3, var4);
}

void LilliputScript::OC_stopMusic() {
debugC(1, kDebugScript, "OC_stopMusic()");

_vm->_soundHandler->contentFct6();
_vm->_soundHandler->remove();
}

void LilliputScript::OC_setCharacterMapColor() {
@@ -31,35 +31,59 @@ LilliputSound::LilliputSound(LilliputEngine *vm) : _vm(vm) {
}

LilliputSound::~LilliputSound() {
free(_musicBuff);
}

// Used during initialisation
void LilliputSound::contentFct0() {
debugC(1, kDebugSound, "contentFct0()");
void LilliputSound::loadMusic(Common::String filename) {
debugC(1, kDebugSound, "loadMusic(%s)", filename.c_str());

Common::File f;

if (!f.open(filename))
error("Missing music file %s", filename.c_str());

byte *res = (byte *)malloc(sizeof(byte) * 50000);
for (int i = 0; i < 50000; ++i)
res[i] = f.readByte();

// f.close();
f.seek(0);
int filenumb = f.readUint16LE();



free(res);
}

// Used during initialization
void LilliputSound::init() {
debugC(1, kDebugSound, "LilliputSound::init()");

loadMusic("ROBIN.MUS");
}

void LilliputSound::contentFct1() {
debugC(1, kDebugSound, "contentFct1()");
void LilliputSound::refresh() {
debugC(1, kDebugSound, "LilliputSound::refresh()");
}

void LilliputSound::contentFct2(int var1, Common::Point var2, Common::Point var3, Common::Point var4) {
debugC(1, kDebugSound, "contentFct2(%d, %d - %d, %d - %d, %d - %d)", var1, var2.x, var2.y, var3.x, var3.y, var4.x, var4.y);
void LilliputSound::play(int var1, Common::Point var2, Common::Point var3, Common::Point var4) {
debugC(1, kDebugSound, "LilliputSound::play(%d, %d - %d, %d - %d, %d - %d)", var1, var2.x, var2.y, var3.x, var3.y, var4.x, var4.y);
}

void LilliputSound::contentFct3(Common::Point pos) {
debugC(1, kDebugSound, "contentFct3(%d - %d)", pos.x, pos.y);
void LilliputSound::stop(Common::Point pos) {
debugC(1, kDebugSound, "LilliputSound::stop(%d - %d)", pos.x, pos.y);
}

void LilliputSound::contentFct4() {
debugC(1, kDebugSound, "contentFct4()");
void LilliputSound::toggleOnOff() {
debugC(1, kDebugSound, "LilliputSound::toggleOnOff()");
}

void LilliputSound::contentFct5() {
debugC(1, kDebugSound, "contentFct5()");
void LilliputSound::update() {
debugC(1, kDebugSound, "LilliputSound::update()");
}

void LilliputSound::contentFct6() {
debugC(1, kDebugSound, "contentFct6()");
void LilliputSound::remove() {
debugC(1, kDebugSound, "Lilliput::remove()");
}

} // End of namespace
@@ -32,16 +32,20 @@ class LilliputSound {
LilliputSound(LilliputEngine *vm);
~LilliputSound();

void contentFct0();
void contentFct1();
void contentFct2(int var1, Common::Point var2, Common::Point var3, Common::Point var4);
void contentFct3(Common::Point pos);
void contentFct4();
void contentFct5();
void contentFct6();
void init();
void refresh();
void play(int var1, Common::Point var2, Common::Point var3, Common::Point var4);
void stop(Common::Point pos);
void toggleOnOff();
void update();
void remove();

private:
LilliputEngine *_vm;

byte *_musicBuff;

void loadMusic(Common::String filename);
};

} // End of namespace Lilliput

0 comments on commit f01af16

Please sign in to comment.
You can’t perform that action at this time.