rocks_n_diamonds-1.0
[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, clip_gc[NUM_PIXMAPS];
24 Pixmap          pix[NUM_PIXMAPS];
25 Pixmap          clipmask[NUM_PIXMAPS];
26 XpmAttributes   xpm_att[NUM_PICTURES];
27 Drawable        drawto, drawto_field, backbuffer;
28 Colormap        cmap;
29
30 int             sound_pipe[2];
31 int             sound_device;
32 char           *sound_device_name = SOUND_DEVICE;
33 int             joystick_device = 0;
34 char           *joystick_device_name[2] = { DEV_JOYSTICK_0, DEV_JOYSTICK_1 };
35 char           *level_directory = LEVEL_PATH;
36 int             width, height;
37 unsigned long   pen_fg, pen_bg;
38
39 int             game_status = MAINMENU;
40 int             game_emulation = EMU_NONE;
41 int             button_status = MB_NOT_PRESSED, motion_status = FALSE;
42 int             key_joystick_mapping = 0;
43 int             global_joystick_status = JOYSTICK_STATUS;
44 int             joystick_status = JOYSTICK_STATUS;
45 int             sound_status = SOUND_STATUS, sound_on = TRUE;
46 int             sound_loops_allowed = FALSE, sound_loops_on = FALSE;
47 int             sound_music_on = FALSE;
48 int             sound_simple_on = FALSE;
49 int             toons_on = TRUE;
50 int             direct_draw_on = FALSE;
51 int             scroll_delay_on = FALSE;
52 int             fading_on = FALSE;
53 int             autorecord_on = FALSE;
54 int             joystick_nr = 0;
55 int             quick_doors = FALSE;
56
57 BOOL            redraw[SCR_FIELDX][SCR_FIELDY];
58 int             redraw_mask;
59 int             redraw_tiles;
60
61 int             Feld[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
62 int             Ur[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
63 int             MovPos[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
64 int             MovDir[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
65 int             MovDelay[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
66 int             Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
67 int             Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
68 int             Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
69 int             Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
70 int             JustHit[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
71 int             AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY];
72 int             AmoebaCnt[MAX_NUM_AMOEBA], AmoebaCnt2[MAX_NUM_AMOEBA];
73 long            Elementeigenschaften[MAX_ELEMENTS];
74
75 int             level_nr, leveldir_nr, num_leveldirs;
76 int             lev_fieldx,lev_fieldy, scroll_x,scroll_y;
77
78 int             LevelSolved,GameOver, JX,JY, ZX,ZY;
79 int             FrameCounter,TimeFrames,TimeLeft,Score;
80 int             Gems,SokobanFields,Lights,Dynamite,Key[4],MampferNr;
81 int             DynaBombCount, DynaBombSize, DynaBombsLeft, DynaBombXL;
82 int             SiebAktiv;
83
84 struct LevelDirInfo     leveldir[MAX_LEVDIR_ENTRIES];
85 struct LevelInfo        level;
86 struct PlayerInfo       player;
87 struct HiScore          highscore[MAX_SCORE_ENTRIES];
88 struct SoundInfo        Sound[NUM_SOUNDS];
89 struct RecordingInfo    tape;
90
91 struct JoystickInfo joystick[2] =
92 {
93   { JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
94     JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE },
95   { JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE,
96     JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE }
97 };
98
99 /* data needed for playing sounds */
100 char *sound_name[NUM_SOUNDS] =
101 {
102   "alchemy",
103   "amoebe",
104   "antigrav",
105   "autsch",
106   "blurb",
107   "bong",
108   "buing",
109   "chase",
110   "czardasz",
111   "deng",
112   "fuel",
113   "gong",
114   "halloffame",
115   "holz",
116   "hui",
117   "kabumm",
118   "kink",
119   "klapper",
120   "kling",
121   "klopf",
122   "klumpf",
123   "knack",
124   "knurk",
125   "krach",
126   "lachen",
127   "laser",
128   "miep",
129   "network",
130   "njam",
131   "oeffnen",
132   "pling",
133   "pong",
134   "pusch",
135   "quiek",
136   "quirk",
137   "rhythmloop",
138   "roaaar",
139   "roehr",
140   "rumms",
141   "schlopp",
142   "schlurf",
143   "schrff",
144   "schwirr",
145   "sirr",
146   "slurp",
147   "sproing",
148   "twilight",
149   "tyger",
150   "voyager",
151   "warnton",
152   "whoosh",
153   "zisch"
154 };
155
156 /* background music */
157 int background_loop[] =
158 {
159   SND_ALCHEMY,
160   SND_CHASE,
161   SND_NETWORK,
162   SND_CZARDASZ,
163   SND_TYGER,
164   SND_VOYAGER,
165   SND_TWILIGHT
166 };
167 int num_bg_loops = sizeof(background_loop)/sizeof(int);
168
169 char            *progname;
170
171 int main(int argc, char *argv[])
172 {
173   progname = argv[0];
174
175   if (argc>1)
176     level_directory = argv[1];
177
178   OpenAll(argc,argv);
179   EventLoop();
180   CloseAll();
181
182   exit(0);
183 }