1 /***********************************************************
2 * Rocks'n'Diamonds -- McDuffin Strikes Back! *
3 *----------------------------------------------------------*
4 * (c) 1995-98 Artsoft Entertainment *
8 * phone: ++49 +521 290471 *
9 * email: aeglos@valinor.owl.de *
10 *----------------------------------------------------------*
12 ***********************************************************/
29 extern unsigned char get_ascii(KeySym);
34 int x1 = SX+(SXSIZE - strlen(GAMETITLE_STRING) * FONT1_XSIZE) / 2;
36 int x2 = SX+(SXSIZE - strlen(COPYRIGHT_STRING) * FONT2_XSIZE) / 2;
39 DrawText(x1,y1, GAMETITLE_STRING, FS_BIG, FC_YELLOW);
40 DrawText(x2,y2, COPYRIGHT_STRING, FS_SMALL, FC_RED);
53 DrawText(SX + 32, SY + 2*32, "Name:", FS_BIG, FC_GREEN);
54 DrawText(SX + 6*32, SY + 2*32, local_player->alias_name, FS_BIG, FC_RED);
55 DrawText(SX + 32, SY + 3*32, "Level:", FS_BIG, FC_GREEN);
56 DrawText(SX + 11*32, SY + 3*32, int2str(level_nr,3), FS_BIG,
57 (level_nr<leveldir[leveldir_nr].levels ? FC_RED : FC_YELLOW));
58 DrawText(SX + 32, SY + 4*32, "Hall Of Fame", FS_BIG, FC_GREEN);
59 DrawText(SX + 32, SY + 5*32, "Level Creator", FS_BIG, FC_GREEN);
60 DrawText(SY + 32, SY + 6*32, "Info Screen", FS_BIG, FC_GREEN);
61 DrawText(SX + 32, SY + 7*32, "Start Game", FS_BIG, FC_GREEN);
62 DrawText(SX + 32, SY + 8*32, "Setup", FS_BIG, FC_GREEN);
63 DrawText(SX + 32, SY + 9*32, "Quit", FS_BIG, FC_GREEN);
65 DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS);
68 DrawGraphic(0,i,GFX_KUGEL_BLAU);
69 DrawGraphic(10,3,GFX_PFEIL_L);
70 DrawGraphic(14,3,GFX_PFEIL_R);
72 DrawText(SX+40+16,SY+326,"A Game by Artsoft Entertainment",FS_SMALL,FC_BLUE);
75 DrawText(SX+40+16,SY+344,"Graphics: Deluxe Paint IV Amiga",
77 DrawText(SX+60+16,SY+362,"Sounds: AudioMaster IV Amiga",
81 if (leveldir[leveldir_nr].name)
83 int len = strlen(leveldir[leveldir_nr].name);
84 int lxpos = SX+(SXSIZE-len*FONT4_XSIZE)/2;
87 DrawText(lxpos,lypos,leveldir[leveldir_nr].name,FS_SMALL,FC_SPECIAL2);
92 HandleMainMenu(0,0,0,0,MB_MENU_INITIALIZE);
95 if (TAPE_IS_EMPTY(tape))
96 LoadLevelTape(level_nr);
97 DrawCompleteVideoDisplay();
99 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
102 XAutoRepeatOn(display);
105 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
107 static int choice = 3;
108 static int redraw = TRUE;
109 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
111 if (redraw || button == MB_MENU_INITIALIZE)
113 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
117 if (button == MB_MENU_INITIALIZE)
124 x = (dx<0 ? 11 : 15);
141 if (!mx && !my && !dx && !dy)
147 if (y==4 && ((x==11 && level_nr>0) ||
148 (x==15 && level_nr<leveldir[leveldir_nr].levels-1)) &&
151 static long level_delay = 0;
152 int step = (button==1 ? 1 : button==2 ? 5 : 10);
153 int new_level_nr, old_level_nr = level_nr;
155 new_level_nr = level_nr + (x==11 ? -step : +step);
158 if (new_level_nr>leveldir[leveldir_nr].levels-1)
159 new_level_nr = leveldir[leveldir_nr].levels-1;
161 if (old_level_nr==new_level_nr || !DelayReached(&level_delay,150))
164 level_nr = new_level_nr;
166 DrawTextExt(drawto,gc,SX+11*32,SY+3*32,
167 int2str(level_nr,3), FS_BIG,FC_RED);
168 DrawTextExt(window,gc,SX+11*32,SY+3*32,
169 int2str(level_nr,3), FS_BIG,FC_RED);
172 DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS);
175 LoadLevelTape(level_nr);
176 DrawCompleteVideoDisplay();
178 /* needed because DrawMicroLevel() takes some time */
180 XSync(display,FALSE);
181 DelayReached(&level_delay,0); /* reset delay counter */
183 else if (x==1 && y>=3 && y<=10)
189 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
190 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
198 game_status = TYPENAME;
199 HandleTypeName(strlen(local_player->alias_name),0);
205 game_status = CHOOSELEVEL;
212 game_status = HALLOFFAME;
217 game_status = LEVELED;
218 if (leveldir[leveldir_nr].readonly)
219 Request("This level is read only !",REQ_CONFIRM);
224 game_status = HELPSCREEN;
229 if (setup.autorecord_on)
230 TapeStartRecording();
233 SendToServer_StartPlaying();
236 game_status = PLAYING;
248 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
249 game_status = EXITGAME;
260 if (game_status==MAINMENU)
264 #define MAX_HELPSCREEN_ELS 10
268 static long helpscreen_state;
269 static int helpscreen_step[MAX_HELPSCREEN_ELS];
270 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
271 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
272 static int helpscreen_action[] =
274 GFX_SPIELER1_DOWN,4,2,
276 GFX_SPIELER1_LEFT,4,2,
277 GFX_SPIELER1_RIGHT,4,2,
278 GFX_SPIELER1_PUSH_LEFT,4,2,
279 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
280 GFX_ERDREICH,1,100, HA_NEXT,
281 GFX_LEERRAUM,1,100, HA_NEXT,
282 GFX_MORAST_LEER,1,100, HA_NEXT,
283 GFX_BETON,1,100, HA_NEXT,
284 GFX_MAUERWERK,1,100, HA_NEXT,
285 GFX_MAUER_R1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
286 GFX_MAUER_L1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
287 GFX_UNSICHTBAR,1,100, HA_NEXT,
288 GFX_FELSBODEN,1,100, HA_NEXT,
289 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
290 GFX_EDELSTEIN,2,5, HA_NEXT,
291 GFX_DIAMANT,2,5, HA_NEXT,
292 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
293 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
294 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
295 GFX_FELSBROCKEN,4,5, HA_NEXT,
296 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
297 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
298 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
299 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
300 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
301 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
302 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
303 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
304 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
305 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
306 GFX_GEBLUBBER,4,4, HA_NEXT,
307 GFX_SCHLUESSEL1,4,25, HA_NEXT,
308 GFX_PFORTE1,4,25, HA_NEXT,
309 GFX_PFORTE1X,4,25, HA_NEXT,
310 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
311 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
312 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
313 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
314 GFX_LEERRAUM,1,10, HA_NEXT,
315 GFX_DYNABOMB_NR,1,100, HA_NEXT,
316 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
317 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
318 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
319 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
320 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
321 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
322 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
323 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
324 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
325 GFX_BUTTERFLY,2,2, HA_NEXT,
326 GFX_FIREFLY,2,2, HA_NEXT,
327 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
328 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
329 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
330 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
331 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
332 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
333 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
334 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
335 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
336 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
337 GFX_MAULWURF_DOWN,4,2,
339 GFX_MAULWURF_LEFT,4,2,
340 GFX_MAULWURF_RIGHT,4,2, HA_NEXT,
341 GFX_PINGUIN_DOWN,4,2,
343 GFX_PINGUIN_LEFT,4,2,
344 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
345 GFX_SCHWEIN_DOWN,4,2,
347 GFX_SCHWEIN_LEFT,4,2,
348 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
352 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
353 GFX_SONDE_START,8,1, HA_NEXT,
354 GFX_ABLENK,4,1, HA_NEXT,
355 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
356 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
357 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
358 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
359 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
360 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
361 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
362 GFX_DIAMANT,1,10, HA_NEXT,
363 GFX_LIFE,1,100, HA_NEXT,
364 GFX_LIFE_ASYNC,1,100, HA_NEXT,
365 GFX_SIEB_LEER,4,2, HA_NEXT,
366 GFX_SIEB2_LEER,4,2, HA_NEXT,
367 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
368 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
369 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
370 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
371 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
374 static char *helpscreen_eltext[][2] =
376 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
377 {"Normal sand:", "You can dig through it"},
378 {"Empty field:", "You can walk through it"},
379 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
380 {"Massive Wall:", "Nothing can go through it"},
381 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
382 {"Growing Wall: Grows to the left or", "right if there is an empty field"},
383 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
384 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
385 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
386 {"Emerald: You must collect enough of","them to finish a level"},
387 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
388 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
389 {"Colorful Gems:", "Seem to behave like Emeralds"},
390 {"Rock: Smashes several things;", "Can be moved by the player"},
391 {"Bomb: You can move it, but be", "careful when dropping it"},
392 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
393 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
394 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
395 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
396 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
397 {"Acid: Things that fall in are gone", "forever (including our hero)"},
398 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
399 {"Door: Can be opened by the key", "with the same color"},
400 {"Door: You have to find out the", "right color of the key for it"},
401 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
402 {"Dynamite: This one explodes after", "a few seconds"},
403 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
404 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
405 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
406 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
407 {"Bug: Moves at the right side", "of walls; don't touch it!"},
408 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
409 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
410 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
411 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
412 {"Cruncher (BD style):", "Eats almost everything"},
413 {"Robot: Tries to kill the player", ""},
414 {"The mole: You must guide him savely","to the exit; he will follow you"},
415 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
416 {"The Pig: Harmless, but eats all", "gems it can get"},
417 {"The Dragon: Breathes fire,", "especially to some monsters"},
418 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
419 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
420 {"Light Bulb: All of them must be", "switched on to finish a level"},
421 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
422 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
423 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
424 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
425 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
426 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
427 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
428 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
429 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
430 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
431 {"Exit door: Opens if you have enough","emeralds to finish the level"},
432 {"Open exit door: Enter here to leave","the level and exit the actual game"},
434 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
436 static char *helpscreen_music[][3] =
438 { "Alchemy", "Ian Boddy", "Drive" },
439 { "The Chase", "Propaganda", "A Secret Wish" },
440 { "Network 23", "Tangerine Dream", "Exit" },
441 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
442 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
443 { "Voyager", "The Alan Parsons Project","Pyramid" },
444 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
446 static int helpscreen_musicpos;
448 void DrawHelpScreenElAction(int start)
452 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
454 while(helpscreen_action[j] != HA_END)
456 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
458 else if (i<start || helpscreen_delay[i-start])
460 if (i>=start && helpscreen_delay[i-start])
461 helpscreen_delay[i-start]--;
463 while(helpscreen_action[j] != HA_NEXT)
470 j += 3*helpscreen_step[i-start];
471 graphic = helpscreen_action[j++];
473 if (helpscreen_frame[i-start])
475 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
476 helpscreen_frame[i-start]--;
481 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
484 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
486 if (helpscreen_action[j] == HA_NEXT)
488 if (!helpscreen_frame[i-start])
489 helpscreen_step[i-start] = 0;
493 if (!helpscreen_frame[i-start])
494 helpscreen_step[i-start]++;
495 while(helpscreen_action[j] != HA_NEXT)
500 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
511 void DrawHelpScreenElText(int start)
514 int xstart = SX+56, ystart = SY+65+2*32, ystep = TILEY+4;
515 char text[FULL_SXSIZE/FONT2_XSIZE+10];
520 sprintf(text,"The game elements:");
521 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
522 text,FS_SMALL,FC_GREEN);
524 for(i=start;i<start+MAX_HELPSCREEN_ELS && i<num_helpscreen_els;i++)
526 DrawText(xstart,ystart+(i-start)*ystep+(*helpscreen_eltext[i][1] ? 0 : 8),
527 helpscreen_eltext[i][0],FS_SMALL,FC_YELLOW);
528 DrawText(xstart,ystart+(i-start)*ystep+16,
529 helpscreen_eltext[i][1],FS_SMALL,FC_YELLOW);
532 sprintf(text,"Press any key or button for next page");
533 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
534 text,FS_SMALL,FC_BLUE);
537 void DrawHelpScreenMusicText(int num)
539 int ystart = 150, ystep = 30;
540 char text[FULL_SXSIZE/FONT2_XSIZE+10];
546 sprintf(text,"The game background music loops:");
547 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
548 text,FS_SMALL,FC_GREEN);
550 sprintf(text,"Excerpt from");
551 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep,
552 text,FS_SMALL,FC_YELLOW);
553 sprintf(text,"%c%s%c",'\"',helpscreen_music[num][0],'\"');
554 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep,
555 text,FS_SMALL,FC_RED);
557 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep,
558 text,FS_SMALL,FC_YELLOW);
559 sprintf(text,"%s",helpscreen_music[num][1]);
560 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep,
561 text,FS_SMALL,FC_RED);
562 sprintf(text,"from the album");
563 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
564 text,FS_SMALL,FC_YELLOW);
565 sprintf(text,"%c%s%c",'\"',helpscreen_music[num][2],'\"');
566 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+5*ystep,
567 text,FS_SMALL,FC_RED);
569 sprintf(text,"Press any key or button for next page");
570 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
571 text,FS_SMALL,FC_BLUE);
573 PlaySoundLoop(background_loop[num]);
576 void DrawHelpScreenCreditsText()
578 int ystart = 150, ystep = 30;
579 char text[FULL_SXSIZE/FONT2_XSIZE+10];
585 sprintf(text,"Program information:");
586 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
587 text,FS_SMALL,FC_GREEN);
589 sprintf(text,"This game is Freeware!");
590 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep,
591 text,FS_SMALL,FC_YELLOW);
592 sprintf(text,"If you like it, send e-mail to:");
593 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep,
594 text,FS_SMALL,FC_YELLOW);
595 sprintf(text,"aeglos@valinor.owl.de");
596 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep,
597 text,FS_SMALL,FC_RED);
598 sprintf(text,"or SnailMail to:");
599 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep,
600 text,FS_SMALL,FC_YELLOW);
601 sprintf(text,"Holger Schemel");
602 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
603 text,FS_SMALL,FC_RED);
604 sprintf(text,"Sennehof 28");
605 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+20,
606 text,FS_SMALL,FC_RED);
607 sprintf(text,"33659 Bielefeld");
608 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+40,
609 text,FS_SMALL,FC_RED);
610 sprintf(text,"Germany");
611 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+60,
612 text,FS_SMALL,FC_RED);
614 sprintf(text,"If you have created new levels,");
615 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+7*ystep,
616 text,FS_SMALL,FC_YELLOW);
617 sprintf(text,"send them to me to include them!");
618 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+8*ystep,
619 text,FS_SMALL,FC_YELLOW);
621 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+9*ystep,
622 text,FS_SMALL,FC_YELLOW);
624 sprintf(text,"Press any key or button for main menu");
625 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
626 text,FS_SMALL,FC_BLUE);
629 void DrawHelpScreen()
633 CloseDoor(DOOR_CLOSE_2);
635 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
636 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
637 helpscreen_musicpos = 0;
638 helpscreen_state = 0;
639 DrawHelpScreenElText(0);
640 DrawHelpScreenElAction(0);
644 PlaySoundLoop(SND_RHYTHMLOOP);
647 void HandleHelpScreen(int button)
649 static long hs_delay = 0;
650 int num_helpscreen_els_pages =
651 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
652 int button_released = !button;
657 if (helpscreen_state<num_helpscreen_els_pages-1)
659 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
660 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
662 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
663 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
665 else if (helpscreen_state<num_helpscreen_els_pages+num_bg_loops-1)
668 DrawHelpScreenMusicText(helpscreen_state-num_helpscreen_els_pages);
670 else if (helpscreen_state==num_helpscreen_els_pages+num_bg_loops-1)
673 DrawHelpScreenCreditsText();
679 game_status = MAINMENU;
684 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
686 if (helpscreen_state<num_helpscreen_els_pages)
687 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
695 void HandleTypeName(int newxpos, KeySym key)
697 static int xpos = 0, ypos = 2;
703 DrawText(SX+6*32, SY+ypos*32, local_player->alias_name, FS_BIG, FC_YELLOW);
704 DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
709 if ((key>=XK_A && key<=XK_Z) || (key>=XK_a && key<=XK_z &&
712 if (key>=XK_A && key<=XK_Z)
713 ascii = 'A'+(char)(key-XK_A);
714 if (key>=XK_a && key<=XK_z)
715 ascii = 'a'+(char)(key-XK_a);
717 if((ascii = get_ascii(key)) && xpos<MAX_NAMELEN-1)
720 local_player->alias_name[xpos] = ascii;
721 local_player->alias_name[xpos+1] = 0;
723 DrawTextExt(drawto,gc,SX+6*32,SY+ypos*32,
724 local_player->alias_name,FS_BIG,FC_YELLOW);
725 DrawTextExt(window,gc,SX+6*32,SY+ypos*32,
726 local_player->alias_name,FS_BIG,FC_YELLOW);
727 DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
729 else if ((key==XK_Delete || key==XK_BackSpace) && xpos>0)
732 local_player->alias_name[xpos] = 0;
733 DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
734 DrawGraphic(xpos+7,ypos,GFX_LEERRAUM);
736 else if (key==XK_Return && xpos>0)
738 DrawText(SX+6*32,SY+ypos*32,local_player->alias_name,FS_BIG,FC_RED);
739 DrawGraphic(xpos+6,ypos,GFX_LEERRAUM);
742 game_status = MAINMENU;
748 void DrawChooseLevel()
752 CloseDoor(DOOR_CLOSE_2);
755 DrawText(SX,SY,"Level Directories",FS_BIG,FC_GREEN);
756 for(i=0;i<num_leveldirs;i++)
758 DrawText(SX+32,SY+(i+2)*32,leveldir[i].name,FS_BIG,FC_YELLOW);
759 DrawGraphic(0,i+2,GFX_KUGEL_BLAU);
764 HandleChooseLevel(0,0,0,0,MB_MENU_INITIALIZE);
767 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
769 static int choice = 3;
770 static int redraw = TRUE;
771 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
773 if (button == MB_MENU_INITIALIZE)
776 choice = leveldir_nr + 3;
781 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
785 if (button == MB_MENU_INITIALIZE)
800 else if (y>num_leveldirs+2)
804 if (!mx && !my && !dx && !dy)
810 if (x==1 && y>=3 && y<=num_leveldirs+2)
816 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
817 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
827 LoadLevelTape(level_nr);
829 game_status = MAINMENU;
837 if (game_status==CHOOSELEVEL)
841 void DrawHallOfFame(int pos)
846 CloseDoor(DOOR_CLOSE_2);
851 DrawText(SX+64,SY+10,"Hall Of Fame",FS_BIG,FC_YELLOW);
852 sprintf(txt,"HighScores of Level %d",level_nr);
853 DrawText(SX+256-strlen(txt)*7,SY+48,txt,FS_SMALL,FC_RED);
854 for(y=0;y<MAX_SCORE_ENTRIES;y++)
856 DrawText(SX,SY+64+y*32,".................",FS_BIG,
857 (y==pos ? FC_RED : FC_GREEN));
858 DrawText(SX,SY+64+y*32,highscore[y].Name,FS_BIG,
859 (y==pos ? FC_RED : FC_GREEN));
860 DrawText(SX+12*32,SY+64+y*32,
861 int2str(highscore[y].Score,5),FS_BIG,
862 (y==pos ? FC_RED : FC_GREEN));
867 PlaySound(SND_HALLOFFAME);
870 void HandleHallOfFame(int button)
872 int button_released = !button;
876 FadeSound(SND_HALLOFFAME);
877 game_status = MAINMENU;
885 void DrawSetupScreen()
891 char *text, *mode[2];
894 { &setup.sound_on, "Sound:", { "on", "off" } },
895 { &setup.sound_loops_on, " Sound Loops:",{ "on", "off" } },
896 { &setup.sound_music_on, " Game Music:", { "on", "off" } },
897 { &setup.toons_on, "Toons:", { "on", "off" } },
898 { &setup.direct_draw_on, "Buffered gfx:",{ "off","on" } },
899 { &setup.scroll_delay_on, "Scroll Delay:",{ "on", "off" } },
900 { &setup.soft_scrolling_on, "Soft Scroll.:",{ "on", "off" } },
901 { &setup.fading_on, "Fading:", { "on", "off" } },
902 { &setup.quick_doors, "Quick Doors:", { "on", "off" } },
903 { &setup.autorecord_on, "Auto-Record:", { "on", "off" } },
904 { NULL, "Input Devices",{ "", "" } },
905 { NULL, "", { "", "" } },
906 { NULL, "", { "", "" } },
907 { NULL, "Exit", { "", "" } },
908 { NULL, "Save and exit",{ "", "" } }
911 CloseDoor(DOOR_CLOSE_2);
913 DrawText(SX+16, SY+16, "SETUP",FS_BIG,FC_YELLOW);
915 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
917 int base = i - SETUP_SCREEN_POS_START;
919 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
921 DrawGraphic(0,i,GFX_KUGEL_BLAU);
922 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
925 if (setup_info[base].value)
927 int setting_value = *setup_info[base].value;
928 int setting_pos = (setting_value != 0 ? 0 : 1);
929 int fc_on = (strcmp(setup_info[base].mode[setting_pos], "on") == 0);
931 DrawText(SX+14*32, SY+i*32, setup_info[base].mode[setting_pos],
932 FS_BIG, (fc_on ? FC_YELLOW : FC_BLUE));
938 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
941 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
943 static int choice = 3;
944 static int redraw = TRUE;
945 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
946 int pos_start = SETUP_SCREEN_POS_START + 1;
947 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
948 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
949 int pos_end = SETUP_SCREEN_POS_END + 1;
951 if (button == MB_MENU_INITIALIZE)
956 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
960 if (button == MB_MENU_INITIALIZE)
973 if (y >= pos_empty1 && y <= pos_empty2)
974 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
978 else if (y > pos_end)
982 if (!mx && !my && !dx && !dy)
988 if (x==1 && y >= pos_start && y <= pos_end &&
989 !(y >= pos_empty1 && y <= pos_empty2))
995 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
996 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
1004 if (y==3 && sound_status==SOUND_AVAILABLE)
1008 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1009 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1010 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1011 setup.sound_loops_on = FALSE;
1012 setup.sound_music_on = FALSE;
1015 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1016 setup.sound_on = !setup.sound_on;
1018 else if (y==4 && sound_loops_allowed)
1020 if (setup.sound_loops_on)
1021 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1024 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1025 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1026 setup.sound_on = TRUE;
1028 setup.sound_loops_on = !setup.sound_loops_on;
1030 else if (y==5 && sound_loops_allowed)
1032 if (setup.sound_music_on)
1033 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1036 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1037 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1038 setup.sound_on = TRUE;
1040 setup.sound_music_on = !setup.sound_music_on;
1045 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1047 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1048 setup.toons_on = !setup.toons_on;
1052 if (!setup.direct_draw_on)
1053 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1055 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1056 setup.direct_draw_on = !setup.direct_draw_on;
1060 if (setup.scroll_delay_on)
1061 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1063 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1064 setup.scroll_delay_on = !setup.scroll_delay_on;
1068 if (setup.soft_scrolling_on)
1069 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1071 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1072 setup.soft_scrolling_on = !setup.soft_scrolling_on;
1076 if (setup.fading_on)
1077 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1079 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1080 setup.fading_on = !setup.fading_on;
1084 if (setup.quick_doors)
1085 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1087 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1088 setup.quick_doors = !setup.quick_doors;
1092 if (setup.autorecord_on)
1093 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1095 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1096 setup.autorecord_on = !setup.autorecord_on;
1100 game_status = SETUPINPUT;
1101 DrawSetupInputScreen();
1104 else if (y==pos_end-1 || y==pos_end)
1112 game_status = MAINMENU;
1120 if (game_status==SETUP)
1124 void DrawSetupInputScreen()
1127 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1129 DrawGraphic(0, 2, GFX_KUGEL_BLAU);
1130 DrawGraphic(0, 3, GFX_KUGEL_BLAU);
1131 DrawGraphic(0, 4, GFX_KUGEL_BLAU);
1132 DrawGraphic(0, 15, GFX_KUGEL_BLAU);
1133 DrawGraphic(10, 2, GFX_PFEIL_L);
1134 DrawGraphic(12, 2, GFX_PFEIL_R);
1136 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1137 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1138 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1142 HandleSetupInputScreen(0,0,0,0,MB_MENU_INITIALIZE);
1145 static void drawPlayerSetupInputInfo(int player_nr)
1148 static struct SetupKeyboardInfo custom_key;
1155 { &custom_key.left, "Joystick Left" },
1156 { &custom_key.right, "Joystick Right" },
1157 { &custom_key.up, "Joystick Up" },
1158 { &custom_key.down, "Joystick Down" },
1159 { &custom_key.snap, "Button 1" },
1160 { &custom_key.bomb, "Button 2" }
1163 custom_key = setup.input[player_nr].key;
1165 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1166 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1168 if (setup.input[player_nr].use_joystick)
1170 DrawText(SX+8*32, SY+3*32,
1171 (setup.input[player_nr].joystick_nr == 0 ?
1172 "Joystick1" : "Joystick2"),
1174 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1178 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1179 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1182 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1183 DrawGraphic(1, 6, GFX_PFEIL_L);
1184 DrawGraphic(1, 7, GFX_PFEIL_R);
1185 DrawGraphic(1, 8, GFX_PFEIL_O);
1186 DrawGraphic(1, 9, GFX_PFEIL_U);
1187 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1188 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1189 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1190 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1191 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1192 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1196 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1198 DrawText(SX + 3*32, SY + ypos*32,
1199 " ", FS_BIG, FC_YELLOW);
1200 DrawText(SX + 3*32, SY + ypos*32,
1201 (setup.input[player_nr].use_joystick ?
1203 getKeyNameFromKeySym(*custom[i].keysym)),
1208 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1210 static int choice = 3;
1211 static int player_nr = 0;
1212 static int redraw = TRUE;
1213 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1214 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1215 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1216 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1217 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1219 if (button == MB_MENU_INITIALIZE)
1221 drawPlayerSetupInputInfo(player_nr);
1227 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1231 if (button == MB_MENU_INITIALIZE)
1236 if (dx && choice == 3)
1238 x = (dx < 0 ? 11 : 13);
1241 else if (dx && choice == 4)
1243 button = MB_MENU_CHOICE;
1255 if (y >= pos_empty1 && y <= pos_empty2)
1256 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1260 else if (y > pos_end)
1264 if (!mx && !my && !dx && !dy)
1270 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1272 static long delay = 0;
1274 if (!DelayReached(&delay,150))
1277 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1279 drawPlayerSetupInputInfo(player_nr);
1281 else if (x==1 && y >= pos_start && y <= pos_end &&
1282 !(y >= pos_empty1 && y <= pos_empty2))
1288 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
1289 DrawGraphic(0, choice-1, GFX_KUGEL_BLAU);
1297 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1298 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1300 if (setup.input[player_nr].use_joystick)
1302 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1303 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1305 setup.input[player_nr].use_joystick = FALSE;
1309 setup.input[player_nr].use_joystick = TRUE;
1310 setup.input[player_nr].joystick_nr = one_joystick_nr;
1313 drawPlayerSetupInputInfo(player_nr);
1317 if (setup.input[player_nr].use_joystick)
1318 CalibrateJoystick(setup.input[player_nr].joystick_nr);
1320 CustomizeKeyboard(player_nr);
1324 else if (y == pos_end)
1326 game_status = SETUP;
1336 if (game_status == SETUPINPUT)
1340 void CustomizeKeyboard(int player_nr)
1344 boolean finished = FALSE;
1345 static struct SetupKeyboardInfo custom_key;
1350 } customize_step[] =
1352 { &custom_key.left, "Move Left" },
1353 { &custom_key.right, "Move Right" },
1354 { &custom_key.up, "Move Up" },
1355 { &custom_key.down, "Move Down" },
1356 { &custom_key.snap, "Snap Field" },
1357 { &custom_key.bomb, "Place Bomb" }
1360 /* read existing key bindings from player setup */
1361 custom_key = setup.input[player_nr].key;
1364 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1370 DrawText(SX, SY + (2+2*step_nr)*32,
1371 customize_step[step_nr].text, FS_BIG, FC_RED);
1372 DrawText(SX, SY + (2+2*step_nr+1)*32,
1373 "Key:", FS_BIG, FC_RED);
1374 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1375 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1380 if (XPending(display)) /* got event from X server */
1384 XNextEvent(display, &event);
1390 KeySym key = XLookupKeysym((XKeyEvent *)&event,
1391 ((XKeyEvent *)&event)->state);
1393 if (key == XK_Escape || (key == XK_Return && step_nr == 6))
1399 /* press 'Enter' to keep the existing key binding */
1400 if (key == XK_Return || step_nr == 6)
1401 key = *customize_step[step_nr].keysym;
1403 /* check if key already used */
1404 for (i=0; i<step_nr; i++)
1405 if (*customize_step[i].keysym == key)
1410 /* got new key binding */
1411 *customize_step[step_nr].keysym = key;
1412 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1413 " ", FS_BIG, FC_YELLOW);
1414 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1415 getKeyNameFromKeySym(key), FS_BIG, FC_YELLOW);
1418 /* un-highlight last query */
1419 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1420 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1421 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1422 "Key:", FS_BIG, FC_GREEN);
1424 /* press 'Enter' to leave */
1427 DrawText(SX + 16, SY + 15*32+16,
1428 "Press Enter", FS_BIG, FC_YELLOW);
1432 /* query next key binding */
1433 DrawText(SX, SY+(2+2*step_nr)*32,
1434 customize_step[step_nr].text, FS_BIG, FC_RED);
1435 DrawText(SX, SY+(2+2*step_nr+1)*32,
1436 "Key:", FS_BIG, FC_RED);
1437 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1438 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1444 key_joystick_mapping = 0;
1448 HandleOtherEvents(&event);
1456 /* don't eat all CPU time */
1460 /* write new key bindings back to player setup */
1461 setup.input[player_nr].key = custom_key;
1464 DrawSetupInputScreen();
1467 void CalibrateJoystick(int joystick_nr)
1470 struct joystick joy_ctrl;
1472 struct joystick_control
1484 int new_joystick_xleft = 128, new_joystick_xright = 128;
1485 int new_joystick_yupper = 128, new_joystick_ylower = 128;
1486 int new_joystick_xmiddle, new_joystick_ymiddle;
1487 int x, y, last_x, last_y, xpos = 8, ypos = 3;
1488 boolean check[3][3];
1489 int check_remaining = 3 * 3;
1493 if (joystick_status == JOYSTICK_OFF)
1497 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ",FS_BIG,FC_YELLOW);
1498 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS",FS_BIG,FC_YELLOW);
1499 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ",FS_BIG,FC_YELLOW);
1500 DrawText(SX, SY + 10*32, " ARE YELLOW, ",FS_BIG,FC_YELLOW);
1501 DrawText(SX, SY + 11*32, " PRESS BUTTON! ",FS_BIG,FC_YELLOW);
1507 check[x][y] = FALSE;
1508 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
1513 last_x = (joy & JOY_LEFT ? -1 : joy & JOY_RIGHT ? +1 : 0);
1514 last_y = (joy & JOY_UP ? -1 : joy & JOY_DOWN ? +1 : 0);
1515 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
1520 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1522 joy_ctrl.buttons = 0;
1525 while(Joystick() & JOY_BUTTON);
1531 if (XPending(display)) /* got event from X server */
1535 XNextEvent(display, &event);
1540 switch(XLookupKeysym((XKeyEvent *)&event,
1541 ((XKeyEvent *)&event)->state))
1544 if (check_remaining == 0)
1558 key_joystick_mapping = 0;
1562 HandleOtherEvents(&event);
1567 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1569 joystick_status = JOYSTICK_OFF;
1573 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
1574 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
1575 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
1576 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
1578 new_joystick_xmiddle =
1579 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
1580 new_joystick_ymiddle =
1581 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
1583 joystick[joystick_nr].xleft = new_joystick_xleft;
1584 joystick[joystick_nr].yupper = new_joystick_yupper;
1585 joystick[joystick_nr].xright = new_joystick_xright;
1586 joystick[joystick_nr].ylower = new_joystick_ylower;
1587 joystick[joystick_nr].xmiddle = new_joystick_xmiddle;
1588 joystick[joystick_nr].ymiddle = new_joystick_ymiddle;
1590 CheckJoystickData();
1594 if (joy & JOY_BUTTON && check_remaining == 0)
1597 x = (joy & JOY_LEFT ? -1 : joy & JOY_RIGHT ? +1 : 0);
1598 y = (joy & JOY_UP ? -1 : joy & JOY_DOWN ? +1 : 0);
1600 if (x != last_x || y != last_y)
1602 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
1603 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
1608 if (check_remaining > 0 && !check[x+1][y+1])
1610 check[x+1][y+1] = TRUE;
1615 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
1616 joystick[joystick_nr].xleft,
1617 joystick[joystick_nr].xmiddle,
1618 joystick[joystick_nr].xright);
1619 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
1620 joystick[joystick_nr].yupper,
1621 joystick[joystick_nr].ymiddle,
1622 joystick[joystick_nr].ylower);
1629 /* don't eat all CPU time */
1635 DrawSetupInputScreen();
1636 while(Joystick() & JOY_BUTTON);
1642 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
1643 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
1646 DrawSetupInputScreen();
1649 void CalibrateJoystick_OLD()
1652 struct joystick joy_ctrl;
1654 struct joystick_control
1666 int joystick_nr = setup.input[0].joystick_nr;
1667 int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
1668 int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
1670 if (joystick_status == JOYSTICK_OFF)
1675 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1676 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1677 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1681 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1683 joy_ctrl.buttons = 0;
1685 while(Joystick() & JOY_BUTTON);
1687 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1689 while(!joy_ctrl.buttons)
1692 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1694 joystick_status=JOYSTICK_OFF;
1700 new_joystick_xleft = joy_ctrl.x;
1701 new_joystick_yupper = joy_ctrl.y;
1704 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1705 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1706 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1710 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1712 joy_ctrl.buttons = 0;
1714 while(Joystick() & JOY_BUTTON);
1716 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1718 while(!joy_ctrl.buttons)
1721 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1723 joystick_status=JOYSTICK_OFF;
1729 new_joystick_xright = joy_ctrl.x;
1730 new_joystick_ylower = joy_ctrl.y;
1733 DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
1734 DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1738 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1740 joy_ctrl.buttons = 0;
1742 while(Joystick() & JOY_BUTTON);
1744 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1746 while(!joy_ctrl.buttons)
1749 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1751 joystick_status=JOYSTICK_OFF;
1757 new_joystick_xmiddle = joy_ctrl.x;
1758 new_joystick_ymiddle = joy_ctrl.y;
1760 joystick[joystick_nr].xleft = new_joystick_xleft;
1761 joystick[joystick_nr].yupper = new_joystick_yupper;
1762 joystick[joystick_nr].xright = new_joystick_xright;
1763 joystick[joystick_nr].ylower = new_joystick_ylower;
1764 joystick[joystick_nr].xmiddle = new_joystick_xmiddle;
1765 joystick[joystick_nr].ymiddle = new_joystick_ymiddle;
1767 CheckJoystickData();
1770 while(Joystick() & JOY_BUTTON);
1778 joy_nr[1] = SETUP_2ND_JOYSTICK_ON(local_player->setup)+49;
1783 DrawText(SX+32, SY+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
1784 DrawText(SX+16+7*32, SY+8*32, joy_nr, FS_BIG,FC_YELLOW);
1785 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
1788 for(clear_keybuf();!keypressed(););
1789 install_joystick(JOY_TYPE_2PADS);
1792 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1793 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1794 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
1797 for(clear_keybuf();!keypressed(););
1798 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
1801 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1802 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1803 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
1806 for(clear_keybuf();!keypressed(););
1807 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
1814 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
1815 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
1821 void HandleGameActions()
1823 if (game_status != PLAYING)
1826 if (local_player->LevelSolved)
1829 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
1837 void HandleVideoButtons(int mx, int my, int button)
1839 if (game_status != MAINMENU && game_status != PLAYING)
1842 switch(CheckVideoButtons(mx,my,button))
1844 case BUTTON_VIDEO_EJECT:
1846 if (TAPE_IS_EMPTY(tape))
1848 LoadLevelTape(level_nr);
1849 if (TAPE_IS_EMPTY(tape))
1850 Request("No tape for this level !",REQ_CONFIRM);
1855 SaveLevelTape(tape.level_nr);
1858 DrawCompleteVideoDisplay();
1861 case BUTTON_VIDEO_STOP:
1865 case BUTTON_VIDEO_PAUSE:
1869 case BUTTON_VIDEO_REC:
1870 if (TAPE_IS_STOPPED(tape))
1872 TapeStartRecording();
1874 if (options.network)
1875 SendToServer_StartPlaying();
1878 game_status = PLAYING;
1882 else if (tape.pausing)
1884 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
1886 tape.pos[tape.counter].delay = tape.delay_played;
1887 tape.playing = FALSE;
1888 tape.recording = TRUE;
1889 tape.changed = TRUE;
1891 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
1898 case BUTTON_VIDEO_PLAY:
1899 if (TAPE_IS_EMPTY(tape))
1902 if (TAPE_IS_STOPPED(tape))
1906 game_status = PLAYING;
1909 else if (tape.playing)
1911 if (tape.pausing) /* PAUSE -> PLAY */
1913 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
1915 tape.fast_forward = TRUE;
1916 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
1918 else if (!tape.pause_before_death) /* FFWD PLAY -> + AUTO PAUSE */
1920 tape.pause_before_death = TRUE;
1921 DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, VIDEO_DISPLAY_LABEL_ONLY);
1923 else /* -> NORMAL PLAY */
1925 tape.fast_forward = FALSE;
1926 tape.pause_before_death = FALSE;
1927 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PAUSE_OFF, 0);
1939 void HandleSoundButtons(int mx, int my, int button)
1941 if (game_status != PLAYING)
1944 switch(CheckSoundButtons(mx,my,button))
1946 case BUTTON_SOUND_MUSIC:
1947 if (setup.sound_music_on)
1949 setup.sound_music_on = FALSE;
1950 FadeSound(background_loop[level_nr % num_bg_loops]);
1951 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
1953 else if (sound_loops_allowed)
1955 setup.sound_on = setup.sound_music_on = TRUE;
1956 PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
1957 DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
1960 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
1963 case BUTTON_SOUND_LOOPS:
1964 if (setup.sound_loops_on)
1966 setup.sound_loops_on = FALSE;
1967 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
1969 else if (sound_loops_allowed)
1971 setup.sound_on = setup.sound_loops_on = TRUE;
1972 DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
1975 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
1978 case BUTTON_SOUND_SIMPLE:
1979 if (setup.sound_simple_on)
1981 setup.sound_simple_on = FALSE;
1982 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
1984 else if (sound_status==SOUND_AVAILABLE)
1986 setup.sound_on = setup.sound_simple_on = TRUE;
1987 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON);
1990 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2000 void HandleGameButtons(int mx, int my, int button)
2002 if (game_status != PLAYING)
2005 switch(CheckGameButtons(mx,my,button))
2007 case BUTTON_GAME_STOP:
2010 CloseDoor(DOOR_CLOSE_1);
2011 game_status = MAINMENU;
2016 if (Request("Do you really want to quit the game ?",
2017 REQ_ASK | REQ_STAY_CLOSED))
2019 if (options.network)
2020 SendToServer_StopPlaying();
2023 game_status = MAINMENU;
2028 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
2031 case BUTTON_GAME_PAUSE:
2032 if (options.network)
2035 SendToServer_ContinuePlaying();
2037 SendToServer_PausePlaying();
2043 case BUTTON_GAME_PLAY:
2046 if (options.network)
2047 SendToServer_ContinuePlaying();
2050 tape.pausing = FALSE;
2051 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);