rocks_n_diamonds-0.9b
[rocksndiamonds.git] / src / main.c
1 /***********************************************************
2 *  Rocks'n'Diamonds -- McDuffin Strikes Back!              *
3 *----------------------------------------------------------*
4 *  ©1995 Artsoft Development                               *
5 *        Holger Schemel                                    *
6 *        33659 Bielefeld-Senne                             *
7 *        Telefon: (0521) 493245                            *
8 *        eMail: aeglos@valinor.owl.de                      *
9 *               aeglos@uni-paderborn.de                    *
10 *               q99492@pbhrzx.uni-paderborn.de             *
11 *----------------------------------------------------------*
12 *  main.c                                                  *
13 ***********************************************************/
14
15 #include "main.h"
16 #include "init.h"
17 #include "events.h"
18 #include "sound.h"
19
20 Display        *display;
21 int             screen;
22 Window          window;
23 GC              gc, plane_gc;
24 GC              clip_gc[NUM_PIXMAPS];
25 Pixmap          pix[NUM_PIXMAPS];
26 Pixmap          clipmask[NUM_PIXMAPS];
27 XpmAttributes   xpm_att[NUM_PICTURES];
28 Drawable        drawto, drawto_field, backbuffer;
29 Colormap        cmap;
30
31 int             sound_pipe[2];
32 int             sound_device;
33 char           *sound_device_name = SOUND_DEVICE;
34 int             joystick_device = 0;
35 char           *joystick_device_name[2] = { DEV_JOYSTICK_0, DEV_JOYSTICK_1 };
36 int             width, height;
37 unsigned long   pen_fg, pen_bg;
38
39 int             game_status = MAINMENU;
40 int             button_status = MB_NOT_PRESSED, motion_status = FALSE;
41 int             key_status = KEY_NOT_PRESSED;
42 int             global_joystick_status = JOYSTICK_STATUS;
43 int             joystick_status = JOYSTICK_STATUS;
44 int             sound_status = SOUND_STATUS, sound_on=TRUE;
45 int             sound_loops_allowed = FALSE, sound_loops_on = FALSE;
46 int             sound_music_on = FALSE;
47 int             toons_on = TRUE;
48 int             direct_draw_on = FALSE;
49 int             fading_on = FALSE;
50 int             autorecord_on = FALSE;
51 int             joystick_nr = 0;
52 int             quick_doors = FALSE;
53
54 BOOL            redraw[SCR_FIELDX][SCR_FIELDY];
55 int             redraw_mask;
56 int             redraw_tiles;
57
58 int             Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
59 int             Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
60 int             MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
61 int             MovDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
62 int             MovDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
63 int             Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
64 int             Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
65 int             Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
66 int             Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
67 int             AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
68 int             AmoebaCnt[MAX_NUM_AMOEBA];
69 long            Elementeigenschaften[MAX_ELEMENTS];
70
71 int             level_nr, leveldir_nr, num_leveldirs;
72 int             lev_fieldx,lev_fieldy, scroll_x,scroll_y;
73
74 int             LevelSolved,GameOver, JX,JY, ZX,ZY;
75 int             Gems,Dynamite,Key[4],TimeLeft,Score,MampferNr;
76 int             CheckMoving,CheckExploding, SiebAktiv;
77
78 struct LevelDirInfo     leveldir[MAX_LEVDIR_ENTRIES];
79 struct LevelInfo        level;
80 struct PlayerInfo       player;
81 struct HiScore          highscore[MAX_SCORE_ENTRIES];
82 struct SoundInfo        Sound[NUM_SOUNDS];
83 struct RecordingInfo    tape,master_tape;
84
85 struct JoystickInfo joystick[2] =
86 {
87   JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
88   JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE,
89
90   JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
91   JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE
92 };
93
94 /* data needed for playing sounds */
95 char *sound_name[NUM_SOUNDS] =
96 {
97   "alchemy",
98   "amoebe",
99   "antigrav",
100   "autsch",
101   "blurb",
102   "bong",
103   "buing",
104   "chase",
105   "czardasz",
106   "deng",
107   "fuel",
108   "gong",
109   "halloffame",
110   "holz",
111   "hui",
112   "kabumm",
113   "kink",
114   "klapper",
115   "kling",
116   "klopf",
117   "klumpf",
118   "knack",
119   "knurk",
120   "krach",
121   "lachen",
122   "laser",
123   "miep",
124   "network",
125   "njam",
126   "oeffnen",
127   "pling",
128   "pong",
129   "pusch",
130   "quiek",
131   "quirk",
132   "rhythmloop",
133   "roaaar",
134   "roehr",
135   "rumms",
136   "schlopp",
137   "schlurf",
138   "schrff",
139   "schwirr",
140   "sirr",
141   "slurp",
142   "sproing",
143   "twilight",
144   "tyger",
145   "voyager",
146   "warnton",
147   "whoosh",
148   "zisch"
149 };
150
151 /* background music */
152 int background_loop[] =
153 {
154   SND_ALCHEMY,
155   SND_CHASE,
156   SND_NETWORK,
157   SND_CZARDASZ,
158   SND_TYGER,
159   SND_VOYAGER,
160   SND_TWILIGHT
161 };
162 int num_bg_loops = sizeof(background_loop)/sizeof(int);
163
164 char            *progname;
165
166 int main(int argc, char *argv[])
167 {
168   progname = argv[0];
169
170   OpenAll(argc,argv);
171   EventLoop();
172   CloseAll();
173
174   exit(0);
175 }