rocks_n_diamonds-0.9b2
[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             JustHit[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
68 int             AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
69 int             AmoebaCnt[MAX_NUM_AMOEBA];
70 long            Elementeigenschaften[MAX_ELEMENTS];
71
72 int             level_nr, leveldir_nr, num_leveldirs;
73 int             lev_fieldx,lev_fieldy, scroll_x,scroll_y;
74
75 int             LevelSolved,GameOver, JX,JY, ZX,ZY;
76 int             Gems,Dynamite,Key[4],TimeLeft,Score,MampferNr;
77 int             DynaBombCount, DynaBombSize, DynaBombsLeft;
78 int             CheckMoving,CheckExploding, SiebAktiv;
79
80 struct LevelDirInfo     leveldir[MAX_LEVDIR_ENTRIES];
81 struct LevelInfo        level;
82 struct PlayerInfo       player;
83 struct HiScore          highscore[MAX_SCORE_ENTRIES];
84 struct SoundInfo        Sound[NUM_SOUNDS];
85 struct RecordingInfo    tape,master_tape;
86
87 struct JoystickInfo joystick[2] =
88 {
89   JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
90   JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE,
91
92   JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
93   JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE
94 };
95
96 /* data needed for playing sounds */
97 char *sound_name[NUM_SOUNDS] =
98 {
99   "alchemy",
100   "amoebe",
101   "antigrav",
102   "autsch",
103   "blurb",
104   "bong",
105   "buing",
106   "chase",
107   "czardasz",
108   "deng",
109   "fuel",
110   "gong",
111   "halloffame",
112   "holz",
113   "hui",
114   "kabumm",
115   "kink",
116   "klapper",
117   "kling",
118   "klopf",
119   "klumpf",
120   "knack",
121   "knurk",
122   "krach",
123   "lachen",
124   "laser",
125   "miep",
126   "network",
127   "njam",
128   "oeffnen",
129   "pling",
130   "pong",
131   "pusch",
132   "quiek",
133   "quirk",
134   "rhythmloop",
135   "roaaar",
136   "roehr",
137   "rumms",
138   "schlopp",
139   "schlurf",
140   "schrff",
141   "schwirr",
142   "sirr",
143   "slurp",
144   "sproing",
145   "twilight",
146   "tyger",
147   "voyager",
148   "warnton",
149   "whoosh",
150   "zisch"
151 };
152
153 /* background music */
154 int background_loop[] =
155 {
156   SND_ALCHEMY,
157   SND_CHASE,
158   SND_NETWORK,
159   SND_CZARDASZ,
160   SND_TYGER,
161   SND_VOYAGER,
162   SND_TWILIGHT
163 };
164 int num_bg_loops = sizeof(background_loop)/sizeof(int);
165
166 char            *progname;
167
168 int main(int argc, char *argv[])
169 {
170   progname = argv[0];
171
172   OpenAll(argc,argv);
173   EventLoop();
174   CloseAll();
175
176   exit(0);
177 }