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);
73 DrawText(SX+40+16,SY+344,"Graphics: Deluxe Paint IV Amiga",
75 DrawText(SX+60+16,SY+362,"Sounds: AudioMaster IV Amiga",
80 HandleMainMenu(0,0,0,0,MB_MENU_INITIALIZE);
83 if (TAPE_IS_EMPTY(tape))
84 LoadLevelTape(level_nr);
85 DrawCompleteVideoDisplay();
87 OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
90 XAutoRepeatOn(display);
93 void HandleMainMenu(int mx, int my, int dx, int dy, int button)
95 static int choice = 3;
96 static int redraw = TRUE;
97 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
99 if (redraw || button == MB_MENU_INITIALIZE)
101 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
105 if (button == MB_MENU_INITIALIZE)
112 x = (dx<0 ? 11 : 15);
129 if (!mx && !my && !dx && !dy)
135 if (y==4 && ((x==11 && level_nr>0) ||
136 (x==15 && level_nr<leveldir[leveldir_nr].levels-1)) &&
139 static long level_delay = 0;
140 int step = (button==1 ? 1 : button==2 ? 5 : 10);
141 int new_level_nr, old_level_nr = level_nr;
143 new_level_nr = level_nr + (x==11 ? -step : +step);
146 if (new_level_nr>leveldir[leveldir_nr].levels-1)
147 new_level_nr = leveldir[leveldir_nr].levels-1;
149 if (old_level_nr==new_level_nr || !DelayReached(&level_delay,150))
152 level_nr = new_level_nr;
156 if (level_nr > local_player->handicap)
157 level_nr = local_player->handicap;
161 DrawTextExt(drawto,gc,SX+11*32,SY+3*32,
162 int2str(level_nr,3), FS_BIG,FC_RED);
163 DrawTextExt(window,gc,SX+11*32,SY+3*32,
164 int2str(level_nr,3), FS_BIG,FC_RED);
167 DrawMicroLevel(MICROLEV_XPOS,MICROLEV_YPOS);
170 LoadLevelTape(level_nr);
171 DrawCompleteVideoDisplay();
173 /* needed because DrawMicroLevel() takes some time */
175 XSync(display,FALSE);
176 DelayReached(&level_delay,0); /* reset delay counter */
178 else if (x==1 && y>=3 && y<=10)
184 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
185 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
193 game_status = TYPENAME;
194 HandleTypeName(strlen(local_player->alias_name),0);
200 game_status = CHOOSELEVEL;
206 SavePlayerInfo(PLAYER_LEVEL);
215 game_status = HALLOFFAME;
220 game_status = LEVELED;
221 if (leveldir[leveldir_nr].readonly)
222 Request("This level is read only !",REQ_CONFIRM);
227 game_status = HELPSCREEN;
232 if (setup.autorecord_on)
233 TapeStartRecording();
236 SendToServer_StartPlaying();
239 game_status = PLAYING;
254 SavePlayerInfo(PLAYER_LEVEL);
257 if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
258 game_status = EXITGAME;
269 if (game_status==MAINMENU)
273 #define MAX_HELPSCREEN_ELS 10
277 static long helpscreen_state;
278 static int helpscreen_step[MAX_HELPSCREEN_ELS];
279 static int helpscreen_frame[MAX_HELPSCREEN_ELS];
280 static int helpscreen_delay[MAX_HELPSCREEN_ELS];
281 static int helpscreen_action[] =
283 GFX_SPIELER1_DOWN,4,2,
285 GFX_SPIELER1_LEFT,4,2,
286 GFX_SPIELER1_RIGHT,4,2,
287 GFX_SPIELER1_PUSH_LEFT,4,2,
288 GFX_SPIELER1_PUSH_RIGHT,4,2, HA_NEXT,
289 GFX_ERDREICH,1,100, HA_NEXT,
290 GFX_LEERRAUM,1,100, HA_NEXT,
291 GFX_MORAST_LEER,1,100, HA_NEXT,
292 GFX_BETON,1,100, HA_NEXT,
293 GFX_MAUERWERK,1,100, HA_NEXT,
294 GFX_MAUER_R1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10,
295 GFX_MAUER_L1,3,4, GFX_MAUERWERK,1,20, GFX_LEERRAUM,1,10, HA_NEXT,
296 GFX_UNSICHTBAR,1,100, HA_NEXT,
297 GFX_FELSBODEN,1,100, HA_NEXT,
298 GFX_CHAR_A,30,4, GFX_CHAR_AUSRUF,32,4, HA_NEXT,
299 GFX_EDELSTEIN,2,5, HA_NEXT,
300 GFX_DIAMANT,2,5, HA_NEXT,
301 GFX_EDELSTEIN_BD,2,5, HA_NEXT,
302 GFX_EDELSTEIN_GELB,2,5, GFX_EDELSTEIN_ROT,2,5,
303 GFX_EDELSTEIN_LILA,2,5, HA_NEXT,
304 GFX_FELSBROCKEN,4,5, HA_NEXT,
305 GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
306 GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT,
307 GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT,
308 GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT,
309 GFX_ERZ_EDEL_BD,1,50, GFX_EXPLOSION,8,1,GFX_EDELSTEIN_BD,1,10,HA_NEXT,
310 GFX_ERZ_EDEL_GELB,1,50, GFX_EXPLOSION,8,1,
311 GFX_EDELSTEIN_GELB,1,10, GFX_ERZ_EDEL_ROT,1,50,
312 GFX_EXPLOSION,8,1, GFX_EDELSTEIN_ROT,1,10,
313 GFX_ERZ_EDEL_LILA,1,50, GFX_EXPLOSION,8,1,
314 GFX_EDELSTEIN_LILA,1,10, HA_NEXT,
315 GFX_GEBLUBBER,4,4, HA_NEXT,
316 GFX_SCHLUESSEL1,4,25, HA_NEXT,
317 GFX_PFORTE1,4,25, HA_NEXT,
318 GFX_PFORTE1X,4,25, HA_NEXT,
319 GFX_DYNAMIT_AUS,1,100, HA_NEXT,
320 GFX_DYNAMIT,7,6, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT,
321 GFX_DYNABOMB+0,4,3, GFX_DYNABOMB+3,1,3, GFX_DYNABOMB+2,1,3,
322 GFX_DYNABOMB+1,1,3, GFX_DYNABOMB+0,1,3, GFX_EXPLOSION,8,1,
323 GFX_LEERRAUM,1,10, HA_NEXT,
324 GFX_DYNABOMB_NR,1,100, HA_NEXT,
325 GFX_DYNABOMB_SZ,1,100, HA_NEXT,
326 GFX_FLIEGER+4,1,3, GFX_FLIEGER+0,1,3, GFX_FLIEGER+4,1,3,
327 GFX_FLIEGER+5,1,3, GFX_FLIEGER+1,1,3, GFX_FLIEGER+5,1,3,
328 GFX_FLIEGER+6,1,3, GFX_FLIEGER+2,1,3, GFX_FLIEGER+6,1,3,
329 GFX_FLIEGER+7,1,3, GFX_FLIEGER+3,1,3, GFX_FLIEGER+7,1,3, HA_NEXT,
330 GFX_KAEFER+4,1,1, GFX_KAEFER+0,1,1, GFX_KAEFER+4,1,1,
331 GFX_KAEFER+5,1,1, GFX_KAEFER+1,1,1, GFX_KAEFER+5,1,1,
332 GFX_KAEFER+6,1,1, GFX_KAEFER+2,1,1, GFX_KAEFER+6,1,1,
333 GFX_KAEFER+7,1,1, GFX_KAEFER+3,1,1, GFX_KAEFER+7,1,1, HA_NEXT,
334 GFX_BUTTERFLY,2,2, HA_NEXT,
335 GFX_FIREFLY,2,2, HA_NEXT,
336 GFX_PACMAN+0,1,3, GFX_PACMAN+4,1,2, GFX_PACMAN+0,1,3,
337 GFX_PACMAN+1,1,3, GFX_PACMAN+5,1,2, GFX_PACMAN+1,1,3,
338 GFX_PACMAN+2,1,3, GFX_PACMAN+6,1,2, GFX_PACMAN+2,1,3,
339 GFX_PACMAN+3,1,3, GFX_PACMAN+7,1,2, GFX_PACMAN+3,1,3, HA_NEXT,
340 GFX_MAMPFER+0,4,1, GFX_MAMPFER+3,1,1, GFX_MAMPFER+2,1,1,
341 GFX_MAMPFER+1,1,1, GFX_MAMPFER+0,1,1, HA_NEXT,
342 GFX_MAMPFER2+0,4,1, GFX_MAMPFER2+3,1,1, GFX_MAMPFER2+2,1,1,
343 GFX_MAMPFER2+1,1,1, GFX_MAMPFER2+0,1,1, HA_NEXT,
344 GFX_ROBOT+0,4,1, GFX_ROBOT+3,1,1, GFX_ROBOT+2,1,1,
345 GFX_ROBOT+1,1,1, GFX_ROBOT+0,1,1, HA_NEXT,
346 GFX_MAULWURF_DOWN,4,2,
348 GFX_MAULWURF_LEFT,4,2,
349 GFX_MAULWURF_RIGHT,4,2, HA_NEXT,
350 GFX_PINGUIN_DOWN,4,2,
352 GFX_PINGUIN_LEFT,4,2,
353 GFX_PINGUIN_RIGHT,4,2, HA_NEXT,
354 GFX_SCHWEIN_DOWN,4,2,
356 GFX_SCHWEIN_LEFT,4,2,
357 GFX_SCHWEIN_RIGHT,4,2, HA_NEXT,
361 GFX_DRACHE_RIGHT,4,2, HA_NEXT,
362 GFX_SONDE_START,8,1, HA_NEXT,
363 GFX_ABLENK,4,1, HA_NEXT,
364 GFX_BIRNE_AUS,1,25, GFX_BIRNE_EIN,1,25, HA_NEXT,
365 GFX_ZEIT_VOLL,1,25, GFX_ZEIT_LEER,1,25, HA_NEXT,
366 GFX_TROPFEN,1,25, GFX_AMOEBING,4,1, GFX_AMOEBE_LEBT,1,10, HA_NEXT,
367 GFX_AMOEBE_TOT+2,2,50, GFX_AMOEBE_TOT,2,50, HA_NEXT,
368 GFX_AMOEBE_LEBT,4,40, HA_NEXT,
369 GFX_AMOEBE_LEBT,1,10, GFX_AMOEBING,4,2, HA_NEXT,
370 GFX_AMOEBE_LEBT,1,25, GFX_AMOEBE_TOT,1,25, GFX_EXPLOSION,8,1,
371 GFX_DIAMANT,1,10, HA_NEXT,
372 GFX_LIFE,1,100, HA_NEXT,
373 GFX_LIFE_ASYNC,1,100, HA_NEXT,
374 GFX_SIEB_LEER,4,2, HA_NEXT,
375 GFX_SIEB2_LEER,4,2, HA_NEXT,
376 GFX_AUSGANG_ZU,1,100, GFX_AUSGANG_ACT,4,2,
377 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
378 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
379 GFX_AUSGANG_AUF+0,4,2, GFX_AUSGANG_AUF+3,1,2,
380 GFX_AUSGANG_AUF+2,1,2, GFX_AUSGANG_AUF+1,1,2, HA_NEXT,
383 static char *helpscreen_eltext[][2] =
385 {"THE HERO:", "(Is _this_ guy good old Rockford?)"},
386 {"Normal sand:", "You can dig through it"},
387 {"Empty field:", "You can walk through it"},
388 {"Quicksand: You cannot pass it,", "but rocks can fall though it"},
389 {"Massive Wall:", "Nothing can go through it"},
390 {"Normal Wall: You can't go through", "it, but you can bomb it away"},
391 {"Growing Wall: Grows to the left or", "right if there is an empty field"},
392 {"Invisible Wall: Behaves like normal","wall, but is invisible"},
393 {"Old Wall: Like normal wall, but", "some things can fall down from it"},
394 {"Letter Wall: Looks like a letter,", "behaves like a normal wall"},
395 {"Emerald: You must collect enough of","them to finish a level"},
396 {"Diamond: Counts as 3 emeralds, but", "can be destroyed by rocks"},
397 {"Diamond (BD style): Counts like one","emerald and behaves a bit different"},
398 {"Colorful Gems:", "Seem to behave like Emeralds"},
399 {"Rock: Smashes several things;", "Can be moved by the player"},
400 {"Bomb: You can move it, but be", "careful when dropping it"},
401 {"Nut: Throw a rock on it to open it;","Each nut contains an emerald"},
402 {"Wall with an emerald inside:", "Bomb the wall away to get it"},
403 {"Wall with a diamond inside:", "Bomb the wall away to get it"},
404 {"Wall with BD style diamond inside:", "Bomb the wall away to get it"},
405 {"Wall with colorful gem inside:", "Bomb the wall away to get it"},
406 {"Acid: Things that fall in are gone", "forever (including our hero)"},
407 {"Key: Opens the door that has the", "same color (red/yellow/green/blue)"},
408 {"Door: Can be opened by the key", "with the same color"},
409 {"Door: You have to find out the", "right color of the key for it"},
410 {"Dynamite: Collect it and use it to", "destroy walls or kill enemies"},
411 {"Dynamite: This one explodes after", "a few seconds"},
412 {"Dyna Bomb: Explodes in 4 directions","with variable explosion size"},
413 {"Dyna Bomb: Increases the number of", "dyna bombs available at a time"},
414 {"Dyna Bomb: Increases the size of", "explosion of dyna bombs"},
415 {"Spaceship: Moves at the left side", "of walls; don't touch it!"},
416 {"Bug: Moves at the right side", "of walls; don't touch it!"},
417 {"Butterfly: Moves at the right side", "of walls; don't touch it!"},
418 {"Firefly: Moves at the left side", "of walls; don't touch it!"},
419 {"Pacman: Eats the amoeba and you,", "if you're not careful"},
420 {"Cruncher: Eats diamonds and you,", "if you're not careful"},
421 {"Cruncher (BD style):", "Eats almost everything"},
422 {"Robot: Tries to kill the player", ""},
423 {"The mole: You must guide him savely","to the exit; he will follow you"},
424 {"The penguin: Guide him to the exit,","but keep him away from monsters!"},
425 {"The Pig: Harmless, but eats all", "gems it can get"},
426 {"The Dragon: Breathes fire,", "especially to some monsters"},
427 {"Sonde: Follows you everywhere;", "harmless, but may block your way"},
428 {"Magic Wheel: Touch it to get rid of","the robots for some seconds"},
429 {"Light Bulb: All of them must be", "switched on to finish a level"},
430 {"Extra Time Orb: Adds some seconds", "to the time available for the level"},
431 {"Amoeba Drop: Grows to an amoeba on", "the ground - don't touch it"},
432 {"Dead Amoeba: Does not grow, but", "can still kill bugs and spaceships"},
433 {"Normal Amoeba: Grows through empty", "fields, sand and quicksand"},
434 {"Dropping Amoeba: This one makes", "drops that grow to a new amoeba"},
435 {"Living Amoeba (BD style): Contains", "other element, when surrounded"},
436 {"Game Of Life: Behaves like the well","known 'Game Of Life' (2333 style)"},
437 {"Biomaze: A bit like the 'Game Of", "Life', but builds crazy mazes"},
438 {"Magic Wall: Changes rocks, emeralds","and diamonds when they pass it"},
439 {"Magic Wall (BD style):", "Changes rocks and BD style diamonds"},
440 {"Exit door: Opens if you have enough","emeralds to finish the level"},
441 {"Open exit door: Enter here to leave","the level and exit the actual game"},
443 static int num_helpscreen_els = sizeof(helpscreen_eltext)/(2*sizeof(char *));
445 static char *helpscreen_music[][3] =
447 { "Alchemy", "Ian Boddy", "Drive" },
448 { "The Chase", "Propaganda", "A Secret Wish" },
449 { "Network 23", "Tangerine Dream", "Exit" },
450 { "Czardasz", "Robert Pieculewicz", "Czardasz" },
451 { "21st Century Common Man", "Tangerine Dream", "Tyger" },
452 { "Voyager", "The Alan Parsons Project","Pyramid" },
453 { "Twilight Painter", "Tangerine Dream", "Heartbreakers" }
455 static int helpscreen_musicpos;
457 void DrawHelpScreenElAction(int start)
461 int xstart = SX+16, ystart = SY+64+2*32, ystep = TILEY+4;
463 while(helpscreen_action[j] != HA_END)
465 if (i>=start+MAX_HELPSCREEN_ELS || i>=num_helpscreen_els)
467 else if (i<start || helpscreen_delay[i-start])
469 if (i>=start && helpscreen_delay[i-start])
470 helpscreen_delay[i-start]--;
472 while(helpscreen_action[j] != HA_NEXT)
479 j += 3*helpscreen_step[i-start];
480 graphic = helpscreen_action[j++];
482 if (helpscreen_frame[i-start])
484 frame = helpscreen_action[j++] - helpscreen_frame[i-start];
485 helpscreen_frame[i-start]--;
490 helpscreen_frame[i-start] = helpscreen_action[j++]-1;
493 helpscreen_delay[i-start] = helpscreen_action[j++] - 1;
495 if (helpscreen_action[j] == HA_NEXT)
497 if (!helpscreen_frame[i-start])
498 helpscreen_step[i-start] = 0;
502 if (!helpscreen_frame[i-start])
503 helpscreen_step[i-start]++;
504 while(helpscreen_action[j] != HA_NEXT)
509 DrawGraphicExt(drawto, gc, xstart, ystart+(i-start)*ystep, graphic+frame);
520 void DrawHelpScreenElText(int start)
523 int xstart = SX+56, ystart = SY+65+2*32, ystep = TILEY+4;
524 char text[FULL_SXSIZE/FONT2_XSIZE+10];
529 sprintf(text,"The game elements:");
530 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
531 text,FS_SMALL,FC_GREEN);
533 for(i=start;i<start+MAX_HELPSCREEN_ELS && i<num_helpscreen_els;i++)
535 DrawText(xstart,ystart+(i-start)*ystep+(*helpscreen_eltext[i][1] ? 0 : 8),
536 helpscreen_eltext[i][0],FS_SMALL,FC_YELLOW);
537 DrawText(xstart,ystart+(i-start)*ystep+16,
538 helpscreen_eltext[i][1],FS_SMALL,FC_YELLOW);
541 sprintf(text,"Press any key or button for next page");
542 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
543 text,FS_SMALL,FC_BLUE);
546 void DrawHelpScreenMusicText(int num)
548 int ystart = 150, ystep = 30;
549 char text[FULL_SXSIZE/FONT2_XSIZE+10];
555 sprintf(text,"The game background music loops:");
556 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
557 text,FS_SMALL,FC_GREEN);
559 sprintf(text,"Excerpt from");
560 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep,
561 text,FS_SMALL,FC_YELLOW);
562 sprintf(text,"%c%s%c",'\"',helpscreen_music[num][0],'\"');
563 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep,
564 text,FS_SMALL,FC_RED);
566 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep,
567 text,FS_SMALL,FC_YELLOW);
568 sprintf(text,"%s",helpscreen_music[num][1]);
569 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep,
570 text,FS_SMALL,FC_RED);
571 sprintf(text,"from the album");
572 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
573 text,FS_SMALL,FC_YELLOW);
574 sprintf(text,"%c%s%c",'\"',helpscreen_music[num][2],'\"');
575 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+5*ystep,
576 text,FS_SMALL,FC_RED);
578 sprintf(text,"Press any key or button for next page");
579 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
580 text,FS_SMALL,FC_BLUE);
582 PlaySoundLoop(background_loop[num]);
585 void DrawHelpScreenCreditsText()
587 int ystart = 150, ystep = 30;
588 char text[FULL_SXSIZE/FONT2_XSIZE+10];
594 sprintf(text,"Program information:");
595 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100,
596 text,FS_SMALL,FC_GREEN);
598 sprintf(text,"This game is Freeware!");
599 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep,
600 text,FS_SMALL,FC_YELLOW);
601 sprintf(text,"If you like it, send e-mail to:");
602 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep,
603 text,FS_SMALL,FC_YELLOW);
604 sprintf(text,"aeglos@valinor.owl.de");
605 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep,
606 text,FS_SMALL,FC_RED);
607 sprintf(text,"or SnailMail to:");
608 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep,
609 text,FS_SMALL,FC_YELLOW);
610 sprintf(text,"Holger Schemel");
611 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep,
612 text,FS_SMALL,FC_RED);
613 sprintf(text,"Sennehof 28");
614 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+20,
615 text,FS_SMALL,FC_RED);
616 sprintf(text,"33659 Bielefeld");
617 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+40,
618 text,FS_SMALL,FC_RED);
619 sprintf(text,"Germany");
620 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+60,
621 text,FS_SMALL,FC_RED);
623 sprintf(text,"If you have created new levels,");
624 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+7*ystep,
625 text,FS_SMALL,FC_YELLOW);
626 sprintf(text,"send them to me to include them!");
627 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+8*ystep,
628 text,FS_SMALL,FC_YELLOW);
630 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+9*ystep,
631 text,FS_SMALL,FC_YELLOW);
633 sprintf(text,"Press any key or button for main menu");
634 DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20,
635 text,FS_SMALL,FC_BLUE);
638 void DrawHelpScreen()
642 CloseDoor(DOOR_CLOSE_2);
644 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
645 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
646 helpscreen_musicpos = 0;
647 helpscreen_state = 0;
648 DrawHelpScreenElText(0);
649 DrawHelpScreenElAction(0);
653 PlaySoundLoop(SND_RHYTHMLOOP);
656 void HandleHelpScreen(int button)
658 static long hs_delay = 0;
659 int num_helpscreen_els_pages =
660 (num_helpscreen_els + MAX_HELPSCREEN_ELS-1) / MAX_HELPSCREEN_ELS;
661 int button_released = !button;
666 if (helpscreen_state<num_helpscreen_els_pages-1)
668 for(i=0;i<MAX_HELPSCREEN_ELS;i++)
669 helpscreen_step[i] = helpscreen_frame[i] = helpscreen_delay[i] = 0;
671 DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
672 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
674 else if (helpscreen_state<num_helpscreen_els_pages+num_bg_loops-1)
677 DrawHelpScreenMusicText(helpscreen_state-num_helpscreen_els_pages);
679 else if (helpscreen_state==num_helpscreen_els_pages+num_bg_loops-1)
682 DrawHelpScreenCreditsText();
688 game_status = MAINMENU;
693 if (DelayReached(&hs_delay,GAME_FRAME_DELAY * 2))
695 if (helpscreen_state<num_helpscreen_els_pages)
696 DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
708 int old_handicap = local_player->handicap;
710 if (!strcmp(local_player->alias_name,"Artsoft"))
711 local_player->handicap = leveldir[leveldir_nr].levels-1;
713 if (local_player->handicap != old_handicap)
715 SavePlayerInfo(PLAYER_LEVEL);
716 level_nr = local_player->handicap;
722 void HandleTypeName(int newxpos, KeySym key)
724 static int xpos = 0, ypos = 2;
730 DrawText(SX+6*32, SY+ypos*32, local_player->alias_name, FS_BIG, FC_YELLOW);
731 DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
736 if ((key>=XK_A && key<=XK_Z) || (key>=XK_a && key<=XK_z &&
739 if (key>=XK_A && key<=XK_Z)
740 ascii = 'A'+(char)(key-XK_A);
741 if (key>=XK_a && key<=XK_z)
742 ascii = 'a'+(char)(key-XK_a);
744 if((ascii = get_ascii(key)) && xpos<MAX_NAMELEN-1)
747 local_player->alias_name[xpos] = ascii;
748 local_player->alias_name[xpos+1] = 0;
750 DrawTextExt(drawto,gc,SX+6*32,SY+ypos*32,
751 local_player->alias_name,FS_BIG,FC_YELLOW);
752 DrawTextExt(window,gc,SX+6*32,SY+ypos*32,
753 local_player->alias_name,FS_BIG,FC_YELLOW);
754 DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
756 else if ((key==XK_Delete || key==XK_BackSpace) && xpos>0)
759 local_player->alias_name[xpos] = 0;
760 DrawGraphic(xpos+6,ypos,GFX_KUGEL_ROT);
761 DrawGraphic(xpos+7,ypos,GFX_LEERRAUM);
763 else if (key==XK_Return && xpos>0)
765 DrawText(SX+6*32,SY+ypos*32,local_player->alias_name,FS_BIG,FC_RED);
766 DrawGraphic(xpos+6,ypos,GFX_LEERRAUM);
773 SavePlayerInfo(PLAYER_SETUP);
783 game_status = MAINMENU;
792 void DrawChooseLevel()
796 CloseDoor(DOOR_CLOSE_2);
799 DrawText(SX,SY,"Level Directories",FS_BIG,FC_GREEN);
800 for(i=0;i<num_leveldirs;i++)
802 DrawText(SX+32,SY+(i+2)*32,leveldir[i].name,FS_BIG,FC_YELLOW);
803 DrawGraphic(0,i+2,GFX_KUGEL_BLAU);
808 HandleChooseLevel(0,0,0,0,MB_MENU_INITIALIZE);
811 void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
813 static int choice = 3;
814 static int redraw = TRUE;
815 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
817 if (button == MB_MENU_INITIALIZE)
820 choice = leveldir_nr + 3;
825 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
829 if (button == MB_MENU_INITIALIZE)
844 else if (y>num_leveldirs+2)
848 if (!mx && !my && !dx && !dy)
854 if (x==1 && y>=3 && y<=num_leveldirs+2)
860 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
861 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
867 local_player->leveldir_nr = leveldir_nr = y-3;
872 LoadPlayerInfo(PLAYER_LEVEL);
873 SavePlayerInfo(PLAYER_SETUP);
883 LoadLevelTape(level_nr);
885 game_status = MAINMENU;
892 if (game_status==CHOOSELEVEL)
896 void DrawHallOfFame(int pos)
901 CloseDoor(DOOR_CLOSE_2);
906 DrawText(SX+64,SY+10,"Hall Of Fame",FS_BIG,FC_YELLOW);
907 sprintf(txt,"HighScores of Level %d",level_nr);
908 DrawText(SX+256-strlen(txt)*7,SY+48,txt,FS_SMALL,FC_RED);
909 for(y=0;y<MAX_SCORE_ENTRIES;y++)
911 DrawText(SX,SY+64+y*32,".................",FS_BIG,
912 (y==pos ? FC_RED : FC_GREEN));
913 DrawText(SX,SY+64+y*32,highscore[y].Name,FS_BIG,
914 (y==pos ? FC_RED : FC_GREEN));
915 DrawText(SX+12*32,SY+64+y*32,
916 int2str(highscore[y].Score,5),FS_BIG,
917 (y==pos ? FC_RED : FC_GREEN));
922 PlaySound(SND_HALLOFFAME);
925 void HandleHallOfFame(int button)
927 int button_released = !button;
931 FadeSound(SND_HALLOFFAME);
932 game_status = MAINMENU;
940 void DrawSetupScreen()
949 char *text, *mode[2];
953 {SETUP_SOUND, "Sound:", {"on", "off"}, {FC_YELLOW,FC_BLUE}},
954 {SETUP_SOUND_LOOPS, " Sound Loops:",{"on", "off"}, {FC_YELLOW,FC_BLUE}},
955 {SETUP_SOUND_MUSIC, " Game Music:", {"on", "off"}, {FC_YELLOW,FC_BLUE}},
956 {SETUP_TOONS, "Toons:", {"on", "off"}, {FC_YELLOW,FC_BLUE}},
957 {SETUP_DIRECT_DRAW, "Buffered gfx:",{"off","on" }, {FC_BLUE,FC_YELLOW}},
958 {SETUP_SCROLL_DELAY,"Scroll Delay:",{"on", "off"}, {FC_YELLOW,FC_BLUE}},
959 {SETUP_SOFT_SCROLL, "Soft Scroll.:",{"on", "off"}, {FC_YELLOW,FC_BLUE}},
960 {SETUP_FADING, "Fading:", {"on", "off"}, {FC_YELLOW,FC_BLUE}},
961 {SETUP_QUICK_DOORS, "Quick Doors:", {"on", "off"}, {FC_YELLOW,FC_BLUE}},
962 {SETUP_AUTO_RECORD, "Auto-Record:", {"on", "off"}, {FC_YELLOW,FC_BLUE}},
963 {0, "Input Devices",{"", ""}, {0,0}},
964 {0, "", {"", ""}, {0,0}},
965 {0, "", {"", ""}, {0,0}},
966 {0, "Exit", {"", ""}, {0,0}},
967 {0, "Save and exit",{"", ""}, {0,0}}
974 char *text, *mode[2];
978 { &setup.sound_on, "Sound:", {"on", "off"},{FC_YELLOW,FC_BLUE}},
979 { &setup.sound_loops_on," Sound Loops:",{"on", "off"},{FC_YELLOW,FC_BLUE}},
980 { &setup.sound_music_on," Game Music:", {"on", "off"},{FC_YELLOW,FC_BLUE}},
981 { &setup.toons_on, "Toons:", {"on", "off"},{FC_YELLOW,FC_BLUE}},
982 { &setup.direct_draw_on,"Buffered gfx:",{"off","on" },{FC_BLUE,FC_YELLOW}},
983 { &setup.scroll_delay_on,"Scroll Delay:",{"on", "off"},{FC_YELLOW,FC_BLUE}},
984 { &setup.soft_scrolling_on, "Soft Scroll.:",{"on", "off"},{FC_YELLOW,FC_BLUE}},
985 { &setup.fading_on, "Fading:", {"on", "off"},{FC_YELLOW,FC_BLUE}},
986 { &setup.quick_doors,"Quick Doors:", {"on", "off"},{FC_YELLOW,FC_BLUE}},
987 { &setup.autorecord_on,"Auto-Record:", {"on", "off"},{FC_YELLOW,FC_BLUE}},
988 { NULL, "Input Devices",{"", ""}, {0,0}},
989 { NULL, "", {"", ""}, {0,0}},
990 { NULL, "", {"", ""}, {0,0}},
991 { NULL, "Exit", {"", ""}, {0,0}},
992 { NULL, "Save and exit",{"", ""}, {0,0}}
995 CloseDoor(DOOR_CLOSE_2);
997 DrawText(SX+16, SY+16, "SETUP",FS_BIG,FC_YELLOW);
1001 printf("setup.sound_loops_on == %d\n", setup.sound_loops_on);
1005 for(i=SETUP_SCREEN_POS_START;i<=SETUP_SCREEN_POS_END;i++)
1007 int base = i - SETUP_SCREEN_POS_START;
1009 if (!(i >= SETUP_SCREEN_POS_EMPTY1 && i <= SETUP_SCREEN_POS_EMPTY2))
1011 DrawGraphic(0,i,GFX_KUGEL_BLAU);
1012 DrawText(SX+32,SY+i*32, setup_info[base].text, FS_BIG,FC_GREEN);
1016 if (i < SETUP_SCREEN_POS_EMPTY1)
1018 int setting_bit = setup_info[base].bit;
1019 int setting_pos = ((local_player->setup & setting_bit) != 0 ? 0 : 1);
1023 if (setup_info[base].value)
1025 int setting_value = *setup_info[base].value;
1026 int setting_pos = (setting_value != 0 ? 0 : 1);
1028 DrawText(SX+14*32, SY+i*32,setup_info[base].mode[setting_pos],
1029 FS_BIG,setup_info[base].color[setting_pos]);
1035 HandleSetupScreen(0,0,0,0,MB_MENU_INITIALIZE);
1038 void HandleSetupScreen(int mx, int my, int dx, int dy, int button)
1040 static int choice = 3;
1041 static int redraw = TRUE;
1042 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1043 int pos_start = SETUP_SCREEN_POS_START + 1;
1044 int pos_empty1 = SETUP_SCREEN_POS_EMPTY1 + 1;
1045 int pos_empty2 = SETUP_SCREEN_POS_EMPTY2 + 1;
1046 int pos_end = SETUP_SCREEN_POS_END + 1;
1048 if (button == MB_MENU_INITIALIZE)
1053 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1057 if (button == MB_MENU_INITIALIZE)
1070 if (y >= pos_empty1 && y <= pos_empty2)
1071 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1075 else if (y > pos_end)
1079 if (!mx && !my && !dx && !dy)
1085 if (x==1 && y >= pos_start && y <= pos_end &&
1086 !(y >= pos_empty1 && y <= pos_empty2))
1092 DrawGraphic(0,y-1,GFX_KUGEL_ROT);
1093 DrawGraphic(0,choice-1,GFX_KUGEL_BLAU);
1101 if (y==3 && sound_status==SOUND_AVAILABLE)
1105 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1106 DrawText(SX+14*32, SY+(yy+1)*32,"off",FS_BIG,FC_BLUE);
1107 DrawText(SX+14*32, SY+(yy+2)*32,"off",FS_BIG,FC_BLUE);
1108 setup.sound_loops_on = FALSE;
1109 setup.sound_music_on = FALSE;
1112 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1113 setup.sound_on = !setup.sound_on;
1115 else if (y==4 && sound_loops_allowed)
1117 if (setup.sound_loops_on)
1118 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1121 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1122 DrawText(SX+14*32, SY+(yy-1)*32,"on ",FS_BIG,FC_YELLOW);
1123 setup.sound_on = TRUE;
1125 setup.sound_loops_on = !setup.sound_loops_on;
1127 else if (y==5 && sound_loops_allowed)
1129 if (setup.sound_music_on)
1130 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1133 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1134 DrawText(SX+14*32, SY+(yy-2)*32,"on ",FS_BIG,FC_YELLOW);
1135 setup.sound_on = TRUE;
1137 setup.sound_music_on = !setup.sound_music_on;
1142 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1144 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1145 setup.toons_on = !setup.toons_on;
1149 if (!setup.direct_draw_on)
1150 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1152 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1153 setup.direct_draw_on = !setup.direct_draw_on;
1157 if (setup.scroll_delay_on)
1158 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1160 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1161 setup.scroll_delay_on = !setup.scroll_delay_on;
1165 if (setup.soft_scrolling_on)
1166 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1168 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1169 setup.soft_scrolling_on = !setup.soft_scrolling_on;
1173 if (setup.fading_on)
1174 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1176 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1177 setup.fading_on = !setup.fading_on;
1181 if (setup.quick_doors)
1182 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1184 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1185 setup.quick_doors = !setup.quick_doors;
1189 if (setup.autorecord_on)
1190 DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE);
1192 DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW);
1193 setup.autorecord_on = !setup.autorecord_on;
1197 game_status = SETUPINPUT;
1198 DrawSetupInputScreen();
1201 else if (y==pos_end-1 || y==pos_end)
1211 SavePlayerInfo(PLAYER_SETUP);
1217 game_status = MAINMENU;
1225 if (game_status==SETUP)
1229 void DrawSetupInputScreen()
1232 DrawText(SX+16, SY+16, "SETUP INPUT", FS_BIG, FC_YELLOW);
1234 DrawGraphic(0, 2, GFX_KUGEL_BLAU);
1235 DrawGraphic(0, 3, GFX_KUGEL_BLAU);
1236 DrawGraphic(0, 4, GFX_KUGEL_BLAU);
1237 DrawGraphic(0, 15, GFX_KUGEL_BLAU);
1238 DrawGraphic(10, 2, GFX_PFEIL_L);
1239 DrawGraphic(12, 2, GFX_PFEIL_R);
1241 DrawText(SX+32, SY+2*32, "Player:", FS_BIG, FC_GREEN);
1242 DrawText(SX+32, SY+3*32, "Device:", FS_BIG, FC_GREEN);
1243 DrawText(SX+32, SY+15*32, "Exit", FS_BIG, FC_GREEN);
1247 HandleSetupInputScreen(0,0,0,0,MB_MENU_INITIALIZE);
1250 static void drawPlayerSetupInputInfo(int player_nr)
1253 static struct SetupKeyboardInfo custom_key;
1260 { &custom_key.left, "Joystick Left" },
1261 { &custom_key.right, "Joystick Right" },
1262 { &custom_key.up, "Joystick Up" },
1263 { &custom_key.down, "Joystick Down" },
1264 { &custom_key.snap, "Button 1" },
1265 { &custom_key.bomb, "Button 2" }
1268 custom_key = setup.input[player_nr].key;
1270 DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
1271 DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
1273 if (setup.input[player_nr].use_joystick)
1275 DrawText(SX+8*32, SY+3*32,
1276 (setup.input[player_nr].joystick_nr == 0 ?
1277 "Joystick1" : "Joystick2"),
1279 DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
1283 DrawText(SX+8*32, SY+3*32, "Keyboard ", FS_BIG, FC_YELLOW);
1284 DrawText(SX+32, SY+4*32, "Customize", FS_BIG, FC_GREEN);
1287 DrawText(SX+32, SY+5*32, "Actual Settings:", FS_BIG, FC_GREEN);
1288 DrawGraphic(1, 6, GFX_PFEIL_L);
1289 DrawGraphic(1, 7, GFX_PFEIL_R);
1290 DrawGraphic(1, 8, GFX_PFEIL_O);
1291 DrawGraphic(1, 9, GFX_PFEIL_U);
1292 DrawText(SX+2*32, SY+6*32, ":", FS_BIG, FC_BLUE);
1293 DrawText(SX+2*32, SY+7*32, ":", FS_BIG, FC_BLUE);
1294 DrawText(SX+2*32, SY+8*32, ":", FS_BIG, FC_BLUE);
1295 DrawText(SX+2*32, SY+9*32, ":", FS_BIG, FC_BLUE);
1296 DrawText(SX+32, SY+10*32, "Snap Field:", FS_BIG, FC_BLUE);
1297 DrawText(SX+32, SY+12*32, "Place Bomb:", FS_BIG, FC_BLUE);
1301 int ypos = 6 + i + (i > 3 ? i-3 : 0);
1303 DrawText(SX + 3*32, SY + ypos*32,
1304 " ", FS_BIG, FC_YELLOW);
1305 DrawText(SX + 3*32, SY + ypos*32,
1306 (setup.input[player_nr].use_joystick ?
1308 getKeyNameFromKeySym(*custom[i].keysym)),
1313 void HandleSetupInputScreen(int mx, int my, int dx, int dy, int button)
1315 static int choice = 3;
1316 static int player_nr = 0;
1317 static int redraw = TRUE;
1318 int x = (mx+32-SX)/32, y = (my+32-SY)/32;
1319 int pos_start = SETUPINPUT_SCREEN_POS_START + 1;
1320 int pos_empty1 = SETUPINPUT_SCREEN_POS_EMPTY1 + 1;
1321 int pos_empty2 = SETUPINPUT_SCREEN_POS_EMPTY2 + 1;
1322 int pos_end = SETUPINPUT_SCREEN_POS_END + 1;
1324 if (button == MB_MENU_INITIALIZE)
1326 drawPlayerSetupInputInfo(player_nr);
1332 DrawGraphic(0,choice-1,GFX_KUGEL_ROT);
1336 if (button == MB_MENU_INITIALIZE)
1341 if (dx && choice == 3)
1343 x = (dx < 0 ? 11 : 13);
1346 else if (dx && choice == 4)
1348 button = MB_MENU_CHOICE;
1360 if (y >= pos_empty1 && y <= pos_empty2)
1361 y = (dy > 0 ? pos_empty2 + 1 : pos_empty1 - 1);
1365 else if (y > pos_end)
1369 if (!mx && !my && !dx && !dy)
1375 if (y == 3 && ((x == 1 && !button) || ((x == 11 || x == 13) && button)))
1377 static long delay = 0;
1379 if (!DelayReached(&delay,150))
1382 player_nr = (player_nr + (x == 11 ? -1 : +1) + MAX_PLAYERS) % MAX_PLAYERS;
1384 drawPlayerSetupInputInfo(player_nr);
1386 else if (x==1 && y >= pos_start && y <= pos_end &&
1387 !(y >= pos_empty1 && y <= pos_empty2))
1393 DrawGraphic(0, y-1, GFX_KUGEL_ROT);
1394 DrawGraphic(0, choice-1, GFX_KUGEL_BLAU);
1402 int one_joystick_nr = (dx >= 0 ? 0 : 1);
1403 int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
1405 if (setup.input[player_nr].use_joystick)
1407 if (setup.input[player_nr].joystick_nr == one_joystick_nr)
1408 setup.input[player_nr].joystick_nr = the_other_joystick_nr;
1410 setup.input[player_nr].use_joystick = FALSE;
1414 setup.input[player_nr].use_joystick = TRUE;
1415 setup.input[player_nr].joystick_nr = one_joystick_nr;
1418 drawPlayerSetupInputInfo(player_nr);
1422 if (setup.input[player_nr].use_joystick)
1423 CalibrateJoystick(setup.input[player_nr].joystick_nr);
1425 CustomizeKeyboard(player_nr);
1429 else if (y == pos_end)
1431 game_status = SETUP;
1441 if (game_status == SETUPINPUT)
1445 void CustomizeKeyboard(int player_nr)
1449 boolean finished = FALSE;
1450 static struct SetupKeyboardInfo custom_key;
1455 } customize_step[] =
1457 { &custom_key.left, "Move Left" },
1458 { &custom_key.right, "Move Right" },
1459 { &custom_key.up, "Move Up" },
1460 { &custom_key.down, "Move Down" },
1461 { &custom_key.snap, "Snap Field" },
1462 { &custom_key.bomb, "Place Bomb" }
1465 /* read existing key bindings from player setup */
1466 custom_key = setup.input[player_nr].key;
1469 DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
1475 DrawText(SX, SY + (2+2*step_nr)*32,
1476 customize_step[step_nr].text, FS_BIG, FC_RED);
1477 DrawText(SX, SY + (2+2*step_nr+1)*32,
1478 "Key:", FS_BIG, FC_RED);
1479 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1480 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1485 if (XPending(display)) /* got event from X server */
1489 XNextEvent(display, &event);
1495 KeySym key = XLookupKeysym((XKeyEvent *)&event,
1496 ((XKeyEvent *)&event)->state);
1498 if (key == XK_Escape || (key == XK_Return && step_nr == 6))
1504 /* press 'Enter' to keep the existing key binding */
1505 if (key == XK_Return || step_nr == 6)
1506 key = *customize_step[step_nr].keysym;
1508 /* check if key already used */
1509 for (i=0; i<step_nr; i++)
1510 if (*customize_step[i].keysym == key)
1515 /* got new key binding */
1516 *customize_step[step_nr].keysym = key;
1517 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1518 " ", FS_BIG, FC_YELLOW);
1519 DrawText(SX + 4*32, SY + (2+2*step_nr+1)*32,
1520 getKeyNameFromKeySym(key), FS_BIG, FC_YELLOW);
1523 /* un-highlight last query */
1524 DrawText(SX, SY+(2+2*(step_nr-1))*32,
1525 customize_step[step_nr-1].text, FS_BIG, FC_GREEN);
1526 DrawText(SX, SY+(2+2*(step_nr-1)+1)*32,
1527 "Key:", FS_BIG, FC_GREEN);
1529 /* press 'Enter' to leave */
1532 DrawText(SX + 16, SY + 15*32+16,
1533 "Press Enter", FS_BIG, FC_YELLOW);
1537 /* query next key binding */
1538 DrawText(SX, SY+(2+2*step_nr)*32,
1539 customize_step[step_nr].text, FS_BIG, FC_RED);
1540 DrawText(SX, SY+(2+2*step_nr+1)*32,
1541 "Key:", FS_BIG, FC_RED);
1542 DrawText(SX + 4*32, SY+(2+2*step_nr+1)*32,
1543 getKeyNameFromKeySym(*customize_step[step_nr].keysym),
1549 key_joystick_mapping = 0;
1553 HandleOtherEvents(&event);
1561 /* don't eat all CPU time */
1565 /* write new key bindings back to player setup */
1566 setup.input[player_nr].key = custom_key;
1569 DrawSetupInputScreen();
1572 void CalibrateJoystick(int joystick_nr)
1575 struct joystick joy_ctrl;
1577 struct joystick_control
1589 int new_joystick_xleft = 128, new_joystick_xright = 128;
1590 int new_joystick_yupper = 128, new_joystick_ylower = 128;
1591 int new_joystick_xmiddle, new_joystick_ymiddle;
1592 int x, y, last_x, last_y, xpos = 8, ypos = 3;
1593 boolean check[3][3];
1594 int check_remaining = 3 * 3;
1598 if (joystick_status == JOYSTICK_OFF)
1602 DrawText(SX, SY + 6*32, " ROTATE JOYSTICK ",FS_BIG,FC_YELLOW);
1603 DrawText(SX, SY + 7*32, "IN ALL DIRECTIONS",FS_BIG,FC_YELLOW);
1604 DrawText(SX + 16, SY + 9*32, " IF ALL BALLS ",FS_BIG,FC_YELLOW);
1605 DrawText(SX, SY + 10*32, " ARE YELLOW, ",FS_BIG,FC_YELLOW);
1606 DrawText(SX, SY + 11*32, " PRESS BUTTON! ",FS_BIG,FC_YELLOW);
1612 check[x][y] = FALSE;
1613 DrawGraphic(xpos + x - 1, ypos + y - 1, GFX_KUGEL_BLAU);
1618 last_x = (joy & JOY_LEFT ? -1 : joy & JOY_RIGHT ? +1 : 0);
1619 last_y = (joy & JOY_UP ? -1 : joy & JOY_DOWN ? +1 : 0);
1620 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_ROT);
1625 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1627 joy_ctrl.buttons = 0;
1630 while(Joystick() & JOY_BUTTON);
1636 if (XPending(display)) /* got event from X server */
1640 XNextEvent(display, &event);
1645 switch(XLookupKeysym((XKeyEvent *)&event,
1646 ((XKeyEvent *)&event)->state))
1649 if (check_remaining == 0)
1663 key_joystick_mapping = 0;
1667 HandleOtherEvents(&event);
1672 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1674 joystick_status = JOYSTICK_OFF;
1678 new_joystick_xleft = MIN(new_joystick_xleft, joy_ctrl.x);
1679 new_joystick_xright = MAX(new_joystick_xright, joy_ctrl.x);
1680 new_joystick_yupper = MIN(new_joystick_yupper, joy_ctrl.y);
1681 new_joystick_ylower = MAX(new_joystick_ylower, joy_ctrl.y);
1683 new_joystick_xmiddle =
1684 new_joystick_xleft + (new_joystick_xright - new_joystick_xleft) / 2;
1685 new_joystick_ymiddle =
1686 new_joystick_yupper + (new_joystick_ylower - new_joystick_yupper) / 2;
1688 joystick[joystick_nr].xleft = new_joystick_xleft;
1689 joystick[joystick_nr].yupper = new_joystick_yupper;
1690 joystick[joystick_nr].xright = new_joystick_xright;
1691 joystick[joystick_nr].ylower = new_joystick_ylower;
1692 joystick[joystick_nr].xmiddle = new_joystick_xmiddle;
1693 joystick[joystick_nr].ymiddle = new_joystick_ymiddle;
1695 CheckJoystickData();
1699 if (joy & JOY_BUTTON && check_remaining == 0)
1702 x = (joy & JOY_LEFT ? -1 : joy & JOY_RIGHT ? +1 : 0);
1703 y = (joy & JOY_UP ? -1 : joy & JOY_DOWN ? +1 : 0);
1705 if (x != last_x || y != last_y)
1707 DrawGraphic(xpos + last_x, ypos + last_y, GFX_KUGEL_GELB);
1708 DrawGraphic(xpos + x, ypos + y, GFX_KUGEL_ROT);
1713 if (check_remaining > 0 && !check[x+1][y+1])
1715 check[x+1][y+1] = TRUE;
1720 printf("LEFT / MIDDLE / RIGHT == %d / %d / %d\n",
1721 joystick[joystick_nr].xleft,
1722 joystick[joystick_nr].xmiddle,
1723 joystick[joystick_nr].xright);
1724 printf("UP / MIDDLE / DOWN == %d / %d / %d\n",
1725 joystick[joystick_nr].yupper,
1726 joystick[joystick_nr].ymiddle,
1727 joystick[joystick_nr].ylower);
1734 /* don't eat all CPU time */
1740 DrawSetupInputScreen();
1741 while(Joystick() & JOY_BUTTON);
1747 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
1748 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
1751 DrawSetupInputScreen();
1754 void CalibrateJoystick_OLD()
1757 struct joystick joy_ctrl;
1759 struct joystick_control
1771 int joystick_nr = setup.input[0].joystick_nr;
1772 int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
1773 int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
1775 if (joystick_status == JOYSTICK_OFF)
1780 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1781 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1782 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1786 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1788 joy_ctrl.buttons = 0;
1790 while(Joystick() & JOY_BUTTON);
1792 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1794 while(!joy_ctrl.buttons)
1797 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1799 joystick_status=JOYSTICK_OFF;
1805 new_joystick_xleft = joy_ctrl.x;
1806 new_joystick_yupper = joy_ctrl.y;
1809 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1810 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1811 DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1815 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1817 joy_ctrl.buttons = 0;
1819 while(Joystick() & JOY_BUTTON);
1821 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1823 while(!joy_ctrl.buttons)
1826 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1828 joystick_status=JOYSTICK_OFF;
1834 new_joystick_xright = joy_ctrl.x;
1835 new_joystick_ylower = joy_ctrl.y;
1838 DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
1839 DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW);
1843 joy_ctrl.b1 = joy_ctrl.b2 = 0;
1845 joy_ctrl.buttons = 0;
1847 while(Joystick() & JOY_BUTTON);
1849 while(!(joy_ctrl.b1 || joy_ctrl.b2))
1851 while(!joy_ctrl.buttons)
1854 if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl))
1856 joystick_status=JOYSTICK_OFF;
1862 new_joystick_xmiddle = joy_ctrl.x;
1863 new_joystick_ymiddle = joy_ctrl.y;
1865 joystick[joystick_nr].xleft = new_joystick_xleft;
1866 joystick[joystick_nr].yupper = new_joystick_yupper;
1867 joystick[joystick_nr].xright = new_joystick_xright;
1868 joystick[joystick_nr].ylower = new_joystick_ylower;
1869 joystick[joystick_nr].xmiddle = new_joystick_xmiddle;
1870 joystick[joystick_nr].ymiddle = new_joystick_ymiddle;
1872 CheckJoystickData();
1875 while(Joystick() & JOY_BUTTON);
1883 joy_nr[1] = SETUP_2ND_JOYSTICK_ON(local_player->setup)+49;
1888 DrawText(SX+32, SY+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW);
1889 DrawText(SX+16+7*32, SY+8*32, joy_nr, FS_BIG,FC_YELLOW);
1890 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
1893 for(clear_keybuf();!keypressed(););
1894 install_joystick(JOY_TYPE_2PADS);
1897 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1898 DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW);
1899 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
1902 for(clear_keybuf();!keypressed(););
1903 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
1906 DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW);
1907 DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW);
1908 DrawText(SX+32, SY+9*32, "AND PRESS A KEY",FS_BIG,FC_YELLOW);
1911 for(clear_keybuf();!keypressed(););
1912 calibrate_joystick(SETUP_2ND_JOYSTICK_ON(local_player->setup));
1919 DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW);
1920 DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW);
1926 void HandleGameActions()
1928 if (game_status != PLAYING)
1931 if (local_player->LevelSolved)
1934 if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
1942 void HandleVideoButtons(int mx, int my, int button)
1944 if (game_status != MAINMENU && game_status != PLAYING)
1947 switch(CheckVideoButtons(mx,my,button))
1949 case BUTTON_VIDEO_EJECT:
1951 if (TAPE_IS_EMPTY(tape))
1953 LoadLevelTape(level_nr);
1954 if (TAPE_IS_EMPTY(tape))
1955 Request("No tape for this level !",REQ_CONFIRM);
1960 SaveLevelTape(tape.level_nr);
1963 DrawCompleteVideoDisplay();
1966 case BUTTON_VIDEO_STOP:
1970 case BUTTON_VIDEO_PAUSE:
1974 case BUTTON_VIDEO_REC:
1975 if (TAPE_IS_STOPPED(tape))
1977 TapeStartRecording();
1979 if (options.network)
1980 SendToServer_StartPlaying();
1983 game_status = PLAYING;
1987 else if (tape.pausing)
1989 if (tape.playing) /* PLAYING -> PAUSING -> RECORDING */
1991 tape.pos[tape.counter].delay = tape.delay_played;
1992 tape.playing = FALSE;
1993 tape.recording = TRUE;
1994 tape.changed = TRUE;
1996 DrawVideoDisplay(VIDEO_STATE_PLAY_OFF | VIDEO_STATE_REC_ON,0);
2003 case BUTTON_VIDEO_PLAY:
2004 if (TAPE_IS_EMPTY(tape))
2007 if (TAPE_IS_STOPPED(tape))
2011 game_status = PLAYING;
2014 else if (tape.playing)
2016 if (tape.pausing) /* PAUSE -> PLAY */
2018 else if (!tape.fast_forward) /* PLAY -> FAST FORWARD PLAY */
2020 tape.fast_forward = TRUE;
2021 DrawVideoDisplay(VIDEO_STATE_FFWD_ON, 0);
2023 else if (!tape.pause_before_death) /* FFWD PLAY -> + AUTO PAUSE */
2025 tape.pause_before_death = TRUE;
2026 DrawVideoDisplay(VIDEO_STATE_PAUSE_ON, VIDEO_DISPLAY_LABEL_ONLY);
2028 else /* -> NORMAL PLAY */
2030 tape.fast_forward = FALSE;
2031 tape.pause_before_death = FALSE;
2032 DrawVideoDisplay(VIDEO_STATE_FFWD_OFF | VIDEO_STATE_PAUSE_OFF, 0);
2044 void HandleSoundButtons(int mx, int my, int button)
2046 if (game_status != PLAYING)
2049 switch(CheckSoundButtons(mx,my,button))
2051 case BUTTON_SOUND_MUSIC:
2052 if (setup.sound_music_on)
2054 setup.sound_music_on = FALSE;
2055 FadeSound(background_loop[level_nr % num_bg_loops]);
2056 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2058 else if (sound_loops_allowed)
2060 setup.sound_on = setup.sound_music_on = TRUE;
2061 PlaySoundLoop(background_loop[level_nr % num_bg_loops]);
2062 DrawSoundDisplay(BUTTON_SOUND_MUSIC_ON);
2065 DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
2068 case BUTTON_SOUND_LOOPS:
2069 if (setup.sound_loops_on)
2071 setup.sound_loops_on = FALSE;
2072 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2074 else if (sound_loops_allowed)
2076 setup.sound_on = setup.sound_loops_on = TRUE;
2077 DrawSoundDisplay(BUTTON_SOUND_LOOPS_ON);
2080 DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
2083 case BUTTON_SOUND_SIMPLE:
2084 if (setup.sound_simple_on)
2086 setup.sound_simple_on = FALSE;
2087 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2089 else if (sound_status==SOUND_AVAILABLE)
2091 setup.sound_on = setup.sound_simple_on = TRUE;
2092 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_ON);
2095 DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
2105 void HandleGameButtons(int mx, int my, int button)
2107 if (game_status != PLAYING)
2110 switch(CheckGameButtons(mx,my,button))
2112 case BUTTON_GAME_STOP:
2115 CloseDoor(DOOR_CLOSE_1);
2116 game_status = MAINMENU;
2121 if (Request("Do you really want to quit the game ?",
2122 REQ_ASK | REQ_STAY_CLOSED))
2124 if (options.network)
2125 SendToServer_StopPlaying();
2128 game_status = MAINMENU;
2133 OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
2136 case BUTTON_GAME_PAUSE:
2137 if (options.network)
2140 SendToServer_ContinuePlaying();
2142 SendToServer_PausePlaying();
2150 if (options.network)
2151 SendToServer_ContinuePlaying();
2154 tape.pausing = FALSE;
2155 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
2160 if (options.network)
2161 SendToServer_PausePlaying();
2164 tape.pausing = TRUE;
2165 DrawVideoDisplay(VIDEO_STATE_PAUSE_ON,0);
2172 case BUTTON_GAME_PLAY:
2175 if (options.network)
2176 SendToServer_ContinuePlaying();
2179 tape.pausing = FALSE;
2180 DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);