1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "gob/gob.h"
24 #include "gob/inter.h"
25 #include "gob/global.h"
26 #include "gob/util.h"
27 #include "gob/draw.h"
28 #include "gob/game.h"
29 #include "gob/script.h"
30 #include "gob/hotspots.h"
31 #include "gob/sound/sound.h"
32 
33 namespace Gob {
34 
35 #define OPCODEVER Inter_LittleRed
36 #define OPCODEDRAW(i, x)  _opcodesDraw[i]._OPCODEDRAW(OPCODEVER, x)
37 #define OPCODEFUNC(i, x)  _opcodesFunc[i]._OPCODEFUNC(OPCODEVER, x)
38 #define OPCODEGOB(i, x)   _opcodesGob[i]._OPCODEGOB(OPCODEVER, x)
39 
Inter_LittleRed(GobEngine * vm)40 Inter_LittleRed::Inter_LittleRed(GobEngine *vm) : Inter_v2(vm) {
41 }
42 
setupOpcodesDraw()43 void Inter_LittleRed::setupOpcodesDraw() {
44 	Inter_v2::setupOpcodesDraw();
45 }
46 
setupOpcodesFunc()47 void Inter_LittleRed::setupOpcodesFunc() {
48 	Inter_v2::setupOpcodesFunc();
49 
50 	OPCODEFUNC(0x14, oLittleRed_keyFunc);
51 
52 	OPCODEFUNC(0x3D, oLittleRed_playComposition);
53 }
54 
setupOpcodesGob()55 void Inter_LittleRed::setupOpcodesGob() {
56 	OPCODEGOB(1, o_gobNOP); // Sets some sound timer interrupt
57 	OPCODEGOB(2, o_gobNOP); // Sets some sound timer interrupt
58 
59 	OPCODEGOB(500, o2_playProtracker);
60 	OPCODEGOB(501, o2_stopProtracker);
61 }
62 
oLittleRed_keyFunc(OpFuncParams & params)63 void Inter_LittleRed::oLittleRed_keyFunc(OpFuncParams &params) {
64 	animPalette();
65 	_vm->_draw->blitInvalidated();
66 
67 	handleBusyWait();
68 
69 	int16 cmd = _vm->_game->_script->readInt16();
70 	int16 key;
71 	uint32 keyState;
72 
73 	switch (cmd) {
74 	case -1:
75 		break;
76 
77 	case 0:
78 		_vm->_draw->_showCursor &= ~2;
79 		_vm->_util->longDelay(1);
80 		key = _vm->_game->_hotspots->check(0, 0);
81 		storeKey(key);
82 
83 		_vm->_util->clearKeyBuf();
84 		break;
85 
86 	case 1:
87 		_vm->_util->forceMouseUp(true);
88 		key = _vm->_game->checkKeys(&_vm->_global->_inter_mouseX,
89 				&_vm->_global->_inter_mouseY, &_vm->_game->_mouseButtons, 0);
90 		storeKey(key);
91 		break;
92 
93 	case 2:
94 		_vm->_util->processInput(true);
95 		keyState = _vm->_util->getKeyState();
96 
97 		WRITE_VAR(0, keyState);
98 		_vm->_util->clearKeyBuf();
99 		break;
100 
101 	default:
102 		_vm->_sound->speakerOnUpdate(cmd);
103 		if (cmd < 20) {
104 			_vm->_util->delay(cmd);
105 			_noBusyWait = true;
106 		} else
107 			_vm->_util->longDelay(cmd);
108 		break;
109 	}
110 }
111 
oLittleRed_playComposition(OpFuncParams & params)112 void Inter_LittleRed::oLittleRed_playComposition(OpFuncParams &params) {
113 	o1_playComposition(params);
114 
115 	_vm->_sound->blasterRepeatComposition(-1);
116 }
117 
118 } // End of namespace Gob
119