From 78c675278b1a232d2058b2d85eb089bfdec64b12 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 20 Apr 2008 12:34:16 +0000 Subject: Implemented opcodes: - 64: o3_checkInRect - 87: o3_stopMusic - 88: o3_playMusicTrack svn-id: r31595 --- engines/kyra/kyra_v3.cpp | 5 ++--- engines/kyra/kyra_v3.h | 8 +++++--- engines/kyra/script_v3.cpp | 43 ++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 47 insertions(+), 9 deletions(-) (limited to 'engines/kyra') diff --git a/engines/kyra/kyra_v3.cpp b/engines/kyra/kyra_v3.cpp index 9bca12cdb9..af0e8687e4 100644 --- a/engines/kyra/kyra_v3.cpp +++ b/engines/kyra/kyra_v3.cpp @@ -464,9 +464,8 @@ void KyraEngine_v3::playStudioSFX(const char *str) { void KyraEngine_v3::preinit() { debugC(9, kDebugLevelMain, "KyraEngine_v3::preinit()"); - _unkBuffer1040Bytes = new uint8[1040]; - _itemBuffer1 = new uint8[72]; - _itemBuffer2 = new uint8[144]; + _itemBuffer1 = new int8[72]; + _itemBuffer2 = new int8[144]; initMouseShapes(); initItems(); diff --git a/engines/kyra/kyra_v3.h b/engines/kyra/kyra_v3.h index 0a24e52f39..5706e0f575 100644 --- a/engines/kyra/kyra_v3.h +++ b/engines/kyra/kyra_v3.h @@ -258,8 +258,8 @@ private: uint8 *getTableEntry(uint8 *buffer, int id); // items - uint8 *_itemBuffer1; - uint8 *_itemBuffer2; + int8 *_itemBuffer1; + int8 *_itemBuffer2; struct Item { uint16 id; uint16 sceneId; @@ -505,7 +505,6 @@ private: int _newShapeDelay; // unk - uint8 *_unkBuffer1040Bytes; uint8 *_costPalBuffer; uint8 *_screenBuffer; uint8 *_gfxBackUpRect; @@ -541,6 +540,9 @@ private: int o3_badConscienceChat(ScriptState *script); int o3_delay(ScriptState *script); int o3_setSceneFilename(ScriptState *script); + int o3_checkInRect(ScriptState *script); + int o3_stopMusic(ScriptState *script); + int o3_playMusicTrack(ScriptState *script); int o3_playSoundEffect(ScriptState *script); int o3_getRand(ScriptState *script); int o3_defineRoomEntrance(ScriptState *script); diff --git a/engines/kyra/script_v3.cpp b/engines/kyra/script_v3.cpp index 4eca162734..ddab206790 100644 --- a/engines/kyra/script_v3.cpp +++ b/engines/kyra/script_v3.cpp @@ -206,6 +206,43 @@ int KyraEngine_v3::o3_setSceneFilename(ScriptState *script) { return 0; } +int KyraEngine_v3::o3_checkInRect(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_checkInRect(%p) (%d, %d, %d, %d, %d, %d)", (const void *)script, + stackPos(0), stackPos(1), stackPos(2), stackPos(3), stackPos(4), stackPos(5)); + const int x1 = stackPos(0); + const int y1 = stackPos(1); + const int x2 = stackPos(2); + const int y2 = stackPos(3); + int x = stackPos(4), y = stackPos(5); + if (_itemInHand >= 0) { + const int8 *desc = &_itemBuffer2[_itemInHand*2]; + x -= 12; + x += desc[0]; + y -= 19; + y += desc[1]; + } + + if (x >= x1 && x <= x2 && y >= y1 && y <= y2) { + //XXX + return 1; + } else { + //XXX + return 0; + } +} + +int KyraEngine_v3::o3_stopMusic(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_stopMusic(%p) ()", (const void *)script); + stopMusicTrack(); + return 0; +} + +int KyraEngine_v3::o3_playMusicTrack(ScriptState *script) { + debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_playMusicTrack(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); + playMusicTrack(stackPos(0), stackPos(1)); + return 0; +} + int KyraEngine_v3::o3_playSoundEffect(ScriptState *script) { debugC(3, kDebugLevelScriptFuncs, "KyraEngine_v3::o3_playSoundEffect(%p) (%d, %d)", (const void *)script, stackPos(0), stackPos(1)); playSoundEffect(stackPos(0), stackPos(1)); @@ -519,7 +556,7 @@ void KyraEngine_v3::setupOpcodeTable() { OpcodeUnImpl(), OpcodeUnImpl(), // 0x40 - OpcodeUnImpl(), + Opcode(o3_checkInRect), OpcodeUnImpl(), OpcodeUnImpl(), Opcode(o3_dummy), @@ -547,9 +584,9 @@ void KyraEngine_v3::setupOpcodeTable() { Opcode(o3_dummy), Opcode(o3_dummy), OpcodeUnImpl(), - OpcodeUnImpl(), + Opcode(o3_stopMusic), // 0x58 - OpcodeUnImpl(), + Opcode(o3_playMusicTrack), Opcode(o3_playSoundEffect), OpcodeUnImpl(), OpcodeUnImpl(), -- cgit v1.2.3