aboutsummaryrefslogtreecommitdiff
path: root/saga/events.h
blob: a119d5dd46683390fb78ce220001999049f9f373 (plain)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/* ScummVM - Scumm Interpreter
 * Copyright (C) 2004-2005 The ScummVM project
 *
 * The ReInherit Engine is (C)2000-2003 by Daniel Balsom.
 *
 * 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 * $Header$
 *
 */

// Event management module header file

#ifndef SAGA_EVENT_H
#define SAGA_EVENT_H

#include "saga/list.h"

namespace Saga {

enum EVENT_TYPES {
	ONESHOT_EVENT,
	CONTINUOUS_EVENT,
	INTERVAL_EVENT,
	IMMEDIATE_EVENT
};

enum EVENT_FLAGS {
	SIGNALED = 0x8000,
	NODESTROY = 0x4000
};

enum EVENT_CODES {
	BG_EVENT = 1,
	ANIM_EVENT,
	MUSIC_EVENT,
	VOICE_EVENT,
	SOUND_EVENT,
	SCENE_EVENT,
	TEXT_EVENT,
	PAL_EVENT,
	PALANIM_EVENT,
	TRANSITION_EVENT,
	INTERFACE_EVENT,
	ACTOR_EVENT,
	SCRIPT_EVENT,
	CURSOR_EVENT
};

enum EVENT_OPS {
	// INSTANTANEOUS events
	// BG events
	EVENT_DISPLAY = 1,
	// ANIM events
	// EVENT_PLAY = 1, // reused
	// EVENT_STOP = 2, // reused
	EVENT_FRAME = 3,
	EVENT_SETFLAG = 4,
	EVENT_CLEARFLAG = 5,
	// MUISC & SOUND events
	EVENT_PLAY = 1,
	EVENT_STOP = 2,
	// SCENE events
	EVENT_END = 2,
	// TEXT events
	EVENT_HIDE = 2,
	EVENT_REMOVE = 3,
	// PALANIM events
	EVENT_CYCLESTART = 1,
	EVENT_CYCLESTEP = 2,
	// INTERFACE events
	EVENT_ACTIVATE = 1,
	EVENT_DEACTIVATE,
	// ACTOR events
	EVENT_MOVE = 1,
	// SCRIPT events
	EVENT_BLOCKING = 1,
	EVENT_NONBLOCKING = 2,
	// CURSOR events
	EVENT_SHOW = 1,
	// EVENT_HIDE = 2, // reused

	// CONTINUOUS events
	// PALETTE events
	EVENT_PALTOBLACK = 1,
	EVENT_BLACKTOPAL = 2,
	// TRANSITION events
	EVENT_DISSOLVE = 1,
	EVENT_DISSOLVE_BGMASK = 2
};

enum EVENT_PARAMS {
	NO_SET_PALETTE,
	SET_PALETTE
};

struct EVENT {
	unsigned int type;
	unsigned int code; // Event operation category & flags 
	int op;            // Event operation
	long param;        // Optional event parameter
	long param2;
	long param3;
	long param4;
	long param5;
	void *data;        // Optional event data
	long time;         // Elapsed time until event
	long duration;     // Duration of event
	long d_reserved;

	EVENT *chain;    // Event chain (For consecutive events)
	EVENT() { memset(this, 0, sizeof(*this)); }
};

typedef SortedList<EVENT> EventList;

#define EVENT_WARNINGCOUNT 1000
#define EVENT_MASK 0x00FF

enum EVENT_STATUSCODE {
	EVENT_INVALIDCODE = 0,
	EVENT_DELETE,
	EVENT_CONTINUE,
	EVENT_BREAK
};

class Events {
 public:
	Events(SagaEngine *vm);
	~Events(void);
	int handleEvents(long msec);
	int clearList();
	int freeList();
	EVENT *queue(EVENT *event);
	EVENT *chain(EVENT *eead_event, EVENT *add_event);

 private:
	int handleContinuous(EVENT * event);
	int handleOneShot(EVENT * event);
	int handleInterval(EVENT * event);
	int handleImmediate(EVENT *event);
	int processEventTime(long msec);
	int initializeEvent(EVENT * event);

 private:
	SagaEngine *_vm;
	bool _initialized;

	EventList _eventList;
};

} // End of namespace Saga

#endif