aboutsummaryrefslogtreecommitdiff
path: root/engines/tony/mpal/mpaldll.h
blob: 8a52f1ed90455a6d752bb1ede2c51b37c6384b31 (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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
/* 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.
 *
 *
 */
/**************************************************************************
 *                                     ���������������������������������� *
 *                        ...                  Spyral Software snc        *
 *        .             x#""*$Nu       -= We create much MORE than ALL =- *
 *      d*#R$.          R     ^#$o     ���������������������������������� *
 *    .F    ^$k         $        "$b                                      *
 *   ."       $b      u "$         #$L                                    *
 *   P         $c    :*$L"$L        '$k  Project: MPAL................... *
 *  d    @$N.   $.   d ^$b^$k         $c                                  *
 *  F   4  "$c  '$   $   #$u#$u       '$ Module:  MPAL DLL Header........ *
 * 4    4k   *N  #b .>    '$N'*$u      *                                  *
 * M     $L   #$  $ 8       "$c'#$b.. .@ Author:  Giovanni Bajo.......... *
 * M     '$u   "$u :"         *$. "#*#"                                   *
 * M      '$N.  "  F           ^$k       Desc:    Header per i moduli per *
 * 4>       ^R$oue#             d                 la DLL di query di MPAL *
 * '$          ""              @                  ....................... *
 *  #b                       u#                                           *
 *   $b                    .@"           OS: [ ] DOS  [X] WIN95  [ ] OS/2 *
 *    #$u                .d"                                              *
 *     '*$e.          .zR".@           ���������������������������������� *
 *        "*$$beooee$*"  @"M                  This source code is         *
 *             """      '$.?              Copyright (C) Spyral Software   *
 *                       '$d>                 ALL RIGHTS RESERVED         *
 *                        '$>          ���������������������������������� *
 *                                                                        *
 **************************************************************************/

#ifndef __MPALDLL_H
#define __MPALDLL_H

#include "common/file.h"
#include "stubs.h"

namespace Tony {

namespace MPAL {

/****************************************************************************\
*       Defines
\****************************************************************************/

#define HEX_VERSION             0x0170

/*
  SICURA

#define MAX_ACTIONS_PER_ITEM    40
#define MAX_COMMANDS_PER_ITEM   256
#define MAX_COMMANDS_PER_ACTION 64
#define MAX_DESCRIBE_SIZE				128
*/

#define MAX_ACTIONS_PER_ITEM    40
#define MAX_COMMANDS_PER_ITEM   128
#define MAX_COMMANDS_PER_ACTION 128
#define MAX_DESCRIBE_SIZE				64



#define MAX_MOMENTS_PER_SCRIPT  256
#define MAX_COMMANDS_PER_SCRIPT 256
#define MAX_COMMANDS_PER_MOMENT 32





/*
   Versione sicura!

#define MAX_GROUPS_PER_DIALOG   128
#define MAX_COMMANDS_PER_DIALOG 640
#define MAX_COMMANDS_PER_GROUP  64
#define MAX_CHOICES_PER_DIALOG  64
#define MAX_SELECTS_PER_CHOICE  33
#define MAX_PLAYGROUPS_PER_SELECT 9
#define MAX_PERIODS_PER_DIALOG  640

*/

#define MAX_GROUPS_PER_DIALOG   128
#define MAX_COMMANDS_PER_DIALOG 480
#define MAX_COMMANDS_PER_GROUP  64
#define MAX_CHOICES_PER_DIALOG  64
#define MAX_SELECTS_PER_CHOICE  64
#define MAX_PLAYGROUPS_PER_SELECT 9
#define MAX_PERIODS_PER_DIALOG  400

/*
  Prima di Rufus:

#define MAX_GROUPS_PER_DIALOG   128
#define MAX_COMMANDS_PER_DIALOG 512
#define MAX_COMMANDS_PER_GROUP  32
#define MAX_CHOICES_PER_DIALOG  64
#define MAX_SELECTS_PER_CHOICE  32
#define MAX_PLAYGROUPS_PER_SELECT 4
#define MAX_PERIODS_PER_DIALOG  512
*/

#define NEED_LOCK_MSGS


/****************************************************************************\
*       Strutture
\****************************************************************************/

#include "common/pack-start.h"

/****************************************************************************\
*       typedef MPALVAR
*       ---------------
* Description: Variabile globale di MPAL
\****************************************************************************/

struct MPALVAR {
	uint32 dwVal;                   // Valore della variabile
	char lpszVarName[33];			// Nome della variabile
} PACKED_STRUCT;
typedef MPALVAR*        LPMPALVAR;
typedef LPMPALVAR*      LPLPMPALVAR;


/****************************************************************************\
*       typedef MPALMSG
*       ---------------
* Description: Messaggio di MPAL
\****************************************************************************/

struct MPALMSG {
  HGLOBAL hText;                // Handle al testo del messaggio
  uint16 wNum;                    // Numero del messaggio
} PACKED_STRUCT;
typedef MPALMSG*        LPMPALMSG;
typedef LPMPALMSG*      LPLPMPALMSG;


/****************************************************************************\
*       typedef MPALLOCATION
*       --------------------
* Description: Locazione di MPAL
\****************************************************************************/

struct MPALLOCATION {
	uint32 nObj;						// Numero della locazione
	uint32 dwXlen, dwYlen;			// Dimensione
	uint32 dwPicRes;				// Risorsa che contiene l'immagine
} PACKED_STRUCT;
typedef MPALLOCATION*   LPMPALLOCATION;
typedef LPMPALLOCATION* LPLPMPALLOCATION;


/****************************************************************************\
*       struct command
*       --------------
* Description: Gestisce un comando, cioe' le tag utilizzate dalle OnAction
*   negli item, dalle Time negli script e dai Group nei Dialog
\****************************************************************************/

struct command {
  /*
   * Tipi di comandi riconosciuti:
   *
   *   #1 -> Chiamata a funzione custom         (ITEM, SCRIPT, DIALOG)
   *   #2 -> Assegnazione di variabile          (ITEM, SCRIPT, DIALOG)
   *   #3 -> Esecuzione di una scelta           (DIALOG)
   *
   */
	byte  type;						// Tipo di comando

	union {
		int32 nCf;                  // Numero funzione custom         [#1]
		char *lpszVarName;			// Nome variabile                 [#2]
		int32 nChoice;              // Numero di scelta da fare       [#3]
	};

	union {
		int32 arg1;                 // Argomento 1 funzione custom    [#1]
		HGLOBAL expr;				// Espressione da assegnare alla
									//   variabile                    [#2]
	};

	int32 arg2,arg3,arg4;			// Argomenti per funzione custom  [#1]
} PACKED_STRUCT;

/****************************************************************************\
*       typedef MPALDIALOG
*       ------------------
* Description: Dialog di MPAL
\****************************************************************************/

struct MPALDIALOG {
	uint32 nObj;                    // Numero dialog

	struct command Command[MAX_COMMANDS_PER_DIALOG];

	struct {
		uint16 num;

		byte nCmds;
		uint16 CmdNum[MAX_COMMANDS_PER_GROUP];

	} Group[MAX_GROUPS_PER_DIALOG];

	struct {
		// L'ultima choice ha nChoice==0
		uint16 nChoice;

		// Non c'e' il numero di Select (siamo abbastanza avari di RAM). L'ultimo
		// select ha dwData==0
		struct {
			HGLOBAL when;
			uint32 dwData;
			uint16 wPlayGroup[MAX_PLAYGROUPS_PER_SELECT];

			// Bit 0=endchoice   Bit 1=enddialog
			byte attr;

			// Modificata a run-time: 0 se il select e' correntemente disabilitato,
			// 1 se e' correntemente attivato
			byte curActive;
		} Select[MAX_SELECTS_PER_CHOICE];

	} Choice[MAX_CHOICES_PER_DIALOG];

	uint16 PeriodNums[MAX_PERIODS_PER_DIALOG];
	HGLOBAL Periods[MAX_PERIODS_PER_DIALOG];

} PACKED_STRUCT;
typedef MPALDIALOG*     LPMPALDIALOG;
typedef LPMPALDIALOG*   LPLPMPALDIALOG;

/****************************************************************************\
*       typedef MPALITEM
*       ----------------
* Description: Item di MPAL
\****************************************************************************/

struct ItemAction {
	byte    num;                // Numero dell'azione
	uint16    wTime;              // In caso di idle, il tempo che deve passare
    byte    perc;               // Percentuale di eseguire l'idle
    HGLOBAL when;               // Espressione da calcolare: se !=0, allora
                                //  l'azione puo' essere eseguita
    uint16    wParm;              // Parametro per l'azione

    byte nCmds;                 // Numero comandi da eseguire
    uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire
} PACKED_STRUCT;

struct MPALITEM {
	uint32 nObj;                    // Numero item

	byte lpszDescribe[MAX_DESCRIBE_SIZE]; // Nome
	byte nActions;                // Numero delle azioni gestite
	uint32 dwRes;                  // Risorsa che contiene frame e pattern

	struct command Command[MAX_COMMANDS_PER_ITEM];

  // Array di strutture contenenti le varie azioni gestite. In pratica, di
  // ogni azione sappiamo quali comandi eseguire, tra quelli definiti nella
  // struttura qui sopra
/*
  struct
  {
    byte    num;                // Numero dell'azione
    uint16    wTime;              // In caso di idle, il tempo che deve passare
    byte    perc;               // Percentuale di eseguire l'idle
    HGLOBAL when;               // Espressione da calcolare: se !=0, allora
                                //  l'azione puo' essere eseguita
    uint16    wParm;              // Parametro per l'azione

    byte nCmds;                 // Numero comandi da eseguire
    uint32 CmdNum[MAX_COMMANDS_PER_ACTION]; // Comando da eseguire

  } Action[MAX_ACTIONS_PER_ITEM];
	*/
	struct ItemAction *Action;

} PACKED_STRUCT;
typedef MPALITEM*       LPMPALITEM;
typedef LPMPALITEM*     LPLPMPALITEM;


/****************************************************************************\
*       typedef MPALSCRIPT
*       ------------------
* Description: Script di MPAL
\****************************************************************************/

struct MPALSCRIPT {
	uint32 nObj;

	uint32 nMoments;

	struct command Command[MAX_COMMANDS_PER_SCRIPT];

	struct {
		int32 dwTime;

		byte nCmds;
		uint32 CmdNum[MAX_COMMANDS_PER_MOMENT];
  
	} Moment[MAX_MOMENTS_PER_SCRIPT];

} PACKED_STRUCT;
typedef MPALSCRIPT*     LPMPALSCRIPT;
typedef LPMPALSCRIPT*   LPLPMPALSCRIPT;

#include "common/pack-end.h"

/****************************************************************************\
*       Variabili globali
\****************************************************************************/

extern uint32                   mpalError;
extern LPLPCUSTOMFUNCTION       lplpFunctions;
extern uint16                   nObjs;

extern uint16                   nVars;
extern HGLOBAL                  hVars;
extern LPMPALVAR                lpmvVars;

extern uint16                   nMsgs;
extern HGLOBAL                  hMsgs;
extern LPMPALMSG                lpmmMsgs;

extern uint16					nDialogs;
extern HGLOBAL                  hDialogs;
extern LPMPALDIALOG             lpmdDialogs;

extern uint16                   nItems;
extern HGLOBAL                  hItems;
extern LPMPALITEM               lpmiItems;

extern uint16                   nLocations;
extern HGLOBAL                  hLocations;
extern LPMPALLOCATION           lpmlLocations;

extern uint16                   nScripts;
extern HGLOBAL                  hScripts;
extern LPMPALSCRIPT             lpmsScripts;

extern Common::File             hMpr;
extern uint16                   nResources;
extern uint32 *                 lpResources;

/****************************************************************************\
*       Prototipi di funzione
\****************************************************************************/

/****************************************************************************\
*
* Function:     int32 varGetValue(const char *lpszVarName);
*
* Description:  Restituisce il valore corrente di una variabile globale
*
* Input:        const char *lpszVarName       Nome della variabile
*
* Return:       Valore corrente
*
* Note:         Prima di questa funzione, bisogna richiamare LockVar() che
*               locka le variabili globali per l'utilizzo. Dopo inoltre bi-
*               sogna ricordarsi di chiamare UnlockVar()
*
\****************************************************************************/

int32 varGetValue(const char *lpszVarName);


/****************************************************************************\
*
* Function:     void varSetValue(const char *lpszVarName, int32 val);
*
* Description:  Setta un nuovo valore per una variabile globale di MPAL
*
* Input:        const char *lpszVarName       Nome della variabile
*               int32 val                 Valore da settare
*
\****************************************************************************/

void varSetValue(const char *lpszVarName, int32 val);

/****************************************************************************\
*       Includes the various modules
\****************************************************************************/

} // end of namespace MPAL

} // end of namespace Tony

#include "loadmpc.h"
#include "expr.h"

#endif