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