1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "common/endian.h"
#include "common/util.h"
/*
* SysEx command handlers must have full access to the
* internal IMuse implementation classes. Before including
* the relevant header file, two things must happen:
* 1. A function declaration must be made.
* 2. The following #define must be established:
* #define SYSEX_CALLBACK_FUNCTION functionName
*/
#define SYSEX_CALLBACK_FUNCTION sysexHandler_SamNMax
#include "scumm/imuse/imuse_internal.h"
namespace Scumm {
extern void sysexHandler_Scumm(Player *, const byte *, uint16);
void sysexHandler_SamNMax(Player *player, const byte *msg, uint16 len) {
byte a;
IMuseInternal *se = player->_se;
const byte *p = msg;
switch (*p++) {
case 0:
// Trigger Event
// Triggers are set by doCommand(ImSetTrigger).
// When a SysEx marker is encountered whose sound
// ID and marker ID match what was set by ImSetTrigger,
// something magical is supposed to happen....
for (a = 0; a < ARRAYSIZE(se->_snm_triggers); ++a) {
if (se->_snm_triggers[a].sound == player->_id &&
se->_snm_triggers[a].id == *p)
{
se->_snm_triggers[a].sound = se->_snm_triggers[a].id = 0;
se->doCommand(8, se->_snm_triggers[a].command);
break;
}
}
break;
case 1:
// maybe_jump.
if (player->_scanning)
break;
player->maybe_jump(p[0], p[1] - 1, (READ_BE_UINT16(p + 2) - 1) * 4 + p[4], ((p[5] * TICKS_PER_BEAT) >> 2) + p[6]);
break;
default:
sysexHandler_Scumm(player, msg, len);
}
}
} // End of namespace Scumm
|