From c3d03cdffce070695ba0520d00667b42b8460087 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sun, 5 Nov 1995 22:29:59 +0100 Subject: [PATCH] rocks_n_diamonds-0.9b --- CHANGES | 16 + REGISTRATION | 66 +-- THIS_IS_NOW_FREEWARE | 23 + src/Makefile | 39 +- src/buttons.c | 963 +++++++++++++++++++++++++++++++++++ src/buttons.h | 509 +++++++++++++++++++ src/editor.c | 507 +++---------------- src/editor.h | 273 +--------- src/events.c | 7 +- src/events.h | 2 - src/files.c | 703 ++++++++++++++++++++++++++ src/files.h | 65 +++ src/game.c | 1147 ++++++++++-------------------------------- src/game.h | 24 +- src/images.c | 41 -- src/images.h | 25 - src/init.c | 326 +++++++++++- src/init.h | 4 +- src/main.c | 16 +- src/main.h | 361 ++++--------- src/misc.c | 195 ++++--- src/misc.h | 10 +- src/screens.c | 525 +++++++------------ src/screens.h | 36 +- src/sound.c | 2 - src/sound.h | 6 +- src/tools.c | 579 +++++++-------------- src/tools.h | 16 +- 28 files changed, 3598 insertions(+), 2888 deletions(-) mode change 100644 => 120000 REGISTRATION create mode 100644 THIS_IS_NOW_FREEWARE create mode 100644 src/buttons.c create mode 100644 src/buttons.h create mode 100644 src/files.c create mode 100644 src/files.h delete mode 100644 src/images.c delete mode 100644 src/images.h diff --git a/CHANGES b/CHANGES index 0dafe5df..5ad2b64d 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,20 @@ +Prerelease Version 0.9b [4 NOV 95] +------------------------------------ + - the game is now completely Freeware + - the game is now better playable by keyboard + (in the last version, the player was making more than + one step for one keystroke in some cases -- thanks to + Warwick Allison for the hint with "XSync()"!) + - new amoeba type with configurable content (like in the + original C64 version, when aboeba cannot grow anymore + and explodes to diamonds or some other elements) + - compile error with ONE_PER_NAME in high score function + removed (thanks to Dmitry Kohmanyuk) + - little code cleanup (to get some new bugs ;) + - FreeBSD sound and joystick support (thanks to Jean-Marc + Zucconi) + Prerelease Version 0.9 [23 OCT 95] ---------------------------------- - first (pre)release version diff --git a/REGISTRATION b/REGISTRATION deleted file mode 100644 index 00233a6a..00000000 --- a/REGISTRATION +++ /dev/null @@ -1,65 +0,0 @@ - -How to (and why) become a registered user of Rocks'n'Diamonds -============================================================= - -It was much fun writing this game, and I hope that it is much fun playing -it, too. - -Writing it was much work, too, and if you like this game, please think about -becoming a registered user. Registered users will get a keyfile which allows -them to use registered-users-only level series, starting with 50 new levels -when version 1.0 come out (around December '95 or January '96). If you own -the Amiga game "Emerald Mine", you can use its levels with the registered -version of Rocks'n'Diamonds, too. - -There are some other plans for future versions of Rocks'n'Diamonds which -will be only available for registered users, like support for more than -one player on one machine, multi-player support for games over a network -or Dyna-Blaster like levels (especially for multi player modes). - -If you want to become a registered user, send $20 or DM 20 to the -following Snail-Mail address: - - Holger Schemel - Sennehof 28 - 33659 Bielefeld - GERMANY - -... and send the filled-out registration form (at the end of this file) -to the following E-Mail address: - - aeglos@valinor.owl.de - -If you live outside Europe, you can use an international money order -or just send a banknote, if you live in Europe, you can send an Euro- -Cheque or remit the registration fee directly to my bank account in -Germany (please write a short e-mail note and I'll send you the bank -account information). - -You will then get a patch to change the program to a registered version -(together with each main release version, if needed), a keyfile to use -the registered-users-only level series and a little program to convert -old "Emerald Mine" levels to Rocks'n'Diamonds levels. - ----------- 8< ---------- cut here ---------- 8< ---------- - -Name: ----------------------------------------------------------- -Street: ----------------------------------------------------------- -City: ----------------------------------------------------------- -Country: ----------------------------------------------------------- -E-Mail: ----------------------------------------------------------- -Username: ----------------------------------------------------------- - -(All informations will only be used to create a personalized -keyfile. The game will work for the user in "Username", the -fields "Name" to "Country" will appear in the info screen -and your e-mail address will be used to inform you of new -main release versions of Rocks'n'Diamonds.) - ----------- 8< ---------- cut here ---------- 8< ---------- diff --git a/REGISTRATION b/REGISTRATION new file mode 120000 index 00000000..5f4a260c --- /dev/null +++ b/REGISTRATION @@ -0,0 +1 @@ +THIS_IS_NOW_FREEWARE \ No newline at end of file diff --git a/THIS_IS_NOW_FREEWARE b/THIS_IS_NOW_FREEWARE new file mode 100644 index 00000000..c0e5098a --- /dev/null +++ b/THIS_IS_NOW_FREEWARE @@ -0,0 +1,23 @@ + +THIS GAME IS NOW COMPLETELY FREEWARE! +===================================== + +In version 0.9, I planned to offer the possibility to become a +registered user and get special level series for registered users +only and some more things. + +Now I have decided that it is better to distribute it as Freeware, +that means: Freely distributable, but still copyrighted software. + +If you like this game, please send me mail about it! + + aeglos@valinor.owl.de + +or SnailMail: + + Holger Schemel + Sennehof 28 + 33659 Bielefeld + GERMANY + +Have fun! diff --git a/src/Makefile b/src/Makefile index fffe019c..7333fb28 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,6 +6,7 @@ PROGNAME = rocksndiamonds RM = rm -f CC = gcc +CPP = $(CC) -E # CC = cc # for HP-UX and others GAME_DIR = -DGAME_DIR=\".\" # path of the game and its data @@ -35,15 +36,28 @@ LIBS = -lXpm -lXpm -lXpm -lX11 -lm # triple -lXpm; else I got an error... # CFLAGS = -O2 $(CONFIG) $(SYSTEM) CFLAGS = $(DEBUG) $(CONFIG) $(SYSTEM) $(INCL) -OBJS = main.o \ - init.o \ - images.o \ - events.o \ - tools.o \ - screens.o \ - misc.o \ - game.o \ - editor.o \ +SRCS = main.c \ + init.c \ + events.c \ + tools.c \ + screens.c \ + misc.c \ + game.c \ + editor.c \ + buttons.c \ + files.c \ + sound.c + +OBJS = main.o \ + init.o \ + events.o \ + tools.o \ + screens.o \ + misc.o \ + game.o \ + editor.o \ + buttons.o \ + files.o \ sound.o all: $(OBJS) @@ -54,3 +68,10 @@ all: $(OBJS) clean: $(RM) $(OBJS) + +depend: + for i in $(SRCS); do $(CPP) $(CFLAGS) -M $$i; done > .depend + +ifeq (.depend,$(wildcard .depend)) +include .depend +endif diff --git a/src/buttons.c b/src/buttons.c new file mode 100644 index 00000000..8b825451 --- /dev/null +++ b/src/buttons.c @@ -0,0 +1,963 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* ©1995 Artsoft Development * +* Holger Schemel * +* 33659 Bielefeld-Senne * +* Telefon: (0521) 493245 * +* eMail: aeglos@valinor.owl.de * +* aeglos@uni-paderborn.de * +* q99492@pbhrzx.uni-paderborn.de * +*----------------------------------------------------------* +* buttons.c * +***********************************************************/ + +#include "buttons.h" +#include "tools.h" +#include "misc.h" +#include "editor.h" + +/****************************************************************/ +/********** drawing buttons and corresponding displays **********/ +/****************************************************************/ + +void DrawVideoDisplay(unsigned long state, unsigned long value) +{ + int i; + int part1 = 0, part2 = 1; + int xpos = 0, ypos = 1, xsize = 2, ysize = 3; + static char *monatsname[12] = + { + "JAN", "FEB", "MAR", "APR", "MAY", "JUN", + "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" + }; + static int video_pos[10][2][4] = + { + VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS, + VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE, + VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS, + VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE, + + VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS, + VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE, + VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS, + VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE, + + VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS, + VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE, + VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS, + VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE, + + VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS, + VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE, + VIDEO_DATE_XPOS, VIDEO_DATE_YPOS, + VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE, + + 0,0, + 0,0, + VIDEO_TIME_XPOS, VIDEO_TIME_YPOS, + VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE, + + VIDEO_BUTTON_PLAY_XPOS, VIDEO_BUTTON_ANY_YPOS, + VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, + 0,0, + 0,0, + + VIDEO_BUTTON_REC_XPOS, VIDEO_BUTTON_ANY_YPOS, + VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, + 0,0, + 0,0, + + VIDEO_BUTTON_PAUSE_XPOS, VIDEO_BUTTON_ANY_YPOS, + VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, + 0,0, + 0,0, + + VIDEO_BUTTON_STOP_XPOS, VIDEO_BUTTON_ANY_YPOS, + VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, + 0,0, + 0,0, + + VIDEO_BUTTON_EJECT_XPOS, VIDEO_BUTTON_ANY_YPOS, + VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, + 0,0, + 0,0 + }; + + for(i=0;i<20;i++) + { + if (state & (1< STATE_ON / PRESS_OFF */ + cx = DOOR_GFX_PAGEX4; + else + cx = DOOR_GFX_PAGEX3; /* i gerade => STATE_OFF / PRESS_ON */ + + if (video_pos[pos][part1][0]) + XCopyArea(display,pix[PIX_DOOR],drawto,gc, + cx + video_pos[pos][part1][xpos], + cy + video_pos[pos][part1][ypos], + video_pos[pos][part1][xsize], + video_pos[pos][part1][ysize], + VX + video_pos[pos][part1][xpos], + VY + video_pos[pos][part1][ypos]); + if (video_pos[pos][part2][0]) + XCopyArea(display,pix[PIX_DOOR],drawto,gc, + cx + video_pos[pos][part2][xpos], + cy + video_pos[pos][part2][ypos], + video_pos[pos][part2][xsize], + video_pos[pos][part2][ysize], + VX + video_pos[pos][part2][xpos], + VY + video_pos[pos][part2][ypos]); + } + } + + if (state & VIDEO_STATE_DATE_ON) + { + int tag = value % 100; + int monat = (value/100) % 100; + int jahr = (value/10000); + + DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS, + int2str(tag,2),FS_SMALL,FC_SPECIAL1); + DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS, + monatsname[monat],FS_SMALL,FC_SPECIAL1); + DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS, + int2str(jahr,2),FS_SMALL,FC_SPECIAL1); + } + + if (state & VIDEO_STATE_TIME_ON) + { + int min = value / 60; + int sec = value % 60; + + DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS, + int2str(min,2),FS_SMALL,FC_SPECIAL1); + DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS, + int2str(sec,2),FS_SMALL,FC_SPECIAL1); + } + + if (state & VIDEO_STATE_DATE) + redraw_mask |= REDRAW_VIDEO_1; + if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE) + redraw_mask |= REDRAW_VIDEO_2; + if (state & VIDEO_PRESS) + redraw_mask |= REDRAW_VIDEO_3; +} + +void DrawCompleteVideoDisplay() +{ + XCopyArea(display,pix[PIX_DOOR],drawto,gc, + DOOR_GFX_PAGEX3,DOOR_GFX_PAGEY2, VXSIZE,VYSIZE, VX,VY); + XCopyArea(display,pix[PIX_DOOR],drawto,gc, + DOOR_GFX_PAGEX4+VIDEO_CONTROL_XPOS, + DOOR_GFX_PAGEY2+VIDEO_CONTROL_YPOS, + VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE, + VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS); + + DrawVideoDisplay(VIDEO_ALL_OFF,0); + if (tape.date && tape.length) + { + DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date); + DrawVideoDisplay(VIDEO_STATE_TIME_ON,0); + } + + XCopyArea(display,drawto,pix[PIX_DB_DOOR],gc, + VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2); +} + +void DrawSoundDisplay(unsigned long state) +{ + int pos, cx = DOOR_GFX_PAGEX4, cy = 0; + + pos = (state & BUTTON_SOUND_MUSIC ? SOUND_BUTTON_MUSIC_XPOS : + state & BUTTON_SOUND_LOOPS ? SOUND_BUTTON_LOOPS_XPOS : + SOUND_BUTTON_SOUND_XPOS); + + if (state & BUTTON_ON) + cy -= SOUND_BUTTON_YSIZE; + + if (state & BUTTON_PRESSED) + cx = DOOR_GFX_PAGEX3; + + XCopyArea(display,pix[PIX_DOOR],drawto,gc, + cx + pos,cy + SOUND_BUTTON_ANY_YPOS, + SOUND_BUTTON_XSIZE,SOUND_BUTTON_YSIZE, + DX + pos,DY + SOUND_BUTTON_ANY_YPOS); + + redraw_mask |= REDRAW_DOOR_1; +} + +void DrawGameButton(unsigned long state) +{ + int pos, cx = DOOR_GFX_PAGEX4, cy = -GAME_BUTTON_YSIZE; + + pos = (state & BUTTON_GAME_STOP ? GAME_BUTTON_STOP_XPOS : + state & BUTTON_GAME_PAUSE ? GAME_BUTTON_PAUSE_XPOS : + GAME_BUTTON_PLAY_XPOS); + + if (state & BUTTON_PRESSED) + cx = DOOR_GFX_PAGEX3; + + XCopyArea(display,pix[PIX_DOOR],drawto,gc, + cx + pos,cy + GAME_BUTTON_ANY_YPOS, + GAME_BUTTON_XSIZE,GAME_BUTTON_YSIZE, + DX + pos,DY + GAME_BUTTON_ANY_YPOS); + + redraw_mask |= REDRAW_DOOR_1; +} + +void DrawChooseButton(unsigned long state) +{ + int pos, cx = DOOR_GFX_PAGEX4, cy = 0; + + pos = (state & BUTTON_OK ? OK_BUTTON_XPOS : NO_BUTTON_XPOS); + + if (state & BUTTON_PRESSED) + cx = DOOR_GFX_PAGEX3; + + XCopyArea(display,pix[PIX_DOOR],drawto,gc, + cx + pos,cy + OK_BUTTON_GFX_YPOS, + OK_BUTTON_XSIZE,OK_BUTTON_YSIZE, + DX + pos,DY + OK_BUTTON_YPOS); + + redraw_mask |= REDRAW_DOOR_1; +} + +void DrawConfirmButton(unsigned long state) +{ + int cx = DOOR_GFX_PAGEX4, cy = 0; + + if (state & BUTTON_PRESSED) + cx = DOOR_GFX_PAGEX3; + + XCopyArea(display,pix[PIX_DOOR],drawto,gc, + cx + CONFIRM_BUTTON_XPOS,cy + CONFIRM_BUTTON_GFX_YPOS, + CONFIRM_BUTTON_XSIZE,CONFIRM_BUTTON_YSIZE, + DX + CONFIRM_BUTTON_XPOS,DY + CONFIRM_BUTTON_YPOS); + + redraw_mask |= REDRAW_DOOR_1; +} + +/* several buttons in the level editor */ + +void DrawEditButton(unsigned long state) +{ + int i; + int xpos = 0, ypos = 1, xsize = 2, ysize = 3; + int cx = DOOR_GFX_PAGEX6, cy = DOOR_GFX_PAGEY2; + static int edit_pos[6][4] = + { + ED_BUTTON_CTRL_XPOS,ED_BUTTON_CTRL_YPOS, + ED_BUTTON_CTRL_XSIZE,ED_BUTTON_CTRL_YSIZE, + + ED_BUTTON_FILL_XPOS,ED_BUTTON_FILL_YPOS, + ED_BUTTON_FILL_XSIZE,ED_BUTTON_FILL_YSIZE, + + ED_BUTTON_LEFT_XPOS,ED_BUTTON_LEFT_YPOS, + ED_BUTTON_LEFT_XSIZE,ED_BUTTON_LEFT_YSIZE, + + ED_BUTTON_UP_XPOS,ED_BUTTON_UP_YPOS, + ED_BUTTON_UP_XSIZE,ED_BUTTON_UP_YSIZE, + + ED_BUTTON_DOWN_XPOS,ED_BUTTON_DOWN_YPOS, + ED_BUTTON_DOWN_XSIZE,ED_BUTTON_DOWN_YSIZE, + + ED_BUTTON_RIGHT_XPOS,ED_BUTTON_RIGHT_YPOS, + ED_BUTTON_RIGHT_XSIZE,ED_BUTTON_RIGHT_YSIZE + }; + + if (state & ED_BUTTON_PRESSED) + cx = DOOR_GFX_PAGEX5; + + for(i=0;i<6;i++) + { + if (state & (1<=0 && pressed) + { + pressed = FALSE; + DrawVideoDisplay(video_button[choice]<<1,0); + } + else if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && !pressed) + { + pressed = TRUE; + DrawVideoDisplay(video_button[choice],0); + } + } + } + else /* Maustaste wieder losgelassen */ + { + if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && pressed) + { + DrawVideoDisplay(video_button[choice]<<1,0); + return_code = choice+1; + choice = -1; + pressed = FALSE; + } + else + { + choice = -1; + pressed = FALSE; + } + } + + BackToFront(); + return(return_code); +} + +int CheckSoundButtons(int mx, int my, int button) +{ + int return_code = 0; + static int choice = -1; + static BOOL pressed = FALSE; + int sound_state[3]; + + sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * sound_music_on); + sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * sound_loops_on); + sound_state[2] = BUTTON_SOUND_SOUND | (BUTTON_ON * sound_on); + + if (button) + { + if (!motion_status) /* Maustaste neu gedrückt */ + { + if (ON_SOUND_BUTTON(mx,my)) + { + choice = SOUND_BUTTON(mx); + pressed = TRUE; + DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED); + } + } + else /* Mausbewegung bei gedrückter Maustaste */ + { + if ((!ON_SOUND_BUTTON(mx,my) || SOUND_BUTTON(mx)!=choice) && + choice>=0 && pressed) + { + pressed = FALSE; + DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED); + } + else if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && !pressed) + { + pressed = TRUE; + DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED); + } + } + } + else /* Maustaste wieder losgelassen */ + { + if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && pressed) + { + DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED); + return_code = 1<=0 && pressed) + { + pressed = FALSE; + DrawGameButton(game_state[choice] | BUTTON_RELEASED); + } + else if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && !pressed) + { + pressed = TRUE; + DrawGameButton(game_state[choice] | BUTTON_PRESSED); + } + } + } + else /* Maustaste wieder losgelassen */ + { + if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && pressed) + { + DrawGameButton(game_state[choice] | BUTTON_RELEASED); + return_code = 1<=0 && pressed) + { + pressed = FALSE; + DrawChooseButton(choose_button[choice] | BUTTON_RELEASED); + } + else if (ON_CHOOSE_BUTTON(mx,my) &&CHOOSE_BUTTON(mx)==choice && !pressed) + { + pressed = TRUE; + DrawChooseButton(choose_button[choice] | BUTTON_PRESSED); + } + } + } + else /* Maustaste wieder losgelassen */ + { + if (ON_CHOOSE_BUTTON(mx,my) && CHOOSE_BUTTON(mx)==choice && pressed) + { + DrawChooseButton(choose_button[choice] | BUTTON_RELEASED); + return_code = choice+1; + choice = -1; + pressed = FALSE; + } + else + { + choice = -1; + pressed = FALSE; + } + } + + BackToFront(); + return(return_code); +} + +int CheckConfirmButton(int mx, int my, int button) +{ + int return_code = 0; + static int choice = -1; + static BOOL pressed = FALSE; + + if (button) + { + if (!motion_status) /* Maustaste neu gedrückt */ + { + if (ON_CONFIRM_BUTTON(mx,my)) + { + choice = 0; + pressed = TRUE; + DrawConfirmButton(BUTTON_PRESSED); + } + } + else /* Mausbewegung bei gedrückter Maustaste */ + { + if (!ON_CONFIRM_BUTTON(mx,my) && choice>=0 && pressed) + { + pressed = FALSE; + DrawConfirmButton(BUTTON_RELEASED); + } + else if (ON_CONFIRM_BUTTON(mx,my) && !pressed) + { + pressed = TRUE; + DrawConfirmButton(BUTTON_PRESSED); + } + } + } + else /* Maustaste wieder losgelassen */ + { + if (ON_CONFIRM_BUTTON(mx,my) && pressed) + { + DrawConfirmButton(BUTTON_RELEASED); + return_code = BUTTON_CONFIRM; + choice = -1; + pressed = FALSE; + } + else + { + choice = -1; + pressed = FALSE; + } + } + + BackToFront(); + return(return_code); +} + +/* several buttons in the level editor */ + +int CheckEditButtons(int mx, int my, int button) +{ + int return_code = 0; + static int choice = -1; + static BOOL pressed = FALSE; + static int edit_button[6] = + { + ED_BUTTON_CTRL, + ED_BUTTON_FILL, + ED_BUTTON_LEFT, + ED_BUTTON_UP, + ED_BUTTON_DOWN, + ED_BUTTON_RIGHT + }; + + if (button) + { + if (!motion_status) /* Maustaste neu gedrückt */ + { + if (ON_EDIT_BUTTON(mx,my)) + { + choice = EDIT_BUTTON(mx,my); + pressed = TRUE; + DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED); + if (edit_button[choice]!=ED_BUTTON_CTRL && + edit_button[choice]!=ED_BUTTON_FILL) + return_code = 1<=0 && pressed) + { + pressed = FALSE; + DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED); + } + else if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice) + { + if (!pressed) + DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED); + pressed = TRUE; + if (edit_button[choice]!=ED_BUTTON_CTRL && + edit_button[choice]!=ED_BUTTON_FILL) + return_code = 1<=0 && pressed) + { + pressed = FALSE; + DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED); + } + else if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && !pressed) + { + pressed = TRUE; + DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED); + } + } + } + else /* Maustaste wieder losgelassen */ + { + if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && pressed) + { + DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED); + return_code = 1<<(choice+6); + choice = -1; + pressed = FALSE; + } + else + { + choice = -1; + pressed = FALSE; + } + } + + BackToFront(); + return(return_code); +} + +int CheckElemButtons(int mx, int my, int button) +{ + int return_code = -1; + static int choice = -1; + static BOOL pressed = FALSE; + + if (button) + { + if (!motion_status) /* Maustaste neu gedrückt */ + { + if (ON_ELEM_BUTTON(mx,my)) + { + choice = ELEM_BUTTON(mx,my); + pressed = TRUE; + DrawElemButton(choice,ED_BUTTON_PRESSED); + if (choice==ED_BUTTON_EUP || + choice==ED_BUTTON_EDOWN) + return_code = choice; + } + } + else /* Mausbewegung bei gedrückter Maustaste */ + { + if ((!ON_ELEM_BUTTON(mx,my) || ELEM_BUTTON(mx,my)!=choice) && + choice>=0 && pressed) + { + pressed = FALSE; + DrawElemButton(choice,ED_BUTTON_RELEASED); + } + else if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice) + { + if (!pressed) + DrawElemButton(choice,ED_BUTTON_PRESSED); + pressed = TRUE; + if (choice==ED_BUTTON_EUP || + choice==ED_BUTTON_EDOWN) + return_code = choice; + } + } + } + else /* Maustaste wieder losgelassen */ + { + if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice && pressed) + { + DrawElemButton(choice,ED_BUTTON_RELEASED); + if (choice!=ED_BUTTON_EUP && + choice!=ED_BUTTON_EDOWN) + return_code = choice; + choice = -1; + pressed = FALSE; + } + else + { + choice = -1; + pressed = FALSE; + } + } + + BackToFront(); + return(return_code); +} + +int CheckCountButtons(int mx, int my, int button) +{ + int return_code = -1; + static int choice = -1; + static BOOL pressed = FALSE; + + if (button) + { + if (!motion_status) /* Maustaste neu gedrückt */ + { + if (ON_COUNT_BUTTON(mx,my)) + { + choice = COUNT_BUTTON(mx,my); + pressed = TRUE; + DrawCountButton(choice,ED_BUTTON_PRESSED); + return_code = choice; + } + } + else /* Mausbewegung bei gedrückter Maustaste */ + { + if ((!ON_COUNT_BUTTON(mx,my) || COUNT_BUTTON(mx,my)!=choice) && + choice>=0 && pressed) + { + pressed = FALSE; + DrawCountButton(choice,ED_BUTTON_RELEASED); + } + else if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice) + { + if (!pressed) + DrawCountButton(choice,ED_BUTTON_PRESSED); + pressed = TRUE; + return_code = choice; + } + } + } + else /* Maustaste wieder losgelassen */ + { + if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice && pressed) + { + DrawCountButton(choice,ED_BUTTON_RELEASED); + choice = -1; + pressed = FALSE; + } + else + { + choice = -1; + pressed = FALSE; + } + } + + BackToFront(); + return(return_code); +} diff --git a/src/buttons.h b/src/buttons.h new file mode 100644 index 00000000..98ac5caf --- /dev/null +++ b/src/buttons.h @@ -0,0 +1,509 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* ©1995 Artsoft Development * +* Holger Schemel * +* 33659 Bielefeld-Senne * +* Telefon: (0521) 493245 * +* eMail: aeglos@valinor.owl.de * +* aeglos@uni-paderborn.de * +* q99492@pbhrzx.uni-paderborn.de * +*----------------------------------------------------------* +* buttons.h * +***********************************************************/ + +#ifndef BUTTONS_H +#define BUTTONS_H + +#include "main.h" + +/* some positions in the video tape control window */ +#define VIDEO_DISPLAY1_XPOS 5 +#define VIDEO_DISPLAY1_YPOS 5 +#define VIDEO_DISPLAY2_XPOS 5 +#define VIDEO_DISPLAY2_YPOS 41 +#define VIDEO_DISPLAY_XSIZE 90 +#define VIDEO_DISPLAY_YSIZE 31 +#define VIDEO_BUTTON_XSIZE 18 +#define VIDEO_BUTTON_YSIZE 18 +#define VIDEO_CONTROL_XPOS 5 +#define VIDEO_CONTROL_YPOS 77 +#define VIDEO_CONTROL_XSIZE (VIDEO_DISPLAY_XSIZE) +#define VIDEO_CONTROL_YSIZE (VIDEO_BUTTON_YSIZE) +#define VIDEO_BUTTON_EJECT_XPOS (VIDEO_CONTROL_XPOS + 0 * VIDEO_BUTTON_XSIZE) +#define VIDEO_BUTTON_STOP_XPOS (VIDEO_CONTROL_XPOS + 1 * VIDEO_BUTTON_XSIZE) +#define VIDEO_BUTTON_PAUSE_XPOS (VIDEO_CONTROL_XPOS + 2 * VIDEO_BUTTON_XSIZE) +#define VIDEO_BUTTON_REC_XPOS (VIDEO_CONTROL_XPOS + 3 * VIDEO_BUTTON_XSIZE) +#define VIDEO_BUTTON_PLAY_XPOS (VIDEO_CONTROL_XPOS + 4 * VIDEO_BUTTON_XSIZE) +#define VIDEO_BUTTON_ANY_YPOS (VIDEO_CONTROL_YPOS) +#define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS) +#define VIDEO_DATE_LABEL_YPOS (VIDEO_DISPLAY1_YPOS) +#define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE) +#define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE) +#define VIDEO_DATE_XPOS (VIDEO_DISPLAY1_XPOS+1) +#define VIDEO_DATE_YPOS (VIDEO_DISPLAY1_YPOS+14) +#define VIDEO_DATE_XSIZE (VIDEO_DISPLAY_XSIZE) +#define VIDEO_DATE_YSIZE 16 +#define VIDEO_REC_LABEL_XPOS (VIDEO_DISPLAY2_XPOS) +#define VIDEO_REC_LABEL_YPOS (VIDEO_DISPLAY2_YPOS) +#define VIDEO_REC_LABEL_XSIZE 20 +#define VIDEO_REC_LABEL_YSIZE 12 +#define VIDEO_REC_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+20) +#define VIDEO_REC_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS) +#define VIDEO_REC_SYMBOL_XSIZE 16 +#define VIDEO_REC_SYMBOL_YSIZE 16 +#define VIDEO_PLAY_LABEL_XPOS (VIDEO_DISPLAY2_XPOS+65) +#define VIDEO_PLAY_LABEL_YPOS (VIDEO_DISPLAY2_YPOS) +#define VIDEO_PLAY_LABEL_XSIZE 22 +#define VIDEO_PLAY_LABEL_YSIZE 12 +#define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+50) +#define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS) +#define VIDEO_PLAY_SYMBOL_XSIZE 13 +#define VIDEO_PLAY_SYMBOL_YSIZE 13 +#define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS) +#define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS+20) +#define VIDEO_PAUSE_LABEL_XSIZE 35 +#define VIDEO_PAUSE_LABEL_YSIZE 8 +#define VIDEO_PAUSE_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+35) +#define VIDEO_PAUSE_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS) +#define VIDEO_PAUSE_SYMBOL_XSIZE 13 +#define VIDEO_PAUSE_SYMBOL_YSIZE 13 +#define VIDEO_TIME_XPOS (VIDEO_DISPLAY2_XPOS+38) +#define VIDEO_TIME_YPOS (VIDEO_DISPLAY2_YPOS+14) +#define VIDEO_TIME_XSIZE 50 +#define VIDEO_TIME_YSIZE 16 + +#define ON_VIDEO_BUTTON(x,y) ((x)>=(VX+VIDEO_CONTROL_XPOS) && \ + (x)< (VX+VIDEO_CONTROL_XPOS + \ + VIDEO_CONTROL_XSIZE) && \ + (y)>=(VY+VIDEO_CONTROL_YPOS) && \ + (y)< (VY+VIDEO_CONTROL_YPOS + \ + VIDEO_CONTROL_YSIZE)) +#define VIDEO_BUTTON(x) (((x)-(VX+VIDEO_CONTROL_XPOS))/VIDEO_BUTTON_XSIZE) + +/* values for video tape control */ +#define VIDEO_STATE_PLAY_OFF (1L<<0) +#define VIDEO_STATE_PLAY_ON (1L<<1) +#define VIDEO_STATE_PLAY (VIDEO_STATE_PLAY_OFF | VIDEO_STATE_PLAY_ON) +#define VIDEO_STATE_REC_OFF (1L<<2) +#define VIDEO_STATE_REC_ON (1L<<3) +#define VIDEO_STATE_REC (VIDEO_STATE_REC_OFF | VIDEO_STATE_REC_ON) +#define VIDEO_STATE_PAUSE_OFF (1L<<4) +#define VIDEO_STATE_PAUSE_ON (1L<<5) +#define VIDEO_STATE_PAUSE (VIDEO_STATE_PAUSE_OFF | VIDEO_STATE_PAUSE_ON) +#define VIDEO_STATE_DATE_OFF (1L<<6) +#define VIDEO_STATE_DATE_ON (1L<<7) +#define VIDEO_STATE_DATE (VIDEO_STATE_DATE_OFF | VIDEO_STATE_DATE_ON) +#define VIDEO_STATE_TIME_OFF (1L<<8) +#define VIDEO_STATE_TIME_ON (1L<<9) +#define VIDEO_STATE_TIME (VIDEO_STATE_TIME_OFF | VIDEO_STATE_TIME_ON) +#define VIDEO_PRESS_PLAY_ON (1L<<10) +#define VIDEO_PRESS_PLAY_OFF (1L<<11) +#define VIDEO_PRESS_PLAY (VIDEO_PRESS_PLAY_OFF | VIDEO_PRESS_PLAY_ON) +#define VIDEO_PRESS_REC_ON (1L<<12) +#define VIDEO_PRESS_REC_OFF (1L<<13) +#define VIDEO_PRESS_REC (VIDEO_PRESS_REC_OFF | VIDEO_PRESS_REC_ON) +#define VIDEO_PRESS_PAUSE_ON (1L<<14) +#define VIDEO_PRESS_PAUSE_OFF (1L<<15) +#define VIDEO_PRESS_PAUSE (VIDEO_PRESS_PAUSE_OFF | VIDEO_PRESS_PAUSE_ON) +#define VIDEO_PRESS_STOP_ON (1L<<16) +#define VIDEO_PRESS_STOP_OFF (1L<<17) +#define VIDEO_PRESS_STOP (VIDEO_PRESS_STOP_OFF | VIDEO_PRESS_STOP_ON) +#define VIDEO_PRESS_EJECT_ON (1L<<18) +#define VIDEO_PRESS_EJECT_OFF (1L<<19) +#define VIDEO_PRESS_EJECT (VIDEO_PRESS_EJECT_OFF | VIDEO_PRESS_EJECT_ON) + +#define BUTTON_VIDEO_EJECT 1 +#define BUTTON_VIDEO_STOP 2 +#define BUTTON_VIDEO_PAUSE 3 +#define BUTTON_VIDEO_REC 4 +#define BUTTON_VIDEO_PLAY 5 + +#define VIDEO_STATE_OFF (VIDEO_STATE_PLAY_OFF | \ + VIDEO_STATE_REC_OFF | \ + VIDEO_STATE_PAUSE_OFF | \ + VIDEO_STATE_DATE_OFF | \ + VIDEO_STATE_TIME_OFF) +#define VIDEO_PRESS_OFF (VIDEO_PRESS_PLAY_OFF | \ + VIDEO_PRESS_REC_OFF | \ + VIDEO_PRESS_PAUSE_OFF | \ + VIDEO_PRESS_STOP_OFF | \ + VIDEO_PRESS_EJECT_OFF) +#define VIDEO_ALL_OFF (VIDEO_STATE_OFF | VIDEO_PRESS_OFF) + +#define VIDEO_STATE_ON (VIDEO_STATE_PLAY_ON | \ + VIDEO_STATE_REC_ON | \ + VIDEO_STATE_PAUSE_ON | \ + VIDEO_STATE_DATE_ON | \ + VIDEO_STATE_TIME_ON) +#define VIDEO_PRESS_ON (VIDEO_PRESS_PLAY_ON | \ + VIDEO_PRESS_REC_ON | \ + VIDEO_PRESS_PAUSE_ON | \ + VIDEO_PRESS_STOP_ON | \ + VIDEO_PRESS_EJECT_ON) +#define VIDEO_ALL_ON (VIDEO_STATE_ON | VIDEO_PRESS_ON) + +#define VIDEO_STATE (VIDEO_STATE_ON | VIDEO_STATE_OFF) +#define VIDEO_PRESS (VIDEO_PRESS_ON | VIDEO_PRESS_OFF) +#define VIDEO_ALL (VIDEO_ALL_ON | VIDEO_ALL_OFF) + + +/* some positions in the sound control window */ +#define SOUND_BUTTON_XSIZE 30 +#define SOUND_BUTTON_YSIZE 30 +#define SOUND_CONTROL_XPOS 5 +#define SOUND_CONTROL_YPOS 245 +#define SOUND_CONTROL_XSIZE 90 +#define SOUND_CONTROL_YSIZE (SOUND_BUTTON_YSIZE) +#define SOUND_BUTTON_MUSIC_XPOS (SOUND_CONTROL_XPOS + 0 * SOUND_BUTTON_XSIZE) +#define SOUND_BUTTON_LOOPS_XPOS (SOUND_CONTROL_XPOS + 1 * SOUND_BUTTON_XSIZE) +#define SOUND_BUTTON_SOUND_XPOS (SOUND_CONTROL_XPOS + 2 * SOUND_BUTTON_XSIZE) +#define SOUND_BUTTON_ANY_YPOS (SOUND_CONTROL_YPOS) + +#define ON_SOUND_BUTTON(x,y) ((x)>=(DX+SOUND_CONTROL_XPOS) && \ + (x)< (DX+SOUND_CONTROL_XPOS + \ + SOUND_CONTROL_XSIZE) && \ + (y)>=(DY+SOUND_CONTROL_YPOS) && \ + (y)< (DY+SOUND_CONTROL_YPOS + \ + SOUND_CONTROL_YSIZE)) +#define SOUND_BUTTON(x) (((x)-(DX+SOUND_CONTROL_XPOS))/SOUND_BUTTON_XSIZE) + +/* values for sound control */ +#define BUTTON_SOUND_MUSIC (1L<<0) +#define BUTTON_SOUND_LOOPS (1L<<1) +#define BUTTON_SOUND_SOUND (1L<<2) +#define BUTTON_RELEASED 0 +#define BUTTON_PRESSED (1L<<3) +#define BUTTON_OFF 0 +#define BUTTON_ON (1L<<4) +#define BUTTON_SOUND_MUSIC_OFF (BUTTON_SOUND_MUSIC | BUTTON_OFF) +#define BUTTON_SOUND_LOOPS_OFF (BUTTON_SOUND_LOOPS | BUTTON_OFF) +#define BUTTON_SOUND_SOUND_OFF (BUTTON_SOUND_SOUND | BUTTON_OFF) +#define BUTTON_SOUND_MUSIC_ON (BUTTON_SOUND_MUSIC | BUTTON_ON) +#define BUTTON_SOUND_LOOPS_ON (BUTTON_SOUND_LOOPS | BUTTON_ON) +#define BUTTON_SOUND_SOUND_ON (BUTTON_SOUND_SOUND | BUTTON_ON) + + +/* some positions in the game control window */ +#define GAME_BUTTON_XSIZE 30 +#define GAME_BUTTON_YSIZE 30 +#define GAME_CONTROL_XPOS 5 +#define GAME_CONTROL_YPOS 215 +#define GAME_CONTROL_XSIZE 90 +#define GAME_CONTROL_YSIZE (GAME_BUTTON_YSIZE) +#define GAME_BUTTON_STOP_XPOS (GAME_CONTROL_XPOS + 0 * GAME_BUTTON_XSIZE) +#define GAME_BUTTON_PAUSE_XPOS (GAME_CONTROL_XPOS + 1 * GAME_BUTTON_XSIZE) +#define GAME_BUTTON_PLAY_XPOS (GAME_CONTROL_XPOS + 2 * GAME_BUTTON_XSIZE) +#define GAME_BUTTON_ANY_YPOS (GAME_CONTROL_YPOS) + +#define ON_GAME_BUTTON(x,y) ((x)>=(DX+GAME_CONTROL_XPOS) && \ + (x)< (DX+GAME_CONTROL_XPOS + \ + GAME_CONTROL_XSIZE) && \ + (y)>=(DY+GAME_CONTROL_YPOS) && \ + (y)< (DY+GAME_CONTROL_YPOS + \ + GAME_CONTROL_YSIZE)) +#define GAME_BUTTON(x) (((x)-(DX+GAME_CONTROL_XPOS))/GAME_BUTTON_XSIZE) + +/* values for game control */ +#define BUTTON_GAME_STOP (1L<<0) +#define BUTTON_GAME_PAUSE (1L<<1) +#define BUTTON_GAME_PLAY (1L<<2) + + +/* some positions in the asking window */ +#define OK_BUTTON_XPOS 2 +#define OK_BUTTON_YPOS 250 +#define OK_BUTTON_GFX_YPOS 0 +#define OK_BUTTON_XSIZE 46 +#define OK_BUTTON_YSIZE 28 +#define NO_BUTTON_XPOS 52 +#define NO_BUTTON_YPOS OK_BUTTON_YPOS +#define NO_BUTTON_XSIZE OK_BUTTON_XSIZE +#define NO_BUTTON_YSIZE OK_BUTTON_YSIZE +#define CONFIRM_BUTTON_XPOS 2 +#define CONFIRM_BUTTON_GFX_YPOS 30 +#define CONFIRM_BUTTON_YPOS OK_BUTTON_YPOS +#define CONFIRM_BUTTON_XSIZE 96 +#define CONFIRM_BUTTON_YSIZE OK_BUTTON_YSIZE + +#define ON_CHOOSE_BUTTON(x,y) (((x)>=(DX+OK_BUTTON_XPOS) && \ + (x)< (DX+OK_BUTTON_XPOS + \ + OK_BUTTON_XSIZE) && \ + (y)>=(DY+OK_BUTTON_YPOS) && \ + (y)< (DY+OK_BUTTON_YPOS + \ + OK_BUTTON_YSIZE)) || \ + ((x)>=(DX+NO_BUTTON_XPOS) && \ + (x)< (DX+NO_BUTTON_XPOS + \ + NO_BUTTON_XSIZE) && \ + (y)>=(DY+NO_BUTTON_YPOS) && \ + (y)< (DY+NO_BUTTON_YPOS + \ + NO_BUTTON_YSIZE))) +#define ON_CONFIRM_BUTTON(x,y) (((x)>=(DX+CONFIRM_BUTTON_XPOS) && \ + (x)< (DX+CONFIRM_BUTTON_XPOS + \ + CONFIRM_BUTTON_XSIZE) && \ + (y)>=(DY+CONFIRM_BUTTON_YPOS) && \ + (y)< (DY+CONFIRM_BUTTON_YPOS + \ + CONFIRM_BUTTON_YSIZE))) +#define CHOOSE_BUTTON(x) (((x)-(DX+OK_BUTTON_XPOS))/OK_BUTTON_XSIZE) + +/* values for asking control */ +#define BUTTON_OK (1L<<0) +#define BUTTON_NO (1L<<1) +#define BUTTON_CONFIRM (1L<<2) + + +/* some positions in the editor control window */ +#define ED_BUTTON_EUP_XPOS 35 +#define ED_BUTTON_EUP_YPOS 5 +#define ED_BUTTON_EUP_XSIZE 30 +#define ED_BUTTON_EUP_YSIZE 25 +#define ED_BUTTON_EDOWN_XPOS 35 +#define ED_BUTTON_EDOWN_YPOS 250 +#define ED_BUTTON_EDOWN_XSIZE 30 +#define ED_BUTTON_EDOWN_YSIZE 25 +#define ED_BUTTON_ELEM_XPOS 6 +#define ED_BUTTON_ELEM_YPOS 30 +#define ED_BUTTON_ELEM_XSIZE 22 +#define ED_BUTTON_ELEM_YSIZE 22 + +#define ED_BUTTON_EUP_Y2POS 140 +#define ED_BUTTON_EDOWN_Y2POS 165 +#define ED_BUTTON_ELEM_Y2POS 190 + +#define ED_BUTTON_CTRL_XPOS 5 +#define ED_BUTTON_CTRL_YPOS 5 +#define ED_BUTTON_CTRL_XSIZE 90 +#define ED_BUTTON_CTRL_YSIZE 30 +#define ED_BUTTON_FILL_XPOS 5 +#define ED_BUTTON_FILL_YPOS 35 +#define ED_BUTTON_FILL_XSIZE 90 +#define ED_BUTTON_FILL_YSIZE 20 +#define ED_BUTTON_LEFT_XPOS 5 +#define ED_BUTTON_LEFT_YPOS 65 +#define ED_BUTTON_LEFT_XSIZE 30 +#define ED_BUTTON_LEFT_YSIZE 20 +#define ED_BUTTON_UP_XPOS 35 +#define ED_BUTTON_UP_YPOS 55 +#define ED_BUTTON_UP_XSIZE 30 +#define ED_BUTTON_UP_YSIZE 20 +#define ED_BUTTON_DOWN_XPOS 35 +#define ED_BUTTON_DOWN_YPOS 75 +#define ED_BUTTON_DOWN_XSIZE 30 +#define ED_BUTTON_DOWN_YSIZE 20 +#define ED_BUTTON_RIGHT_XPOS 65 +#define ED_BUTTON_RIGHT_YPOS 65 +#define ED_BUTTON_RIGHT_XSIZE 30 +#define ED_BUTTON_RIGHT_YSIZE 20 + +#define ED_BUTTON_EDIT_XPOS 5 +#define ED_BUTTON_EDIT_YPOS 5 +#define ED_BUTTON_EDIT_XSIZE 90 +#define ED_BUTTON_EDIT_YSIZE 30 +#define ED_BUTTON_CLEAR_XPOS 5 +#define ED_BUTTON_CLEAR_YPOS 35 +#define ED_BUTTON_CLEAR_XSIZE 90 +#define ED_BUTTON_CLEAR_YSIZE 20 +#define ED_BUTTON_UNDO_XPOS 5 +#define ED_BUTTON_UNDO_YPOS 55 +#define ED_BUTTON_UNDO_XSIZE 90 +#define ED_BUTTON_UNDO_YSIZE 20 +#define ED_BUTTON_EXIT_XPOS 5 +#define ED_BUTTON_EXIT_YPOS 75 +#define ED_BUTTON_EXIT_XSIZE 90 +#define ED_BUTTON_EXIT_YSIZE 20 + +#define ED_BUTTON_MINUS_XPOS 2 +#define ED_BUTTON_MINUS_YPOS 60 +#define ED_BUTTON_MINUS_XSIZE 20 +#define ED_BUTTON_MINUS_YSIZE 20 +#define ED_WIN_COUNT_XPOS (ED_BUTTON_MINUS_XPOS+ED_BUTTON_MINUS_XSIZE+2) +#define ED_WIN_COUNT_YPOS ED_BUTTON_MINUS_YPOS +#define ED_WIN_COUNT_XSIZE 52 +#define ED_WIN_COUNT_YSIZE ED_BUTTON_MINUS_YSIZE +#define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS+ED_WIN_COUNT_XSIZE+2) +#define ED_BUTTON_PLUS_YPOS ED_BUTTON_MINUS_YPOS +#define ED_BUTTON_PLUS_XSIZE ED_BUTTON_MINUS_XSIZE +#define ED_BUTTON_PLUS_YSIZE ED_BUTTON_MINUS_YSIZE + +#define ED_COUNT_GADGET_XPOS 16 +#define ED_COUNT_GADGET_YPOS (16+3*MINI_TILEY+64) +#define ED_COUNT_GADGET_YSIZE (ED_BUTTON_MINUS_YSIZE+4) +#define ED_COUNT_TEXT_XPOS (ED_COUNT_GADGET_XPOS+DXSIZE+10) +#define ED_COUNT_TEXT_YPOS (ED_COUNT_GADGET_YPOS+3) +#define ED_COUNT_TEXT_YSIZE ED_COUNT_GADGET_YSIZE +#define ED_COUNT_VALUE_XPOS (ED_COUNT_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7) +#define ED_COUNT_VALUE_YPOS ED_COUNT_TEXT_YPOS +#define ED_SIZE_GADGET_XPOS (SX+21*MINI_TILEX) +#define ED_SIZE_GADGET_YPOS (SY+4*MINI_TILEY) +#define ED_SIZE_GADGET_YSIZE (ED_BUTTON_MINUS_YSIZE+4) +#define ED_SIZE_TEXT_XPOS (ED_SIZE_GADGET_XPOS+DXSIZE+10) +#define ED_SIZE_TEXT_YPOS (ED_SIZE_GADGET_YPOS+3) +#define ED_SIZE_TEXT_YSIZE ED_COUNT_GADGET_YSIZE +#define ED_SIZE_VALUE_XPOS (ED_SIZE_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7) +#define ED_SIZE_VALUE_YPOS ED_SIZE_TEXT_YPOS + +#define ON_EDIT_BUTTON(x,y) (((x)>=(VX+ED_BUTTON_CTRL_XPOS) && \ + (x)< (VX+ED_BUTTON_CTRL_XPOS + \ + ED_BUTTON_CTRL_XSIZE) && \ + (y)>=(VY+ED_BUTTON_CTRL_YPOS) && \ + (y)< (VY+ED_BUTTON_CTRL_YPOS + \ + ED_BUTTON_CTRL_YSIZE + \ + ED_BUTTON_FILL_YSIZE)) || \ + ((x)>=(VX+ED_BUTTON_LEFT_XPOS) && \ + (x)< (VX+ED_BUTTON_LEFT_XPOS + \ + ED_BUTTON_LEFT_XSIZE + \ + ED_BUTTON_UP_XSIZE + \ + ED_BUTTON_RIGHT_XSIZE) && \ + (y)>=(VY+ED_BUTTON_LEFT_YPOS) && \ + (y)< (VY+ED_BUTTON_LEFT_YPOS + \ + ED_BUTTON_LEFT_YSIZE)) || \ + ((x)>=(VX+ED_BUTTON_UP_XPOS) && \ + (x)< (VX+ED_BUTTON_UP_XPOS + \ + ED_BUTTON_UP_XSIZE) && \ + (y)>=(VY+ED_BUTTON_UP_YPOS) && \ + (y)< (VY+ED_BUTTON_UP_YPOS + \ + ED_BUTTON_UP_YSIZE + \ + ED_BUTTON_DOWN_YSIZE))) + +#define ON_CTRL_BUTTON(x,y) ((x)>=(VX+ED_BUTTON_EDIT_XPOS) && \ + (x)< (VX+ED_BUTTON_EDIT_XPOS + \ + ED_BUTTON_EDIT_XSIZE) && \ + (y)>=(VY+ED_BUTTON_EDIT_YPOS) && \ + (y)< (VY+ED_BUTTON_EDIT_YPOS + \ + ED_BUTTON_EDIT_YSIZE + \ + ED_BUTTON_CLEAR_YSIZE + \ + ED_BUTTON_UNDO_YSIZE + \ + ED_BUTTON_EXIT_YSIZE)) + +#define ON_ELEM_BUTTON(x,y) (((x)>=(DX+ED_BUTTON_EUP_XPOS) && \ + (x)< (DX+ED_BUTTON_EUP_XPOS + \ + ED_BUTTON_EUP_XSIZE) && \ + (y)>=(DY+ED_BUTTON_EUP_YPOS) && \ + (y)< (DY+ED_BUTTON_EUP_YPOS + \ + ED_BUTTON_EUP_YSIZE)) || \ + ((x)>=(DX+ED_BUTTON_EDOWN_XPOS) && \ + (x)< (DX+ED_BUTTON_EDOWN_XPOS + \ + ED_BUTTON_EDOWN_XSIZE) && \ + (y)>=(DY+ED_BUTTON_EDOWN_YPOS) && \ + (y)< (DY+ED_BUTTON_EDOWN_YPOS + \ + ED_BUTTON_EDOWN_YSIZE)) || \ + ((x)>=(DX+ED_BUTTON_ELEM_XPOS) && \ + (x)< (DX+ED_BUTTON_ELEM_XPOS + \ + MAX_ELEM_X*ED_BUTTON_ELEM_XSIZE) && \ + (y)>=(DY+ED_BUTTON_ELEM_YPOS) && \ + (y)< (DY+ED_BUTTON_ELEM_YPOS + \ + MAX_ELEM_Y*ED_BUTTON_ELEM_YSIZE))) + +#define ON_COUNT_BUTTON(x,y) (((((x)>=ED_COUNT_GADGET_XPOS && \ + (x)<(ED_COUNT_GADGET_XPOS + \ + ED_BUTTON_MINUS_XSIZE)) || \ + ((x)>=(ED_COUNT_GADGET_XPOS + \ + (ED_BUTTON_PLUS_XPOS - \ + ED_BUTTON_MINUS_XPOS)) && \ + (x)<(ED_COUNT_GADGET_XPOS + \ + (ED_BUTTON_PLUS_XPOS - \ + ED_BUTTON_MINUS_XPOS) + \ + ED_BUTTON_PLUS_XSIZE))) && \ + ((y)>=ED_COUNT_GADGET_YPOS && \ + (y)<(ED_COUNT_GADGET_YPOS + \ + 16*ED_COUNT_GADGET_YSIZE)) && \ + (((y)-ED_COUNT_GADGET_YPOS) % \ + ED_COUNT_GADGET_YSIZE) < \ + ED_BUTTON_MINUS_YSIZE) || \ + ((((x)>=ED_SIZE_GADGET_XPOS && \ + (x)<(ED_SIZE_GADGET_XPOS + \ + ED_BUTTON_MINUS_XSIZE)) || \ + ((x)>=(ED_SIZE_GADGET_XPOS + \ + (ED_BUTTON_PLUS_XPOS - \ + ED_BUTTON_MINUS_XPOS)) && \ + (x)<(ED_SIZE_GADGET_XPOS + \ + (ED_BUTTON_PLUS_XPOS - \ + ED_BUTTON_MINUS_XPOS) + \ + ED_BUTTON_PLUS_XSIZE))) && \ + ((y)>=ED_SIZE_GADGET_YPOS && \ + (y)<(ED_SIZE_GADGET_YPOS + \ + 2*ED_SIZE_GADGET_YSIZE)) && \ + (((y)-ED_SIZE_GADGET_YPOS) % \ + ED_SIZE_GADGET_YSIZE) < \ + ED_BUTTON_MINUS_YSIZE)) + +#define EDIT_BUTTON(x,y) (((y) < (VY + ED_BUTTON_CTRL_YPOS + \ + ED_BUTTON_CTRL_YSIZE)) ? 0 : \ + ((y) < (VY + ED_BUTTON_CTRL_YPOS + \ + ED_BUTTON_CTRL_YSIZE + \ + ED_BUTTON_FILL_YSIZE)) ? 1 : \ + ((x) < (VX + ED_BUTTON_LEFT_XPOS + \ + ED_BUTTON_LEFT_XSIZE) ? 2 : \ + (x) > (VX + ED_BUTTON_LEFT_XPOS + \ + ED_BUTTON_LEFT_XSIZE + \ + ED_BUTTON_UP_XSIZE) ? 5 : \ + 3+(((y)-(VY + ED_BUTTON_CTRL_YPOS + \ + ED_BUTTON_CTRL_YSIZE + \ + ED_BUTTON_FILL_YSIZE)) / \ + ED_BUTTON_UP_YSIZE))) + +#define CTRL_BUTTON(x,y) (((y) < (VY + ED_BUTTON_EDIT_YPOS + \ + ED_BUTTON_EDIT_YSIZE)) ? 0 : \ + 1+(((y)-(VY + ED_BUTTON_EDIT_YPOS + \ + ED_BUTTON_EDIT_YSIZE)) / \ + ED_BUTTON_CLEAR_YSIZE)) + +#define ELEM_BUTTON(x,y) (((y) < (DY + ED_BUTTON_EUP_YPOS + \ + ED_BUTTON_EUP_YSIZE)) ? 0 : \ + ((y) > (DY + ED_BUTTON_EDOWN_YPOS)) ? 1 : \ + 2+(((y) - (DY + ED_BUTTON_ELEM_YPOS)) / \ + ED_BUTTON_ELEM_YSIZE)*MAX_ELEM_X + \ + ((x) - (DX + ED_BUTTON_ELEM_XPOS)) / \ + ED_BUTTON_ELEM_XSIZE) + +#define COUNT_BUTTON(x,y) ((x) < ED_SIZE_GADGET_XPOS ? \ + ((((y) - ED_COUNT_GADGET_YPOS) / \ + ED_COUNT_GADGET_YSIZE)*2 + \ + ((x) < (ED_COUNT_GADGET_XPOS + \ + ED_BUTTON_MINUS_XSIZE) ? 0 : 1)) : \ + 32+((((y) - ED_SIZE_GADGET_YPOS) / \ + ED_SIZE_GADGET_YSIZE)*2 + \ + ((x) < (ED_SIZE_GADGET_XPOS + \ + ED_BUTTON_MINUS_XSIZE) ? 0 : 1))) + +/* values for asking control */ +#define ED_BUTTON_CTRL (1L<<0) +#define ED_BUTTON_FILL (1L<<1) +#define ED_BUTTON_LEFT (1L<<2) +#define ED_BUTTON_UP (1L<<3) +#define ED_BUTTON_DOWN (1L<<4) +#define ED_BUTTON_RIGHT (1L<<5) +#define ED_BUTTON_EDIT (1L<<6) +#define ED_BUTTON_CLEAR (1L<<7) +#define ED_BUTTON_UNDO (1L<<8) +#define ED_BUTTON_EXIT (1L<<9) + +#define ED_BUTTON_PRESSED (1L<<10) +#define ED_BUTTON_RELEASED (1L<<11) + +#define ED_BUTTON_EUP 0 +#define ED_BUTTON_EDOWN 1 +#define ED_BUTTON_ELEM 2 + + +void DrawVideoDisplay(unsigned long, unsigned long); +void DrawCompleteVideoDisplay(void); +void DrawSoundDisplay(unsigned long); +void DrawGameButton(unsigned long); +void DrawChooseButton(unsigned long); +void DrawConfirmButton(unsigned long); +void DrawEditButton(unsigned long state); +void DrawCtrlButton(unsigned long state); +void DrawElemButton(int, int); +void DrawCountButton(int, int); +int CheckVideoButtons(int, int, int); +int CheckSoundButtons(int, int, int); +int CheckGameButtons(int, int, int); +int CheckChooseButtons(int, int, int); +int CheckConfirmButton(int, int, int); +int CheckEditButtons(int, int, int); +int CheckCtrlButtons(int, int, int); +int CheckElemButtons(int, int, int); +int CheckCountButtons(int, int, int); + +#endif diff --git a/src/editor.c b/src/editor.c index ee7fe4e5..454fb74e 100644 --- a/src/editor.c +++ b/src/editor.c @@ -10,24 +10,24 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * editor.c * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #include "editor.h" #include "screens.h" -#include "game.h" #include "tools.h" #include "misc.h" +#include "buttons.h" +#include "files.h" static int level_xpos,level_ypos; static BOOL edit_mode; static BOOL name_typing; -static int element_shift; static int new_element1 = EL_MAUERWERK; static int new_element2 = EL_LEERRAUM; static int new_element3 = EL_ERDREICH; -static int editor_element[] = + +int element_shift; +int editor_element[] = { EL_SPIELFIGUR, EL_LEERRAUM, @@ -70,20 +70,24 @@ static int editor_element[] = EL_UNSICHTBAR, EL_TROPFEN, - EL_AMOEBE1, - EL_AMOEBE2, - EL_AMOEBE3, + EL_AMOEBE_TOT, + EL_AMOEBE_NASS, + EL_AMOEBE_NORM, + + EL_AMOEBE_VOLL, +/* EL_LIFE, +*/ EL_LIFE_ASYNC, - EL_ERZ_1, - EL_ERZ_2, + EL_ERZ_EDEL, + EL_ERZ_DIAM, -/* + EL_ZEIT_VOLL, + EL_ZEIT_LEER, EL_BIRNE_AUS, EL_BIRNE_EIN, -*/ EL_SCHLUESSEL1, EL_SCHLUESSEL2, @@ -189,7 +193,7 @@ static int editor_element[] = EL_CHAR_UE, EL_CHAR_COPY }; -static int elements_in_list = sizeof(editor_element)/sizeof(int); +int elements_in_list = sizeof(editor_element)/sizeof(int); void DrawLevelEd() { @@ -275,20 +279,21 @@ void DrawControlWindow() ClearWindow(); + /* Inhalt der Mampfer */ DrawText(ED_COUNT_GADGET_XPOS+1,SY+6, "Contents of a smashed cruncher:",FS_SMALL,FC_YELLOW); for(i=0;i<4;i++) for(y=0;y<4;y++) for(x=0;x<4;x++) { DrawMiniElement(1+5*i+x,2+y,EL_ERDREICH); XFillRectangle(display,drawto,gc, - SX+(2+5*i)*MINI_TILEX-MINI_TILEX/2-1, - SY+(3)*MINI_TILEY-MINI_TILEY/2-1, + SX+(1+5*i)*MINI_TILEX+MINI_TILEX/2-1, + SY+(2)*MINI_TILEY+MINI_TILEY/2-1, 3*MINI_TILEX+2,3*MINI_TILEY+2); } XCopyArea(display,drawto,drawto,gc, - SX+MINI_TILEX,SY+2*MINI_TILEY, + SX+1*MINI_TILEX,SY+2*MINI_TILEY, 4*5*MINI_TILEX,5*MINI_TILEY, - SX+MINI_TILEX-MINI_TILEX/2,SY+2*MINI_TILEY-MINI_TILEY/2); + SX+1*MINI_TILEX-MINI_TILEX/2,SY+2*MINI_TILEY-MINI_TILEY/2); for(i=0;i<4;i++) { for(y=0;y<3;y++) for(x=0;x<3;x++) @@ -299,6 +304,21 @@ void DrawControlWindow() int2str(i+1,1),FS_SMALL,FC_YELLOW); } + /* Inhalt der Amöbe */ + for(y=0;y<2;y++) for(x=0;x<2;x++) + { + DrawMiniElement(29+x,26+y,EL_ERDREICH); + XFillRectangle(display,drawto,gc, + SX+29*MINI_TILEX+MINI_TILEX/2-1, + SY+26*MINI_TILEY+MINI_TILEY/2-1, + MINI_TILEX+2,MINI_TILEY+2); + } + XCopyArea(display,drawto,drawto,gc, + SX+29*MINI_TILEX,SY+26*MINI_TILEY, + 3*MINI_TILEX,3*MINI_TILEY, + SX+29*MINI_TILEX-MINI_TILEX/2,SY+26*MINI_TILEY-MINI_TILEY/2); + DrawMiniElement(29,26,level.amoebe_inhalt); + for(i=0;i<11+3+2;i++) { XCopyArea(display,pix[PIX_DOOR],drawto,gc, @@ -357,7 +377,7 @@ void DrawControlWindow() DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+10*ED_COUNT_TEXT_YSIZE, "Score for each 10 seconds left",FS_SMALL,FC_YELLOW); DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+11*ED_COUNT_TEXT_YSIZE, - "Speed of the amoeba",FS_SMALL,FC_YELLOW); + "Speed of the amoeba / Content",FS_SMALL,FC_YELLOW); DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+12*ED_COUNT_TEXT_YSIZE, "Time for magic wall",FS_SMALL,FC_YELLOW); DrawText(ED_COUNT_TEXT_XPOS,ED_COUNT_TEXT_YPOS+13*ED_COUNT_TEXT_YSIZE, @@ -952,6 +972,25 @@ void LevelEd(int mx, int my, int button) } } + if (mx>=SX+29*MINI_TILEX && mx=SY+26*MINI_TILEY && my3) + return; + + new_element = (button==1 ? new_element1 : + button==2 ? new_element2 : + button==3 ? new_element3 : 0); + + if (new_element != level.amoebe_inhalt) + { + level.amoebe_inhalt = new_element; + DrawMiniElement(29,26,new_element); + } + } + if (mx>=SX+1*MINI_TILEX && mx=SY+2*MINI_TILEY && my=0 && pressed) - { - pressed = FALSE; - DrawEditButton(edit_button[choice] | ED_BUTTON_RELEASED); - } - else if (ON_EDIT_BUTTON(mx,my) && EDIT_BUTTON(mx,my)==choice) - { - if (!pressed) - DrawEditButton(edit_button[choice] | ED_BUTTON_PRESSED); - pressed = TRUE; - if (edit_button[choice]!=ED_BUTTON_CTRL && - edit_button[choice]!=ED_BUTTON_FILL) - return_code = 1<=0 && pressed) - { - pressed = FALSE; - DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED); - } - else if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && !pressed) - { - pressed = TRUE; - DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_PRESSED); - } - } - } - else /* Maustaste wieder losgelassen */ - { - if (ON_CTRL_BUTTON(mx,my) && CTRL_BUTTON(mx,my)==choice && pressed) - { - DrawCtrlButton(ctrl_button[choice] | ED_BUTTON_RELEASED); - return_code = 1<<(choice+6); - choice = -1; - pressed = FALSE; - } - else - { - choice = -1; - pressed = FALSE; - } - } - - BackToFront(); - return(return_code); -} - -int CheckElemButtons(int mx, int my, int button) -{ - int return_code = -1; - static int choice = -1; - static BOOL pressed = FALSE; - - if (button) - { - if (!motion_status) /* Maustaste neu gedrückt */ - { - if (ON_ELEM_BUTTON(mx,my)) - { - choice = ELEM_BUTTON(mx,my); - pressed = TRUE; - DrawElemButton(choice,ED_BUTTON_PRESSED); - if (choice==ED_BUTTON_EUP || - choice==ED_BUTTON_EDOWN) - return_code = choice; - } - } - else /* Mausbewegung bei gedrückter Maustaste */ - { - if ((!ON_ELEM_BUTTON(mx,my) || ELEM_BUTTON(mx,my)!=choice) && - choice>=0 && pressed) - { - pressed = FALSE; - DrawElemButton(choice,ED_BUTTON_RELEASED); - } - else if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice) - { - if (!pressed) - DrawElemButton(choice,ED_BUTTON_PRESSED); - pressed = TRUE; - if (choice==ED_BUTTON_EUP || - choice==ED_BUTTON_EDOWN) - return_code = choice; - } - } - } - else /* Maustaste wieder losgelassen */ - { - if (ON_ELEM_BUTTON(mx,my) && ELEM_BUTTON(mx,my)==choice && pressed) - { - DrawElemButton(choice,ED_BUTTON_RELEASED); - if (choice!=ED_BUTTON_EUP && - choice!=ED_BUTTON_EDOWN) - return_code = choice; - choice = -1; - pressed = FALSE; - } - else - { - choice = -1; - pressed = FALSE; - } - } - - BackToFront(); - return(return_code); -} - -int CheckCountButtons(int mx, int my, int button) -{ - int return_code = -1; - static int choice = -1; - static BOOL pressed = FALSE; - - if (button) - { - if (!motion_status) /* Maustaste neu gedrückt */ - { - if (ON_COUNT_BUTTON(mx,my)) - { - choice = COUNT_BUTTON(mx,my); - pressed = TRUE; - DrawCountButton(choice,ED_BUTTON_PRESSED); - return_code = choice; - } - } - else /* Mausbewegung bei gedrückter Maustaste */ - { - if ((!ON_COUNT_BUTTON(mx,my) || COUNT_BUTTON(mx,my)!=choice) && - choice>=0 && pressed) - { - pressed = FALSE; - DrawCountButton(choice,ED_BUTTON_RELEASED); - } - else if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice) - { - if (!pressed) - DrawCountButton(choice,ED_BUTTON_PRESSED); - pressed = TRUE; - return_code = choice; - } - } - } - else /* Maustaste wieder losgelassen */ - { - if (ON_COUNT_BUTTON(mx,my) && COUNT_BUTTON(mx,my)==choice && pressed) - { - DrawCountButton(choice,ED_BUTTON_RELEASED); - choice = -1; - pressed = FALSE; - } - else - { - choice = -1; - pressed = FALSE; - } - } - - BackToFront(); - return(return_code); -} diff --git a/src/editor.h b/src/editor.h index d01f8136..b4ebfed2 100644 --- a/src/editor.h +++ b/src/editor.h @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * editor.h * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #ifndef EDITOR_H @@ -19,8 +17,7 @@ #include "main.h" -/* sizes in the level editor */ -/* edit window */ +/* positions in the level editor */ #define ED_WIN_MB_LEFT_XPOS 7 #define ED_WIN_MB_LEFT_YPOS 6 #define ED_WIN_LEVELNR_XPOS 77 @@ -30,265 +27,9 @@ #define ED_WIN_MB_RIGHT_XPOS 77 #define ED_WIN_MB_RIGHT_YPOS 258 -#define ED_BUTTON_EUP_XPOS 35 -#define ED_BUTTON_EUP_YPOS 5 -#define ED_BUTTON_EUP_XSIZE 30 -#define ED_BUTTON_EUP_YSIZE 25 -#define ED_BUTTON_EDOWN_XPOS 35 -#define ED_BUTTON_EDOWN_YPOS 250 -#define ED_BUTTON_EDOWN_XSIZE 30 -#define ED_BUTTON_EDOWN_YSIZE 25 -#define ED_BUTTON_ELEM_XPOS 6 -#define ED_BUTTON_ELEM_YPOS 30 -#define ED_BUTTON_ELEM_XSIZE 22 -#define ED_BUTTON_ELEM_YSIZE 22 - #define MAX_ELEM_X 4 #define MAX_ELEM_Y 10 -#define ED_BUTTON_EUP_Y2POS 140 -#define ED_BUTTON_EDOWN_Y2POS 165 -#define ED_BUTTON_ELEM_Y2POS 190 - -#define ED_BUTTON_CTRL_XPOS 5 -#define ED_BUTTON_CTRL_YPOS 5 -#define ED_BUTTON_CTRL_XSIZE 90 -#define ED_BUTTON_CTRL_YSIZE 30 -#define ED_BUTTON_FILL_XPOS 5 -#define ED_BUTTON_FILL_YPOS 35 -#define ED_BUTTON_FILL_XSIZE 90 -#define ED_BUTTON_FILL_YSIZE 20 -#define ED_BUTTON_LEFT_XPOS 5 -#define ED_BUTTON_LEFT_YPOS 65 -#define ED_BUTTON_LEFT_XSIZE 30 -#define ED_BUTTON_LEFT_YSIZE 20 -#define ED_BUTTON_UP_XPOS 35 -#define ED_BUTTON_UP_YPOS 55 -#define ED_BUTTON_UP_XSIZE 30 -#define ED_BUTTON_UP_YSIZE 20 -#define ED_BUTTON_DOWN_XPOS 35 -#define ED_BUTTON_DOWN_YPOS 75 -#define ED_BUTTON_DOWN_XSIZE 30 -#define ED_BUTTON_DOWN_YSIZE 20 -#define ED_BUTTON_RIGHT_XPOS 65 -#define ED_BUTTON_RIGHT_YPOS 65 -#define ED_BUTTON_RIGHT_XSIZE 30 -#define ED_BUTTON_RIGHT_YSIZE 20 - -#define ED_BUTTON_EDIT_XPOS 5 -#define ED_BUTTON_EDIT_YPOS 5 -#define ED_BUTTON_EDIT_XSIZE 90 -#define ED_BUTTON_EDIT_YSIZE 30 -#define ED_BUTTON_CLEAR_XPOS 5 -#define ED_BUTTON_CLEAR_YPOS 35 -#define ED_BUTTON_CLEAR_XSIZE 90 -#define ED_BUTTON_CLEAR_YSIZE 20 -#define ED_BUTTON_UNDO_XPOS 5 -#define ED_BUTTON_UNDO_YPOS 55 -#define ED_BUTTON_UNDO_XSIZE 90 -#define ED_BUTTON_UNDO_YSIZE 20 -#define ED_BUTTON_EXIT_XPOS 5 -#define ED_BUTTON_EXIT_YPOS 75 -#define ED_BUTTON_EXIT_XSIZE 90 -#define ED_BUTTON_EXIT_YSIZE 20 - -#define ED_BUTTON_MINUS_XPOS 2 -#define ED_BUTTON_MINUS_YPOS 60 -#define ED_BUTTON_MINUS_XSIZE 20 -#define ED_BUTTON_MINUS_YSIZE 20 -#define ED_WIN_COUNT_XPOS (ED_BUTTON_MINUS_XPOS+ED_BUTTON_MINUS_XSIZE+2) -#define ED_WIN_COUNT_YPOS ED_BUTTON_MINUS_YPOS -#define ED_WIN_COUNT_XSIZE 52 -#define ED_WIN_COUNT_YSIZE ED_BUTTON_MINUS_YSIZE -#define ED_BUTTON_PLUS_XPOS (ED_WIN_COUNT_XPOS+ED_WIN_COUNT_XSIZE+2) -#define ED_BUTTON_PLUS_YPOS ED_BUTTON_MINUS_YPOS -#define ED_BUTTON_PLUS_XSIZE ED_BUTTON_MINUS_XSIZE -#define ED_BUTTON_PLUS_YSIZE ED_BUTTON_MINUS_YSIZE - -#define ED_COUNT_GADGET_XPOS 16 -#define ED_COUNT_GADGET_YPOS (16+3*MINI_TILEY+64) -#define ED_COUNT_GADGET_YSIZE (ED_BUTTON_MINUS_YSIZE+4) -#define ED_COUNT_TEXT_XPOS (ED_COUNT_GADGET_XPOS+DXSIZE+10) -#define ED_COUNT_TEXT_YPOS (ED_COUNT_GADGET_YPOS+3) -#define ED_COUNT_TEXT_YSIZE ED_COUNT_GADGET_YSIZE -#define ED_COUNT_VALUE_XPOS (ED_COUNT_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7) -#define ED_COUNT_VALUE_YPOS ED_COUNT_TEXT_YPOS -#define ED_SIZE_GADGET_XPOS (SX+21*MINI_TILEX) -#define ED_SIZE_GADGET_YPOS (SY+4*MINI_TILEY) -#define ED_SIZE_GADGET_YSIZE (ED_BUTTON_MINUS_YSIZE+4) -#define ED_SIZE_TEXT_XPOS (ED_SIZE_GADGET_XPOS+DXSIZE+10) -#define ED_SIZE_TEXT_YPOS (ED_SIZE_GADGET_YPOS+3) -#define ED_SIZE_TEXT_YSIZE ED_COUNT_GADGET_YSIZE -#define ED_SIZE_VALUE_XPOS (ED_SIZE_GADGET_XPOS+ED_BUTTON_MINUS_XSIZE+7) -#define ED_SIZE_VALUE_YPOS ED_SIZE_TEXT_YPOS - -#define ON_EDIT_BUTTON(x,y) (((x)>=(VX+ED_BUTTON_CTRL_XPOS) && \ - (x)< (VX+ED_BUTTON_CTRL_XPOS + \ - ED_BUTTON_CTRL_XSIZE) && \ - (y)>=(VY+ED_BUTTON_CTRL_YPOS) && \ - (y)< (VY+ED_BUTTON_CTRL_YPOS + \ - ED_BUTTON_CTRL_YSIZE + \ - ED_BUTTON_FILL_YSIZE)) || \ - ((x)>=(VX+ED_BUTTON_LEFT_XPOS) && \ - (x)< (VX+ED_BUTTON_LEFT_XPOS + \ - ED_BUTTON_LEFT_XSIZE + \ - ED_BUTTON_UP_XSIZE + \ - ED_BUTTON_RIGHT_XSIZE) && \ - (y)>=(VY+ED_BUTTON_LEFT_YPOS) && \ - (y)< (VY+ED_BUTTON_LEFT_YPOS + \ - ED_BUTTON_LEFT_YSIZE)) || \ - ((x)>=(VX+ED_BUTTON_UP_XPOS) && \ - (x)< (VX+ED_BUTTON_UP_XPOS + \ - ED_BUTTON_UP_XSIZE) && \ - (y)>=(VY+ED_BUTTON_UP_YPOS) && \ - (y)< (VY+ED_BUTTON_UP_YPOS + \ - ED_BUTTON_UP_YSIZE + \ - ED_BUTTON_DOWN_YSIZE))) - -#define ON_CTRL_BUTTON(x,y) ((x)>=(VX+ED_BUTTON_EDIT_XPOS) && \ - (x)< (VX+ED_BUTTON_EDIT_XPOS + \ - ED_BUTTON_EDIT_XSIZE) && \ - (y)>=(VY+ED_BUTTON_EDIT_YPOS) && \ - (y)< (VY+ED_BUTTON_EDIT_YPOS + \ - ED_BUTTON_EDIT_YSIZE + \ - ED_BUTTON_CLEAR_YSIZE + \ - ED_BUTTON_UNDO_YSIZE + \ - ED_BUTTON_EXIT_YSIZE)) - -#define ON_ELEM_BUTTON(x,y) (((x)>=(DX+ED_BUTTON_EUP_XPOS) && \ - (x)< (DX+ED_BUTTON_EUP_XPOS + \ - ED_BUTTON_EUP_XSIZE) && \ - (y)>=(DY+ED_BUTTON_EUP_YPOS) && \ - (y)< (DY+ED_BUTTON_EUP_YPOS + \ - ED_BUTTON_EUP_YSIZE)) || \ - ((x)>=(DX+ED_BUTTON_EDOWN_XPOS) && \ - (x)< (DX+ED_BUTTON_EDOWN_XPOS + \ - ED_BUTTON_EDOWN_XSIZE) && \ - (y)>=(DY+ED_BUTTON_EDOWN_YPOS) && \ - (y)< (DY+ED_BUTTON_EDOWN_YPOS + \ - ED_BUTTON_EDOWN_YSIZE)) || \ - ((x)>=(DX+ED_BUTTON_ELEM_XPOS) && \ - (x)< (DX+ED_BUTTON_ELEM_XPOS + \ - MAX_ELEM_X*ED_BUTTON_ELEM_XSIZE) && \ - (y)>=(DY+ED_BUTTON_ELEM_YPOS) && \ - (y)< (DY+ED_BUTTON_ELEM_YPOS + \ - MAX_ELEM_Y*ED_BUTTON_ELEM_YSIZE))) - -#define ON_COUNT_BUTTON(x,y) (((((x)>=ED_COUNT_GADGET_XPOS && \ - (x)<(ED_COUNT_GADGET_XPOS + \ - ED_BUTTON_MINUS_XSIZE)) || \ - ((x)>=(ED_COUNT_GADGET_XPOS + \ - (ED_BUTTON_PLUS_XPOS - \ - ED_BUTTON_MINUS_XPOS)) && \ - (x)<(ED_COUNT_GADGET_XPOS + \ - (ED_BUTTON_PLUS_XPOS - \ - ED_BUTTON_MINUS_XPOS) + \ - ED_BUTTON_PLUS_XSIZE))) && \ - ((y)>=ED_COUNT_GADGET_YPOS && \ - (y)<(ED_COUNT_GADGET_YPOS + \ - 16*ED_COUNT_GADGET_YSIZE)) && \ - (((y)-ED_COUNT_GADGET_YPOS) % \ - ED_COUNT_GADGET_YSIZE) < \ - ED_BUTTON_MINUS_YSIZE) || \ - ((((x)>=ED_SIZE_GADGET_XPOS && \ - (x)<(ED_SIZE_GADGET_XPOS + \ - ED_BUTTON_MINUS_XSIZE)) || \ - ((x)>=(ED_SIZE_GADGET_XPOS + \ - (ED_BUTTON_PLUS_XPOS - \ - ED_BUTTON_MINUS_XPOS)) && \ - (x)<(ED_SIZE_GADGET_XPOS + \ - (ED_BUTTON_PLUS_XPOS - \ - ED_BUTTON_MINUS_XPOS) + \ - ED_BUTTON_PLUS_XSIZE))) && \ - ((y)>=ED_SIZE_GADGET_YPOS && \ - (y)<(ED_SIZE_GADGET_YPOS + \ - 2*ED_SIZE_GADGET_YSIZE)) && \ - (((y)-ED_SIZE_GADGET_YPOS) % \ - ED_SIZE_GADGET_YSIZE) < \ - ED_BUTTON_MINUS_YSIZE)) - -#define EDIT_BUTTON(x,y) (((y) < (VY + ED_BUTTON_CTRL_YPOS + \ - ED_BUTTON_CTRL_YSIZE)) ? 0 : \ - ((y) < (VY + ED_BUTTON_CTRL_YPOS + \ - ED_BUTTON_CTRL_YSIZE + \ - ED_BUTTON_FILL_YSIZE)) ? 1 : \ - ((x) < (VX + ED_BUTTON_LEFT_XPOS + \ - ED_BUTTON_LEFT_XSIZE) ? 2 : \ - (x) > (VX + ED_BUTTON_LEFT_XPOS + \ - ED_BUTTON_LEFT_XSIZE + \ - ED_BUTTON_UP_XSIZE) ? 5 : \ - 3+(((y)-(VY + ED_BUTTON_CTRL_YPOS + \ - ED_BUTTON_CTRL_YSIZE + \ - ED_BUTTON_FILL_YSIZE)) / \ - ED_BUTTON_UP_YSIZE))) - -#define CTRL_BUTTON(x,y) (((y) < (VY + ED_BUTTON_EDIT_YPOS + \ - ED_BUTTON_EDIT_YSIZE)) ? 0 : \ - 1+(((y)-(VY + ED_BUTTON_EDIT_YPOS + \ - ED_BUTTON_EDIT_YSIZE)) / \ - ED_BUTTON_CLEAR_YSIZE)) - -#define ELEM_BUTTON(x,y) (((y) < (DY + ED_BUTTON_EUP_YPOS + \ - ED_BUTTON_EUP_YSIZE)) ? 0 : \ - ((y) > (DY + ED_BUTTON_EDOWN_YPOS)) ? 1 : \ - 2+(((y) - (DY + ED_BUTTON_ELEM_YPOS)) / \ - ED_BUTTON_ELEM_YSIZE)*MAX_ELEM_X + \ - ((x) - (DX + ED_BUTTON_ELEM_XPOS)) / \ - ED_BUTTON_ELEM_XSIZE) - -#define COUNT_BUTTON(x,y) ((x) < ED_SIZE_GADGET_XPOS ? \ - ((((y) - ED_COUNT_GADGET_YPOS) / \ - ED_COUNT_GADGET_YSIZE)*2 + \ - ((x) < (ED_COUNT_GADGET_XPOS + \ - ED_BUTTON_MINUS_XSIZE) ? 0 : 1)) : \ - 32+((((y) - ED_SIZE_GADGET_YPOS) / \ - ED_SIZE_GADGET_YSIZE)*2 + \ - ((x) < (ED_SIZE_GADGET_XPOS + \ - ED_BUTTON_MINUS_XSIZE) ? 0 : 1))) - -/* values for asking control */ -#define ED_BUTTON_CTRL (1L<<0) -#define ED_BUTTON_FILL (1L<<1) -#define ED_BUTTON_LEFT (1L<<2) -#define ED_BUTTON_UP (1L<<3) -#define ED_BUTTON_DOWN (1L<<4) -#define ED_BUTTON_RIGHT (1L<<5) -#define ED_BUTTON_EDIT (1L<<6) -#define ED_BUTTON_CLEAR (1L<<7) -#define ED_BUTTON_UNDO (1L<<8) -#define ED_BUTTON_EXIT (1L<<9) - -#define ED_BUTTON_PRESSED (1L<<10) -#define ED_BUTTON_RELEASED (1L<<11) - -#define ED_BUTTON_EUP 0 -#define ED_BUTTON_EDOWN 1 -#define ED_BUTTON_ELEM 2 - -#if 0 - -/* OBSOLETE *********************** */ - -/* sizes in the level editor */ -#define ED_PFEIL_XSIZE 46 -#define ED_PFEIL_YSIZE 19 -#define ED_ZEIT_XSIZE 20 -#define ED_ZEIT_YSIZE 20 -#define ED_CLEX_XSIZE 46 -#define ED_CLEX_YSIZE 18 -#define ED_BUT_CLEX_Y (DYSIZE-2-ED_CLEX_YSIZE) -#define ED_BUT_ZEIT_Y (ED_BUT_CLEX_Y-2-ED_ZEIT_YSIZE) -#define ED_BUT_PFEIL_Y (ED_BUT_ZEIT_Y-2-ED_PFEIL_YSIZE) -#define ED_BUT_ZEIT2_X (ED_ZEIT_XSIZE+10) -#define ED_BUT_ZEIT2_Y (ED_BUT_ZEIT_Y+4) -#define ED_BUT_X 2 -#define ED_BUT_Y ED_BUT_PFEIL_Y - -/* OBSOLETE *********************** */ - -#endif - - /* other constants for the editor */ #define ED_SCROLL_NO 0 #define ED_SCROLL_LEFT 1 @@ -296,17 +37,13 @@ #define ED_SCROLL_UP 4 #define ED_SCROLL_DOWN 8 +extern int element_shift; +extern int editor_element[]; +extern int elements_in_list; + void DrawLevelEd(void); void ScrollMiniLevel(int, int, int); void LevelEd(int, int, int); void LevelNameTyping(KeySym); -void DrawEditButton(unsigned long state); -void DrawCtrlButton(unsigned long state); -void DrawElemButton(int, int); -void DrawCountButton(int, int); -int CheckEditButtons(int, int, int); -int CheckCtrlButtons(int, int, int); -int CheckElemButtons(int, int, int); -int CheckCountButtons(int, int, int); #endif diff --git a/src/events.c b/src/events.c index 1e8fcd1c..9eb8d623 100644 --- a/src/events.c +++ b/src/events.c @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * events.c * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #include "events.h" @@ -19,6 +17,7 @@ #include "tools.h" #include "game.h" #include "editor.h" +#include "misc.h" void EventLoop(void) { @@ -67,6 +66,8 @@ void EventLoop(void) { HandleNoXEvent(); + XSync(display,FALSE); + if (game_status!=PLAYING) Delay(10000); /* don't use all CPU time when idle */ } @@ -658,7 +659,7 @@ void HandleJoystick() break; } - if ((GameOver || LevelSolved) && newbutton) + if (GameOver && newbutton) { CloseDoor(DOOR_CLOSE_1); game_status = MAINMENU; diff --git a/src/events.h b/src/events.h index 539db844..1916ea32 100644 --- a/src/events.h +++ b/src/events.h @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * events.h * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #ifndef EVENTS_H diff --git a/src/files.c b/src/files.c new file mode 100644 index 00000000..e349c062 --- /dev/null +++ b/src/files.c @@ -0,0 +1,703 @@ +/*********************************************************** +* Rocks'n'Diamonds -- McDuffin Strikes Back! * +*----------------------------------------------------------* +* ©1995 Artsoft Development * +* Holger Schemel * +* 33659 Bielefeld-Senne * +* Telefon: (0521) 493245 * +* eMail: aeglos@valinor.owl.de * +* aeglos@uni-paderborn.de * +* q99492@pbhrzx.uni-paderborn.de * +*----------------------------------------------------------* +* files.h * +***********************************************************/ + +#include "files.h" +#include "tools.h" +#include "misc.h" + +BOOL CreateNewScoreFile() +{ + int i,j,k; + char filename[MAX_FILENAME]; + char empty_alias[MAX_NAMELEN]; + FILE *file; + + sprintf(filename,"%s/%s/%s", + SCORE_PATH,leveldir[leveldir_nr].filename,SCORE_FILENAME); + + if (!(file=fopen(filename,"w"))) + return(FALSE); + + for(i=0;i=MAX_TAPELEN) + break; + tape.pos[i].joystickdata = fgetc(file); + tape.pos[i].delay = fgetc(file); + if (feof(file)) + break; + } + + if (i != tape.length) + fprintf(stderr,"%s: level recording file '%s' corrupted!\n", + progname,filename); + + fclose(file); + + master_tape = tape; +} + +void LoadScore(int level_nr) +{ + int i,j; + char filename[MAX_FILENAME]; + char cookie[MAX_FILENAME]; + FILE *file; + + sprintf(filename,"%s/%s/%s", + SCORE_PATH,leveldir[leveldir_nr].filename,SCORE_FILENAME); + + if (!(file=fopen(filename,"r"))) + { + if (!CreateNewScoreFile()) + { + fprintf(stderr,"%s: cannot create score file '%s'!\n", + progname,filename); + } + else if (!(file=fopen(filename,"r"))) + { + fprintf(stderr,"%s: cannot load score for level %d!\n", + progname,level_nr); + } + } + + if (file) + { + fgets(cookie,SCORE_COOKIE_LEN,file); + if (strcmp(cookie,SCORE_COOKIE)) /* ungültiges Format? */ + { + fprintf(stderr,"%s: wrong format of score file!\n",progname); + fclose(file); + file = NULL; + } + } + + if (file) + { + fseek(file, + SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)), + SEEK_SET); + for(i=0;i> 24) & 0xff,file); + fputc((tape.random_seed >> 16) & 0xff,file); + fputc((tape.random_seed >> 8) & 0xff,file); + fputc((tape.random_seed >> 0) & 0xff,file); + + fputc((tape.date >> 24) & 0xff,file); + fputc((tape.date >> 16) & 0xff,file); + fputc((tape.date >> 8) & 0xff,file); + fputc((tape.date >> 0) & 0xff,file); + + fputc((tape.length >> 24) & 0xff,file); + fputc((tape.length >> 16) & 0xff,file); + fputc((tape.length >> 8) & 0xff,file); + fputc((tape.length >> 0) & 0xff,file); + + for(i=0;i=MAX_TAPELEN) - break; - tape.pos[i].joystickdata = fgetc(file); - tape.pos[i].delay = fgetc(file); - if (feof(file)) - break; - } - - if (i != tape.length) - fprintf(stderr,"%s: level recording file '%s' corrupted!\n", - progname,filename); - - fclose(file); - - master_tape = tape; -} - -void LoadScore(int level_nr) -{ - int i,j; - char filename[MAX_FILENAME]; - char cookie[MAX_FILENAME]; - FILE *file; - - sprintf(filename,"%s/%s/%s", - SCORE_PATH,leveldir[leveldir_nr].filename,SCORE_FILENAME); - - if (!(file=fopen(filename,"r"))) - { - if (!CreateNewScoreFile()) - { - fprintf(stderr,"%s: cannot create score file '%s'!\n", - progname,filename); - } - else if (!(file=fopen(filename,"r"))) - { - fprintf(stderr,"%s: cannot load score for level %d!\n", - progname,level_nr); - } - } - - if (file) - { - fgets(cookie,SCORE_COOKIE_LEN,file); - if (strcmp(cookie,SCORE_COOKIE)) /* ungültiges Format? */ - { - fprintf(stderr,"%s: wrong format of score file!\n",progname); - fclose(file); - file = NULL; - } - } - - if (file) - { - fseek(file, - SCORE_COOKIE_LEN-1+level_nr*(MAX_SCORE_ENTRIES*(MAX_NAMELEN+2)), - SEEK_SET); - for(i=0;i> 24) & 0xff,file); - fputc((tape.random_seed >> 16) & 0xff,file); - fputc((tape.random_seed >> 8) & 0xff,file); - fputc((tape.random_seed >> 0) & 0xff,file); - - fputc((tape.date >> 24) & 0xff,file); - fputc((tape.date >> 16) & 0xff,file); - fputc((tape.date >> 8) & 0xff,file); - fputc((tape.date >> 0) & 0xff,file); - - fputc((tape.length >> 24) & 0xff,file); - fputc((tape.length >> 16) & 0xff,file); - fputc((tape.length >> 8) & 0xff,file); - fputc((tape.length >> 0) & 0xff,file); - - for(i=0;i=0) SaveScore(level_nr); @@ -1123,6 +545,9 @@ void Explode(int ex, int ey, int phase) if (!IN_LEV_FIELD(x,y) || IS_MASSIV(element)) continue; + if (center_element==EL_AMOEBA2DIAM && (x!=ex || y!=ey)) + continue; + if (element==EL_EXPLODING) element = Store2[x][y]; @@ -1130,19 +555,25 @@ void Explode(int ex, int ey, int phase) Store[x][y] = ((x==ex && y==ey) ? EL_DIAMANT : EL_EDELSTEIN); else if (center_element==EL_MAMPFER) Store[x][y] = level.mampfer_inhalt[MampferNr][x-ex+1][y-ey+1]; - else if (Feld[x][y]==EL_ERZ_1) + else if (center_element==EL_AMOEBA2DIAM) + Store[x][y] = level.amoebe_inhalt; + else if (element==EL_ERZ_EDEL) Store[x][y] = EL_EDELSTEIN; - else if (Feld[x][y]==EL_ERZ_2) + else if (element==EL_ERZ_DIAM) Store[x][y] = EL_DIAMANT; else if (!IS_PFORTE(Store[x][y])) Store[x][y] = EL_LEERRAUM; - if (x!=ex || y!=ey) + if (x!=ex || y!=ey || center_element==EL_AMOEBA2DIAM) Store2[x][y] = element; + if (AmoebaNr[x][y] && (element==EL_AMOEBE_VOLL || element==EL_AMOEBING)) + AmoebaCnt[AmoebaNr[x][y]]--; + RemoveMovingField(x,y); Feld[x][y] = EL_EXPLODING; MovDir[x][y] = MovPos[x][y] = 0; + AmoebaNr[x][y] = 0; Frame[x][y] = 1; Stop[x][y] = TRUE; } @@ -1176,6 +607,8 @@ void Explode(int ex, int ey, int phase) Store2[x][y] = 0; Bang(x,y); } + else if (element==EL_AMOEBA2DIAM) + AmoebeUmwandeln(x,y); } if (phase==last_phase) @@ -1307,7 +740,10 @@ void Impact(int x, int y) if (object_hit && PLAYER(x,y+1)) KillHero(); else - Feld[x][y] = EL_AMOEBING2; + { + Feld[x][y] = EL_AMOEBING; + Store[x][y] = EL_AMOEBE_NASS; + } return; } @@ -1380,6 +816,10 @@ void Impact(int x, int y) case EL_SCHLUESSEL4: sound = SND_KINK; break; + case EL_ZEIT_VOLL: + case EL_ZEIT_LEER: + sound = SND_DENG; + break; default: sound = -1; break; @@ -1623,9 +1063,10 @@ void StartMoving(int x, int y) } else if (element==EL_TROPFEN) { - Feld[x][y] = EL_AMOEBING2; + Feld[x][y] = EL_AMOEBING; + Store[x][y] = EL_AMOEBE_NASS; } - else if (SLIPPERY(Feld[x][y+1]) && !Store[x][y+1]) + else if (IS_SLIPPERY(Feld[x][y+1]) && !Store[x][y+1]) { int left = (x>0 && IS_FREE(x-1,y) && (IS_FREE(x-1,y+1) || Feld[x-1][y+1]==EL_SALZSAEURE)); @@ -1701,12 +1142,20 @@ void StartMoving(int x, int y) else if (element==EL_MAMPFER && IN_LEV_FIELD(newx,newy) && Feld[newx][newy]==EL_DIAMANT) { - Feld[newx][newy] = EL_LEERRAUM; - DrawLevelField(newx,newy); + if (IS_MOVING(newx,newy)) + RemoveMovingField(newx,newy); + else + { + Feld[newx][newy] = EL_LEERRAUM; + DrawLevelField(newx,newy); + } } else if (element==EL_PACMAN && IN_LEV_FIELD(newx,newy) && IS_AMOEBOID(Feld[newx][newy])) { + if (AmoebaNr[newx][newy] && Feld[newx][newy]==EL_AMOEBE_VOLL) + AmoebaCnt[AmoebaNr[newx][newy]]--; + Feld[newx][newy] = EL_LEERRAUM; DrawLevelField(newx,newy); } @@ -1782,10 +1231,10 @@ void ContinueMoving(int x, int y) Feld[newx][newy] = EL_SALZSAEURE; element = EL_SALZSAEURE; } - else if (Store[x][y]==EL_AMOEBE2) + else if (Store[x][y]==EL_AMOEBE_NASS) { Store[x][y] = 0; - Feld[x][y] = EL_AMOEBE2; + Feld[x][y] = EL_AMOEBE_NASS; } MovPos[x][y] = MovDir[x][y] = 0; @@ -1816,6 +1265,112 @@ void ContinueMoving(int x, int y) } } +int AmoebeNachbarNr(int ax, int ay) +{ + int i; + int element = Feld[ax][ay]; + int group_nr = 0; + static int xy[4][2] = + { + 0,-1, + -1,0, + +1,0, + 0,+1 + }; + + for(i=0;i<4;i++) + { + int x = ax+xy[i%4][0]; + int y = ay+xy[i%4][1]; + + if (!IN_LEV_FIELD(x,y)) + continue; + + if (Feld[x][y]==element && AmoebaNr[x][y]>0) + group_nr = AmoebaNr[x][y]; + } + + return(group_nr); +} + +void AmoebenVereinigen(int ax, int ay) +{ + int i,x,y,xx,yy; + int new_group_nr = AmoebaNr[ax][ay]; + static int xy[4][2] = + { + 0,-1, + -1,0, + +1,0, + 0,+1 + }; + + if (!new_group_nr) + return; + + for(i=0;i<4;i++) + { + x = ax+xy[i%4][0]; + y = ay+xy[i%4][1]; + + if (!IN_LEV_FIELD(x,y)) + continue; + + if ((Feld[x][y]==EL_AMOEBE_VOLL || Feld[x][y]==EL_AMOEBE_TOT) && + AmoebaNr[x][y] != new_group_nr) + { + int old_group_nr = AmoebaNr[x][y]; + + AmoebaCnt[new_group_nr] += AmoebaCnt[old_group_nr]; + AmoebaCnt[old_group_nr] = 0; + + for(yy=0;yy0) return(MF_NO_ACTION); - LevelSolved = TRUE; + LevelSolved = GameOver = TRUE; PlaySoundLevel(x,y,SND_BUING); break; + case EL_BIRNE_AUS: + Feld[x][y] = EL_BIRNE_EIN; + DrawLevelField(x,y); + PlaySoundLevel(x,y,SND_DENG); + return(MF_ACTION); + break; + case EL_ZEIT_VOLL: + Feld[x][y] = EL_ZEIT_LEER; + DrawLevelField(x,y); + PlaySoundStereo(SND_GONG,PSND_MAX_RIGHT); + return(MF_ACTION); + break; default: return(MF_NO_ACTION); break; @@ -2897,202 +2477,3 @@ void TapeErase() { tape.length = 0; } - -void DrawVideoDisplay(unsigned long state, unsigned long value) -{ - int i; - int part1 = 0, part2 = 1; - int xpos = 0, ypos = 1, xsize = 2, ysize = 3; - static char *monatsname[12] = - { - "JAN", "FEB", "MAR", "APR", "MAY", "JUN", - "JUL", "AUG", "SEP", "OCT", "NOV", "DEC" - }; - static int video_pos[10][2][4] = - { - VIDEO_PLAY_LABEL_XPOS, VIDEO_PLAY_LABEL_YPOS, - VIDEO_PLAY_LABEL_XSIZE,VIDEO_PLAY_LABEL_YSIZE, - VIDEO_PLAY_SYMBOL_XPOS, VIDEO_PLAY_SYMBOL_YPOS, - VIDEO_PLAY_SYMBOL_XSIZE,VIDEO_PLAY_SYMBOL_YSIZE, - - VIDEO_REC_LABEL_XPOS, VIDEO_REC_LABEL_YPOS, - VIDEO_REC_LABEL_XSIZE,VIDEO_REC_LABEL_YSIZE, - VIDEO_REC_SYMBOL_XPOS, VIDEO_REC_SYMBOL_YPOS, - VIDEO_REC_SYMBOL_XSIZE,VIDEO_REC_SYMBOL_YSIZE, - - VIDEO_PAUSE_LABEL_XPOS, VIDEO_PAUSE_LABEL_YPOS, - VIDEO_PAUSE_LABEL_XSIZE,VIDEO_PAUSE_LABEL_YSIZE, - VIDEO_PAUSE_SYMBOL_XPOS, VIDEO_PAUSE_SYMBOL_YPOS, - VIDEO_PAUSE_SYMBOL_XSIZE,VIDEO_PAUSE_SYMBOL_YSIZE, - - VIDEO_DATE_LABEL_XPOS, VIDEO_DATE_LABEL_YPOS, - VIDEO_DATE_LABEL_XSIZE,VIDEO_DATE_LABEL_YSIZE, - VIDEO_DATE_XPOS, VIDEO_DATE_YPOS, - VIDEO_DATE_XSIZE,VIDEO_DATE_YSIZE, - - 0,0, - 0,0, - VIDEO_TIME_XPOS, VIDEO_TIME_YPOS, - VIDEO_TIME_XSIZE,VIDEO_TIME_YSIZE, - - VIDEO_BUTTON_PLAY_XPOS, VIDEO_BUTTON_ANY_YPOS, - VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, - 0,0, - 0,0, - - VIDEO_BUTTON_REC_XPOS, VIDEO_BUTTON_ANY_YPOS, - VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, - 0,0, - 0,0, - - VIDEO_BUTTON_PAUSE_XPOS, VIDEO_BUTTON_ANY_YPOS, - VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, - 0,0, - 0,0, - - VIDEO_BUTTON_STOP_XPOS, VIDEO_BUTTON_ANY_YPOS, - VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, - 0,0, - 0,0, - - VIDEO_BUTTON_EJECT_XPOS, VIDEO_BUTTON_ANY_YPOS, - VIDEO_BUTTON_XSIZE,VIDEO_BUTTON_YSIZE, - 0,0, - 0,0 - }; - - for(i=0;i<20;i++) - { - if (state & (1< STATE_ON / PRESS_OFF */ - cx = DOOR_GFX_PAGEX4; - else - cx = DOOR_GFX_PAGEX3; /* i gerade => STATE_OFF / PRESS_ON */ - - if (video_pos[pos][part1][0]) - XCopyArea(display,pix[PIX_DOOR],drawto,gc, - cx + video_pos[pos][part1][xpos], - cy + video_pos[pos][part1][ypos], - video_pos[pos][part1][xsize], - video_pos[pos][part1][ysize], - VX + video_pos[pos][part1][xpos], - VY + video_pos[pos][part1][ypos]); - if (video_pos[pos][part2][0]) - XCopyArea(display,pix[PIX_DOOR],drawto,gc, - cx + video_pos[pos][part2][xpos], - cy + video_pos[pos][part2][ypos], - video_pos[pos][part2][xsize], - video_pos[pos][part2][ysize], - VX + video_pos[pos][part2][xpos], - VY + video_pos[pos][part2][ypos]); - } - } - - if (state & VIDEO_STATE_DATE_ON) - { - int tag = value % 100; - int monat = (value/100) % 100; - int jahr = (value/10000); - - DrawText(VX+VIDEO_DATE_XPOS,VY+VIDEO_DATE_YPOS, - int2str(tag,2),FS_SMALL,FC_SPECIAL1); - DrawText(VX+VIDEO_DATE_XPOS+27,VY+VIDEO_DATE_YPOS, - monatsname[monat],FS_SMALL,FC_SPECIAL1); - DrawText(VX+VIDEO_DATE_XPOS+64,VY+VIDEO_DATE_YPOS, - int2str(jahr,2),FS_SMALL,FC_SPECIAL1); - } - - if (state & VIDEO_STATE_TIME_ON) - { - int min = value / 60; - int sec = value % 60; - - DrawText(VX+VIDEO_TIME_XPOS,VY+VIDEO_TIME_YPOS, - int2str(min,2),FS_SMALL,FC_SPECIAL1); - DrawText(VX+VIDEO_TIME_XPOS+27,VY+VIDEO_TIME_YPOS, - int2str(sec,2),FS_SMALL,FC_SPECIAL1); - } - - if (state & VIDEO_STATE_DATE) - redraw_mask |= REDRAW_VIDEO_1; - if ((state & ~VIDEO_STATE_DATE) & VIDEO_STATE) - redraw_mask |= REDRAW_VIDEO_2; - if (state & VIDEO_PRESS) - redraw_mask |= REDRAW_VIDEO_3; -} - -void DrawSoundDisplay(unsigned long state) -{ - int pos, cx = DOOR_GFX_PAGEX4, cy = 0; - - pos = (state & BUTTON_SOUND_MUSIC ? SOUND_BUTTON_MUSIC_XPOS : - state & BUTTON_SOUND_LOOPS ? SOUND_BUTTON_LOOPS_XPOS : - SOUND_BUTTON_SOUND_XPOS); - - if (state & BUTTON_ON) - cy -= SOUND_BUTTON_YSIZE; - - if (state & BUTTON_PRESSED) - cx = DOOR_GFX_PAGEX3; - - XCopyArea(display,pix[PIX_DOOR],drawto,gc, - cx + pos,cy + SOUND_BUTTON_ANY_YPOS, - SOUND_BUTTON_XSIZE,SOUND_BUTTON_YSIZE, - DX + pos,DY + SOUND_BUTTON_ANY_YPOS); - - redraw_mask |= REDRAW_DOOR_1; -} - -void DrawGameButton(unsigned long state) -{ - int pos, cx = DOOR_GFX_PAGEX4, cy = -GAME_BUTTON_YSIZE; - - pos = (state & BUTTON_GAME_STOP ? GAME_BUTTON_STOP_XPOS : - state & BUTTON_GAME_PAUSE ? GAME_BUTTON_PAUSE_XPOS : - GAME_BUTTON_PLAY_XPOS); - - if (state & BUTTON_PRESSED) - cx = DOOR_GFX_PAGEX3; - - XCopyArea(display,pix[PIX_DOOR],drawto,gc, - cx + pos,cy + GAME_BUTTON_ANY_YPOS, - GAME_BUTTON_XSIZE,GAME_BUTTON_YSIZE, - DX + pos,DY + GAME_BUTTON_ANY_YPOS); - - redraw_mask |= REDRAW_DOOR_1; -} - -void DrawChooseButton(unsigned long state) -{ - int pos, cx = DOOR_GFX_PAGEX4, cy = 0; - - pos = (state & BUTTON_OK ? OK_BUTTON_XPOS : NO_BUTTON_XPOS); - - if (state & BUTTON_PRESSED) - cx = DOOR_GFX_PAGEX3; - - XCopyArea(display,pix[PIX_DOOR],drawto,gc, - cx + pos,cy + OK_BUTTON_GFX_YPOS, - OK_BUTTON_XSIZE,OK_BUTTON_YSIZE, - DX + pos,DY + OK_BUTTON_YPOS); - - redraw_mask |= REDRAW_DOOR_1; -} - -void DrawConfirmButton(unsigned long state) -{ - int cx = DOOR_GFX_PAGEX4, cy = 0; - - if (state & BUTTON_PRESSED) - cx = DOOR_GFX_PAGEX3; - - XCopyArea(display,pix[PIX_DOOR],drawto,gc, - cx + CONFIRM_BUTTON_XPOS,cy + CONFIRM_BUTTON_GFX_YPOS, - CONFIRM_BUTTON_XSIZE,CONFIRM_BUTTON_YSIZE, - DX + CONFIRM_BUTTON_XPOS,DY + CONFIRM_BUTTON_YPOS); - - redraw_mask |= REDRAW_DOOR_1; -} diff --git a/src/game.h b/src/game.h index 422343d8..e7150b6b 100644 --- a/src/game.h +++ b/src/game.h @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * game.h * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #ifndef GAME_H @@ -19,9 +17,6 @@ #include "main.h" -#define PLAYER_LEVEL 0 -#define PLAYER_SETUP 1 - #define DF_DIG 0 #define DF_SNAP 1 #define DF_NO_PUSH 2 @@ -30,20 +25,10 @@ #define MF_MOVING 1 #define MF_ACTION 2 -BOOL CreateNewScoreFile(void); -BOOL CreateNewNamesFile(int); -void LoadLevelInfo(void); -void LoadLevel(int); -void LoadLevelTape(int); -void LoadScore(int); -void LoadPlayerInfo(int); -void SaveLevel(int); -void SaveLevelTape(int); -void SaveScore(int); -void SavePlayerInfo(int); void GetPlayerConfig(void); void InitGame(void); void InitMovDir(int, int); +void InitAmoebaNr(int, int); void GameWon(void); BOOL NewHiScore(void); void InitMovingField(int, int, int); @@ -60,6 +45,8 @@ void Impact(int, int); void TurnRound(int, int); void StartMoving(int, int); void ContinueMoving(int, int); +int AmoebeNachbarNr(int, int); +void AmoebeUmwandeln(int, int); void AmoebeWaechst(int, int); void AmoebeAbleger(int, int); void Life(int, int); @@ -94,10 +81,5 @@ int TapePlayAction(void); BOOL TapePlayDelay(void); void TapeStop(void); void TapeErase(void); -void DrawVideoDisplay(unsigned long, unsigned long); -void DrawSoundDisplay(unsigned long); -void DrawGameButton(unsigned long); -void DrawChooseButton(unsigned long); -void DrawConfirmButton(unsigned long); #endif diff --git a/src/images.c b/src/images.c deleted file mode 100644 index 83c7ae9f..00000000 --- a/src/images.c +++ /dev/null @@ -1,41 +0,0 @@ -/*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * -*----------------------------------------------------------* -* ©1995 Artsoft Development * -* Holger Schemel * -* 33659 Bielefeld-Senne * -* Telefon: (0521) 493245 * -* eMail: aeglos@valinor.owl.de * -* aeglos@uni-paderborn.de * -* q99492@pbhrzx.uni-paderborn.de * -*----------------------------------------------------------* -* images.c * -* * -* Letzte Aenderung: 15.06.1995 * -***********************************************************/ - -#include "images.h" - -struct PictureFile icon_pic = -{ - "rocks_icon.xbm", - "rocks_iconmask.xbm" -}; - -struct PictureFile pic[NUM_PICTURES] = -{ - "RocksScreen.xpm", - "RocksScreenMaske.xbm", - - "RocksDoor.xpm", - "RocksDoorMaske.xbm", - - "RocksToons.xpm", - "RocksToonsMaske.xbm", - - "RocksFont.xpm", - NULL, - - "RocksFont2.xpm", - NULL -}; diff --git a/src/images.h b/src/images.h deleted file mode 100644 index 6a83841a..00000000 --- a/src/images.h +++ /dev/null @@ -1,25 +0,0 @@ -/*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * -*----------------------------------------------------------* -* ©1995 Artsoft Development * -* Holger Schemel * -* 33659 Bielefeld-Senne * -* Telefon: (0521) 493245 * -* eMail: aeglos@valinor.owl.de * -* aeglos@uni-paderborn.de * -* q99492@pbhrzx.uni-paderborn.de * -*----------------------------------------------------------* -* images.h * -* * -* Letzte Aenderung: 15.06.1995 * -***********************************************************/ - -#ifndef IMAGES_H -#define IMAGES_H - -#include "main.h" - -extern struct PictureFile icon_pic; -extern struct PictureFile pic[]; - -#endif diff --git a/src/init.c b/src/init.c index ec0a1c74..8032ffb3 100644 --- a/src/init.c +++ b/src/init.c @@ -10,27 +10,20 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * init.c * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #include "init.h" -#include "images.h" +#include "misc.h" #include "sound.h" #include "screens.h" -#include "tools.h" -#include "game.h" -#include "misc.h" - +#include "files.h" #include -int sound_process_id=0; +static int sound_process_id = 0; void OpenAll(int argc, char *argv[]) { - LoadLevelInfo(); - LoadPlayerInfo(PLAYER_SETUP); - LoadPlayerInfo(PLAYER_LEVEL); + InitLevelAndPlayerInfo(); InitCounter(); InitSound(); @@ -44,6 +37,7 @@ void OpenAll(int argc, char *argv[]) InitDisplay(argc, argv); InitWindow(argc, argv); InitGfx(); + InitElementProperties(); DrawMainMenu(); @@ -51,6 +45,15 @@ void OpenAll(int argc, char *argv[]) XFlush(display); } +void InitLevelAndPlayerInfo() +{ + if (!LoadLevelInfo()) /* global level info */ + CloseAll(); + + LoadPlayerInfo(PLAYER_SETUP); /* global setup info */ + LoadPlayerInfo(PLAYER_LEVEL); /* level specific info */ +} + void InitSound() { int i; @@ -124,7 +127,7 @@ void InitJoystick() if (access(joystick_device_name[joystick_nr],R_OK)<0) { fprintf(stderr,"%s: cannot access joystick device '%s'\n", - joystick_device_name[joystick_nr],progname); + progname,joystick_device_name[joystick_nr]); joystick_status = JOYSTICK_OFF; return; } @@ -132,7 +135,7 @@ void InitJoystick() if ((joystick_device=open(joystick_device_name[joystick_nr],O_RDONLY))<0) { fprintf(stderr,"%s: cannot open joystick device '%s'\n", - joystick_device_name[joystick_nr],progname); + progname,joystick_device_name[joystick_nr]); joystick_status = JOYSTICK_OFF; return; } @@ -191,6 +194,11 @@ void InitWindow(int argc, char *argv[]) char *window_name = "Rocks'n'Diamonds"; char *icon_name = "Rocks'n'Diamonds"; long window_event_mask; + static struct PictureFile icon_pic = + { + "rocks_icon.xbm", + "rocks_iconmask.xbm" + }; width = WIN_XSIZE; height = WIN_YSIZE; @@ -282,6 +290,15 @@ void InitGfx() char filename[256]; Pixmap shapemask; + static struct PictureFile pic[NUM_PICTURES] = + { + "RocksScreen.xpm", "RocksScreenMaske.xbm", + "RocksDoor.xpm", "RocksDoorMaske.xbm", + "RocksToons.xpm", "RocksToonsMaske.xbm", + "RocksFont.xpm", NULL, + "RocksFont2.xpm", NULL + }; + for(i=0;i=EL_BADEWANNE1 && (e)<=EL_BADEWANNE5) #define IS_SCHLUESSEL(e) ((e)>=EL_SCHLUESSEL1 && (e)<=EL_SCHLUESSEL4) #define IS_PFORTE(e) ((e)>=EL_PFORTE1 && (e)<=EL_PFORTE4X) -#define IS_CHAR(e) ((e)>=EL_CHAR_START && (e)<=EL_CHAR_END) #define IS_SOLID(e) ((e)==EL_BETON || (e)==EL_MAUERWERK || (e)==EL_FELSBODEN || (e)==EL_AUSGANG_ZU || (e)==EL_AUSGANG_ACT || (e)==EL_AUSGANG_AUF || IS_AMOEBOID(e) || (e)==EL_MORAST_VOLL || (e)==EL_MORAST_LEER || (e)==EL_SIEB_VOLL || (e)==EL_SIEB_LEER || (e)==EL_LIFE || (e)==EL_LIFE_ASYNC || IS_BADEWANNOID(e)) #define IS_MASSIV(e) ((e)==EL_BETON || (e)==EL_SALZSAEURE || IS_BADEWANNOID(e) || IS_PFORTE(e)) -#define CAN_FALL(e) ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_TROPFEN || (e)==EL_MORAST_VOLL || (e)==EL_SIEB_VOLL) +#define IS_SLIPPERY(e) ((e)==EL_FELSBODEN || (e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_ABLENK_EIN || (e)==EL_ABLENK_AUS || (e)==EL_ZEIT_VOLL || (e)==EL_ZEIT_LEER || (e)==EL_BIRNE_EIN || (e)==EL_BIRNE_AUS || (e)==EL_BADEWANNE1 || (e)==EL_BADEWANNE2) + +#define IS_ENEMY(e) ((e)==EL_KAEFER || (e)==EL_FLIEGER || (e)==EL_MAMPFER || (e)==EL_ZOMBIE || (e)==EL_PACMAN) + +#define CAN_FALL(e) ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_TROPFEN || (e)==EL_MORAST_VOLL || (e)==EL_SIEB_VOLL || (e)==EL_ZEIT_VOLL || (e)==EL_ZEIT_LEER) -#define CAN_SMASH(e) ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || IS_SCHLUESSEL(e) || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_TROPFEN) +#define CAN_SMASH(e) ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || IS_SCHLUESSEL(e) || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_TROPFEN || (e)==EL_ZEIT_VOLL || (e)==EL_ZEIT_LEER) #define CAN_CHANGE(e) ((e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT) #define CAN_MOVE(e) ((e)==EL_KAEFER || (e)==EL_FLIEGER || (e)==EL_MAMPFER || (e)==EL_ZOMBIE || (e)==EL_PACMAN) -#define COULD_MOVE(e) (((e)>=EL_KAEFER_R && (e)<=EL_KAEFER_U) || ((e)>=EL_FLIEGER_R && (e)<=EL_FLIEGER_U) || ((e)>=EL_PACMAN && (e)==EL_PACMAN_U)) +#define COULD_MOVE(e) (((e)>=EL_KAEFER_R && (e)<=EL_KAEFER_U) || ((e)>=EL_FLIEGER_R && (e)<=EL_FLIEGER_U) || ((e)>=EL_PACMAN_R && (e)==EL_PACMAN_U)) -/* -#define CAN_KILL(e) ((e)==EL_KAEFER || (e)==EL_FLIEGER || (e)==EL_MAMPFER || (e)==EL_ZOMBIE || (e)==EL_PACMAN || (e)==EL_TROPFEN) -*/ - -#define IS_ENEMY(e) ((e)==EL_KAEFER || (e)==EL_FLIEGER || (e)==EL_MAMPFER || (e)==EL_ZOMBIE || (e)==EL_PACMAN) #define DONT_TOUCH(e) ((e)==EL_KAEFER || (e)==EL_FLIEGER) #define DONT_GO_TO(e) (IS_ENEMY(e) || (e)==EL_TROPFEN || (e)==EL_SALZSAEURE) -#define SLIPPERY(e) ((e)==EL_FELSBODEN || (e)==EL_FELSBROCKEN || (e)==EL_EDELSTEIN || (e)==EL_DIAMANT || (e)==EL_BOMBE || (e)==EL_KOKOSNUSS || (e)==EL_ABLENK_EIN || (e)==EL_ABLENK_AUS || (e)==EL_BADEWANNE1 || (e)==EL_BADEWANNE2) +#define IS_CHAR(e) ((e)>=EL_CHAR_START && (e)<=EL_CHAR_END) + +*/ + -#define EL_CHANGED(e) ((e)==EL_FELSBROCKEN ? EL_EDELSTEIN : (e)==EL_EDELSTEIN ? EL_DIAMANT : EL_FELSBROCKEN) +#define EP_BIT_AMOEBALIVE (1<<0) +#define EP_BIT_AMOEBOID (1<<1) +#define EP_BIT_BADEWANNOID (1<<2) +#define EP_BIT_SCHLUESSEL (1<<3) +#define EP_BIT_PFORTE (1<<4) +#define EP_BIT_SOLID (1<<5) +#define EP_BIT_MASSIV (1<<6) +#define EP_BIT_SLIPPERY (1<<7) +#define EP_BIT_ENEMY (1<<8) +#define EP_BIT_CAN_FALL (1<<9) +#define EP_BIT_CAN_SMASH (1<<10) +#define EP_BIT_CAN_CHANGE (1<<11) +#define EP_BIT_CAN_MOVE (1<<12) +#define EP_BIT_COULD_MOVE (1<<13) +#define EP_BIT_DONT_TOUCH (1<<14) +#define EP_BIT_DONT_GO_TO (1<<15) +#define EP_BIT_CHAR (1<<16) + +#define IS_AMOEBALIVE(e) (Elementeigenschaften[e] & EP_BIT_AMOEBALIVE) +#define IS_AMOEBOID(e) (Elementeigenschaften[e] & EP_BIT_AMOEBOID) +#define IS_BADEWANNOID(e) (Elementeigenschaften[e] & EP_BIT_BADEWANNOID) +#define IS_SCHLUESSEL(e) (Elementeigenschaften[e] & EP_BIT_SCHLUESSEL) +#define IS_PFORTE(e) (Elementeigenschaften[e] & EP_BIT_PFORTE) +#define IS_SOLID(e) (Elementeigenschaften[e] & EP_BIT_SOLID) +#define IS_MASSIV(e) (Elementeigenschaften[e] & EP_BIT_MASSIV) +#define IS_SLIPPERY(e) (Elementeigenschaften[e] & EP_BIT_SLIPPERY) +#define IS_ENEMY(e) (Elementeigenschaften[e] & EP_BIT_ENEMY) +#define CAN_FALL(e) (Elementeigenschaften[e] & EP_BIT_CAN_FALL) +#define CAN_SMASH(e) (Elementeigenschaften[e] & EP_BIT_CAN_SMASH) +#define CAN_CHANGE(e) (Elementeigenschaften[e] & EP_BIT_CAN_CHANGE) +#define CAN_MOVE(e) (Elementeigenschaften[e] & EP_BIT_CAN_MOVE) +#define COULD_MOVE(e) (Elementeigenschaften[e] & EP_BIT_COULD_MOVE) +#define DONT_TOUCH(e) (Elementeigenschaften[e] & EP_BIT_DONT_TOUCH) +#define DONT_GO_TO(e) (Elementeigenschaften[e] & EP_BIT_DONT_GO_TO) +#define IS_CHAR(e) (Elementeigenschaften[e] & EP_BIT_CHAR) + +#define EL_CHANGED(e) ((e)==EL_FELSBROCKEN ? EL_EDELSTEIN : \ + (e)==EL_EDELSTEIN ? EL_DIAMANT : \ + EL_FELSBROCKEN) #define IS_DRAWABLE(e) ((e)=EL_BLOCKED) -#define TIMESIZE (TimeLeft*100/level.time) - +#define TIMESIZE (TimeLeft*100/level.time) #define LEVELDIR_SIZE(x) ((x).num_ready + (x).num_free) #define TAPE_IS_EMPTY(x) ((x).length == 0) @@ -127,10 +160,11 @@ typedef int BOOL; #define NUM_PICTURES 5 #define NUM_PIXMAPS 8 +/* boundaries of arrays etc. */ #define MAX_NAMELEN (10+1) #define MAX_LEVNAMLEN 32 -#define MAX_SC_ENTRIES 16 +#define MAX_SC_ENTRIES 15 #define MAX_TAPELEN 10000 #define MAX_LEVDIR_FILENAME (64+1) @@ -139,6 +173,8 @@ typedef int BOOL; #define MAX_SCORE_ENTRIES 15 #define MAX_FILENAME 256 +#define MAX_NUM_AMOEBA 100 +#define MAX_ELEMENTS 512 struct PictureFile { @@ -169,6 +205,7 @@ struct LevelInfo int edelsteine; char name[MAX_LEVNAMLEN]; int score[MAX_SC_ENTRIES]; + int amoebe_inhalt; int mampfer_inhalt[4][3][3]; int tempo_amoebe; int dauer_sieb; @@ -236,6 +273,7 @@ extern int direct_draw_on; extern int fading_on; extern int autorecord_on; extern int joystick_nr; +extern int quick_doors; extern BOOL redraw[SCR_FIELDX][SCR_FIELDY]; extern int redraw_mask; @@ -250,6 +288,10 @@ extern int Store[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern int Store2[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern int Frame[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; extern int Stop[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern int AmoebaNr[MAX_LEV_FIELDX][MAX_LEV_FIELDY]; +extern int AmoebaCnt[MAX_NUM_AMOEBA]; +extern long Elementeigenschaften[MAX_ELEMENTS]; + extern int level_nr, leveldir_nr, num_leveldirs; extern int lev_fieldx,lev_fieldy, scroll_x,scroll_y; @@ -262,6 +304,7 @@ extern struct LevelInfo level; extern struct PlayerInfo player; extern struct HiScore highscore[]; extern struct RecordingInfo tape, master_tape; +extern struct JoystickInfo joystick[]; extern int background_loop[]; extern int num_bg_loops; @@ -321,8 +364,8 @@ extern char *progname; #define FONT_LINES_PER_FONT 4 /* game elements: -** 0 - 255: real elements, stored in level file -** 256 - ?: flag elements, only used at runtime +** 0 - 255: real elements, stored in level file +** 256 - 511: flag elements, only used at runtime */ /* "real" level elements */ #define EL_LEERRAUM 0 @@ -340,7 +383,7 @@ extern char *progname; #define EL_ZOMBIE 12 #define EL_BETON 13 #define EL_DIAMANT 14 -#define EL_AMOEBE1 15 +#define EL_AMOEBE_TOT 15 #define EL_MORAST_LEER 16 #define EL_MORAST_VOLL 17 #define EL_TROPFEN 18 @@ -348,8 +391,8 @@ extern char *progname; #define EL_SIEB_LEER 20 #define EL_SIEB_VOLL 21 #define EL_SALZSAEURE 22 -#define EL_AMOEBE2 23 -#define EL_AMOEBE3 24 +#define EL_AMOEBE_NASS 23 +#define EL_AMOEBE_NORM 24 #define EL_KOKOSNUSS 25 #define EL_LIFE 26 #define EL_LIFE_ASYNC 27 @@ -374,8 +417,12 @@ extern char *progname; #define EL_UNSICHTBAR 46 #define EL_BIRNE_AUS 47 #define EL_BIRNE_EIN 48 -#define EL_ERZ_1 49 -#define EL_ERZ_2 50 +#define EL_ERZ_EDEL 49 +#define EL_ERZ_DIAM 50 +#define EL_AMOEBE_VOLL 51 +#define EL_AMOEBA2DIAM 52 +#define EL_ZEIT_VOLL 53 +#define EL_ZEIT_LEER 54 #define EL_SPIELER1 80 #define EL_SPIELER2 81 @@ -440,8 +487,7 @@ extern char *progname; #define EL_CRACKINGNUT 302 #define EL_BLURB_LEFT 303 #define EL_BLURB_RIGHT 304 -#define EL_AMOEBING2 305 -#define EL_AMOEBING3 306 +#define EL_AMOEBING 305 /* names for the graphic objects */ /* Zeile 0 (0) */ @@ -515,23 +561,26 @@ extern char *progname; #define GFX_ABLENK 96 #define GFX_ABLENK_EIN GFX_ABLENK #define GFX_ABLENK_AUS GFX_ABLENK -#define GFX_AMOEBE2 100 +#define GFX_AMOEBE_NASS 100 #define GFX_TROPFEN 101 #define GFX_AMOEBING GFX_TROPFEN #define GFX_AMOEBE_LEBT 104 -#define GFX_AMOEBE3 GFX_AMOEBE_LEBT +#define GFX_AMOEBE_NORM GFX_AMOEBE_LEBT #define GFX_AMOEBE_TOT 108 -#define GFX_AMOEBE1 GFX_AMOEBE_TOT +#define GFX_AMOEBA2DIAM GFX_AMOEBE_TOT +#define GFX_ZEIT_VOLL 114 +#define GFX_ZEIT_LEER 115 /* Zeile 7 (112) */ #define GFX_GEBLUBBER 124 /* Zeile 8 (128) */ #define GFX_SIEB_LEER 128 #define GFX_SIEB_VOLL GFX_SIEB_LEER #define GFX_SIEB_TOT GFX_SIEB_LEER -#define GFX_ERZ_1 132 -#define GFX_ERZ_2 133 +#define GFX_ERZ_EDEL 132 +#define GFX_ERZ_DIAM 133 #define GFX_BIRNE_AUS 134 #define GFX_BIRNE_EIN 135 +#define GFX_AMOEBE_VOLL 136 #define GFX_KUGEL_ROT 140 #define GFX_KUGEL_BLAU 141 #define GFX_KUGEL_GELB 142 @@ -695,8 +744,13 @@ extern struct SoundInfo Sound[NUM_SOUNDS]; /* values for the joystick */ #define JOYSTICK_OFF 0 #define JOYSTICK_AVAILABLE 1 +#ifdef __FreeBSD__ +#define DEV_JOYSTICK_0 "/dev/joy0" +#define DEV_JOYSTICK_1 "/dev/joy1" +#else #define DEV_JOYSTICK_0 "/dev/js0" #define DEV_JOYSTICK_1 "/dev/js1" +#endif /* get these values from the program 'js' from the joystick package, */ /* set JOYSTICK_PERCENT to a threshold appropriate for your joystick */ @@ -859,235 +913,4 @@ extern struct SoundInfo Sound[NUM_SOUNDS]; #define DOOR_GFX_PAGEY1 0 #define DOOR_GFX_PAGEY2 DYSIZE -/* some positions in the video tape control window */ -#define VIDEO_DISPLAY1_XPOS 5 -#define VIDEO_DISPLAY1_YPOS 5 -#define VIDEO_DISPLAY2_XPOS 5 -#define VIDEO_DISPLAY2_YPOS 41 -#define VIDEO_DISPLAY_XSIZE 90 -#define VIDEO_DISPLAY_YSIZE 31 -#define VIDEO_BUTTON_XSIZE 18 -#define VIDEO_BUTTON_YSIZE 18 -#define VIDEO_CONTROL_XPOS 5 -#define VIDEO_CONTROL_YPOS 77 -#define VIDEO_CONTROL_XSIZE (VIDEO_DISPLAY_XSIZE) -#define VIDEO_CONTROL_YSIZE (VIDEO_BUTTON_YSIZE) -#define VIDEO_BUTTON_EJECT_XPOS (VIDEO_CONTROL_XPOS + 0 * VIDEO_BUTTON_XSIZE) -#define VIDEO_BUTTON_STOP_XPOS (VIDEO_CONTROL_XPOS + 1 * VIDEO_BUTTON_XSIZE) -#define VIDEO_BUTTON_PAUSE_XPOS (VIDEO_CONTROL_XPOS + 2 * VIDEO_BUTTON_XSIZE) -#define VIDEO_BUTTON_REC_XPOS (VIDEO_CONTROL_XPOS + 3 * VIDEO_BUTTON_XSIZE) -#define VIDEO_BUTTON_PLAY_XPOS (VIDEO_CONTROL_XPOS + 4 * VIDEO_BUTTON_XSIZE) -#define VIDEO_BUTTON_ANY_YPOS (VIDEO_CONTROL_YPOS) -#define VIDEO_DATE_LABEL_XPOS (VIDEO_DISPLAY1_XPOS) -#define VIDEO_DATE_LABEL_YPOS (VIDEO_DISPLAY1_YPOS) -#define VIDEO_DATE_LABEL_XSIZE (VIDEO_DISPLAY_XSIZE) -#define VIDEO_DATE_LABEL_YSIZE (VIDEO_DISPLAY_YSIZE) -#define VIDEO_DATE_XPOS (VIDEO_DISPLAY1_XPOS+1) -#define VIDEO_DATE_YPOS (VIDEO_DISPLAY1_YPOS+14) -#define VIDEO_DATE_XSIZE (VIDEO_DISPLAY_XSIZE) -#define VIDEO_DATE_YSIZE 16 -#define VIDEO_REC_LABEL_XPOS (VIDEO_DISPLAY2_XPOS) -#define VIDEO_REC_LABEL_YPOS (VIDEO_DISPLAY2_YPOS) -#define VIDEO_REC_LABEL_XSIZE 20 -#define VIDEO_REC_LABEL_YSIZE 12 -#define VIDEO_REC_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+20) -#define VIDEO_REC_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS) -#define VIDEO_REC_SYMBOL_XSIZE 16 -#define VIDEO_REC_SYMBOL_YSIZE 16 -#define VIDEO_PLAY_LABEL_XPOS (VIDEO_DISPLAY2_XPOS+65) -#define VIDEO_PLAY_LABEL_YPOS (VIDEO_DISPLAY2_YPOS) -#define VIDEO_PLAY_LABEL_XSIZE 22 -#define VIDEO_PLAY_LABEL_YSIZE 12 -#define VIDEO_PLAY_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+50) -#define VIDEO_PLAY_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS) -#define VIDEO_PLAY_SYMBOL_XSIZE 13 -#define VIDEO_PLAY_SYMBOL_YSIZE 13 -#define VIDEO_PAUSE_LABEL_XPOS (VIDEO_DISPLAY2_XPOS) -#define VIDEO_PAUSE_LABEL_YPOS (VIDEO_DISPLAY2_YPOS+20) -#define VIDEO_PAUSE_LABEL_XSIZE 35 -#define VIDEO_PAUSE_LABEL_YSIZE 8 -#define VIDEO_PAUSE_SYMBOL_XPOS (VIDEO_DISPLAY2_XPOS+35) -#define VIDEO_PAUSE_SYMBOL_YPOS (VIDEO_DISPLAY2_YPOS) -#define VIDEO_PAUSE_SYMBOL_XSIZE 13 -#define VIDEO_PAUSE_SYMBOL_YSIZE 13 -#define VIDEO_TIME_XPOS (VIDEO_DISPLAY2_XPOS+38) -#define VIDEO_TIME_YPOS (VIDEO_DISPLAY2_YPOS+14) -#define VIDEO_TIME_XSIZE 50 -#define VIDEO_TIME_YSIZE 16 - -#define ON_VIDEO_BUTTON(x,y) ((x)>=(VX+VIDEO_CONTROL_XPOS) && \ - (x)< (VX+VIDEO_CONTROL_XPOS + \ - VIDEO_CONTROL_XSIZE) && \ - (y)>=(VY+VIDEO_CONTROL_YPOS) && \ - (y)< (VY+VIDEO_CONTROL_YPOS + \ - VIDEO_CONTROL_YSIZE)) -#define VIDEO_BUTTON(x) (((x)-(VX+VIDEO_CONTROL_XPOS))/VIDEO_BUTTON_XSIZE) - -/* values for video tape control */ -#define VIDEO_STATE_PLAY_OFF (1L<<0) -#define VIDEO_STATE_PLAY_ON (1L<<1) -#define VIDEO_STATE_PLAY (VIDEO_STATE_PLAY_OFF | VIDEO_STATE_PLAY_ON) -#define VIDEO_STATE_REC_OFF (1L<<2) -#define VIDEO_STATE_REC_ON (1L<<3) -#define VIDEO_STATE_REC (VIDEO_STATE_REC_OFF | VIDEO_STATE_REC_ON) -#define VIDEO_STATE_PAUSE_OFF (1L<<4) -#define VIDEO_STATE_PAUSE_ON (1L<<5) -#define VIDEO_STATE_PAUSE (VIDEO_STATE_PAUSE_OFF | VIDEO_STATE_PAUSE_ON) -#define VIDEO_STATE_DATE_OFF (1L<<6) -#define VIDEO_STATE_DATE_ON (1L<<7) -#define VIDEO_STATE_DATE (VIDEO_STATE_DATE_OFF | VIDEO_STATE_DATE_ON) -#define VIDEO_STATE_TIME_OFF (1L<<8) -#define VIDEO_STATE_TIME_ON (1L<<9) -#define VIDEO_STATE_TIME (VIDEO_STATE_TIME_OFF | VIDEO_STATE_TIME_ON) -#define VIDEO_PRESS_PLAY_ON (1L<<10) -#define VIDEO_PRESS_PLAY_OFF (1L<<11) -#define VIDEO_PRESS_PLAY (VIDEO_PRESS_PLAY_OFF | VIDEO_PRESS_PLAY_ON) -#define VIDEO_PRESS_REC_ON (1L<<12) -#define VIDEO_PRESS_REC_OFF (1L<<13) -#define VIDEO_PRESS_REC (VIDEO_PRESS_REC_OFF | VIDEO_PRESS_REC_ON) -#define VIDEO_PRESS_PAUSE_ON (1L<<14) -#define VIDEO_PRESS_PAUSE_OFF (1L<<15) -#define VIDEO_PRESS_PAUSE (VIDEO_PRESS_PAUSE_OFF | VIDEO_PRESS_PAUSE_ON) -#define VIDEO_PRESS_STOP_ON (1L<<16) -#define VIDEO_PRESS_STOP_OFF (1L<<17) -#define VIDEO_PRESS_STOP (VIDEO_PRESS_STOP_OFF | VIDEO_PRESS_STOP_ON) -#define VIDEO_PRESS_EJECT_ON (1L<<18) -#define VIDEO_PRESS_EJECT_OFF (1L<<19) -#define VIDEO_PRESS_EJECT (VIDEO_PRESS_EJECT_OFF | VIDEO_PRESS_EJECT_ON) - -#define BUTTON_VIDEO_EJECT 1 -#define BUTTON_VIDEO_STOP 2 -#define BUTTON_VIDEO_PAUSE 3 -#define BUTTON_VIDEO_REC 4 -#define BUTTON_VIDEO_PLAY 5 - -#define VIDEO_STATE_OFF (VIDEO_STATE_PLAY_OFF | \ - VIDEO_STATE_REC_OFF | \ - VIDEO_STATE_PAUSE_OFF | \ - VIDEO_STATE_DATE_OFF | \ - VIDEO_STATE_TIME_OFF) -#define VIDEO_PRESS_OFF (VIDEO_PRESS_PLAY_OFF | \ - VIDEO_PRESS_REC_OFF | \ - VIDEO_PRESS_PAUSE_OFF | \ - VIDEO_PRESS_STOP_OFF | \ - VIDEO_PRESS_EJECT_OFF) -#define VIDEO_ALL_OFF (VIDEO_STATE_OFF | VIDEO_PRESS_OFF) - -#define VIDEO_STATE_ON (VIDEO_STATE_PLAY_ON | \ - VIDEO_STATE_REC_ON | \ - VIDEO_STATE_PAUSE_ON | \ - VIDEO_STATE_DATE_ON | \ - VIDEO_STATE_TIME_ON) -#define VIDEO_PRESS_ON (VIDEO_PRESS_PLAY_ON | \ - VIDEO_PRESS_REC_ON | \ - VIDEO_PRESS_PAUSE_ON | \ - VIDEO_PRESS_STOP_ON | \ - VIDEO_PRESS_EJECT_ON) -#define VIDEO_ALL_ON (VIDEO_STATE_ON | VIDEO_PRESS_ON) - -#define VIDEO_STATE (VIDEO_STATE_ON | VIDEO_STATE_OFF) -#define VIDEO_PRESS (VIDEO_PRESS_ON | VIDEO_PRESS_OFF) -#define VIDEO_ALL (VIDEO_ALL_ON | VIDEO_ALL_OFF) - -/* some positions in the sound control window */ -#define SOUND_BUTTON_XSIZE 30 -#define SOUND_BUTTON_YSIZE 30 -#define SOUND_CONTROL_XPOS 5 -#define SOUND_CONTROL_YPOS 245 -#define SOUND_CONTROL_XSIZE 90 -#define SOUND_CONTROL_YSIZE (SOUND_BUTTON_YSIZE) -#define SOUND_BUTTON_MUSIC_XPOS (SOUND_CONTROL_XPOS + 0 * SOUND_BUTTON_XSIZE) -#define SOUND_BUTTON_LOOPS_XPOS (SOUND_CONTROL_XPOS + 1 * SOUND_BUTTON_XSIZE) -#define SOUND_BUTTON_SOUND_XPOS (SOUND_CONTROL_XPOS + 2 * SOUND_BUTTON_XSIZE) -#define SOUND_BUTTON_ANY_YPOS (SOUND_CONTROL_YPOS) - -#define ON_SOUND_BUTTON(x,y) ((x)>=(DX+SOUND_CONTROL_XPOS) && \ - (x)< (DX+SOUND_CONTROL_XPOS + \ - SOUND_CONTROL_XSIZE) && \ - (y)>=(DY+SOUND_CONTROL_YPOS) && \ - (y)< (DY+SOUND_CONTROL_YPOS + \ - SOUND_CONTROL_YSIZE)) -#define SOUND_BUTTON(x) (((x)-(DX+SOUND_CONTROL_XPOS))/SOUND_BUTTON_XSIZE) - -/* values for sound control */ -#define BUTTON_SOUND_MUSIC (1L<<0) -#define BUTTON_SOUND_LOOPS (1L<<1) -#define BUTTON_SOUND_SOUND (1L<<2) -#define BUTTON_RELEASED 0 -#define BUTTON_PRESSED (1L<<3) -#define BUTTON_OFF 0 -#define BUTTON_ON (1L<<4) -#define BUTTON_SOUND_MUSIC_OFF (BUTTON_SOUND_MUSIC | BUTTON_OFF) -#define BUTTON_SOUND_LOOPS_OFF (BUTTON_SOUND_LOOPS | BUTTON_OFF) -#define BUTTON_SOUND_SOUND_OFF (BUTTON_SOUND_SOUND | BUTTON_OFF) -#define BUTTON_SOUND_MUSIC_ON (BUTTON_SOUND_MUSIC | BUTTON_ON) -#define BUTTON_SOUND_LOOPS_ON (BUTTON_SOUND_LOOPS | BUTTON_ON) -#define BUTTON_SOUND_SOUND_ON (BUTTON_SOUND_SOUND | BUTTON_ON) - -/* some positions in the game control window */ -#define GAME_BUTTON_XSIZE 30 -#define GAME_BUTTON_YSIZE 30 -#define GAME_CONTROL_XPOS 5 -#define GAME_CONTROL_YPOS 215 -#define GAME_CONTROL_XSIZE 90 -#define GAME_CONTROL_YSIZE (GAME_BUTTON_YSIZE) -#define GAME_BUTTON_STOP_XPOS (GAME_CONTROL_XPOS + 0 * GAME_BUTTON_XSIZE) -#define GAME_BUTTON_PAUSE_XPOS (GAME_CONTROL_XPOS + 1 * GAME_BUTTON_XSIZE) -#define GAME_BUTTON_PLAY_XPOS (GAME_CONTROL_XPOS + 2 * GAME_BUTTON_XSIZE) -#define GAME_BUTTON_ANY_YPOS (GAME_CONTROL_YPOS) - -#define ON_GAME_BUTTON(x,y) ((x)>=(DX+GAME_CONTROL_XPOS) && \ - (x)< (DX+GAME_CONTROL_XPOS + \ - GAME_CONTROL_XSIZE) && \ - (y)>=(DY+GAME_CONTROL_YPOS) && \ - (y)< (DY+GAME_CONTROL_YPOS + \ - GAME_CONTROL_YSIZE)) -#define GAME_BUTTON(x) (((x)-(DX+GAME_CONTROL_XPOS))/GAME_BUTTON_XSIZE) - -/* values for game control */ -#define BUTTON_GAME_STOP (1L<<0) -#define BUTTON_GAME_PAUSE (1L<<1) -#define BUTTON_GAME_PLAY (1L<<2) - -/* some positions in the asking window */ -#define OK_BUTTON_XPOS 2 -#define OK_BUTTON_YPOS 250 -#define OK_BUTTON_GFX_YPOS 0 -#define OK_BUTTON_XSIZE 46 -#define OK_BUTTON_YSIZE 28 -#define NO_BUTTON_XPOS 52 -#define NO_BUTTON_YPOS OK_BUTTON_YPOS -#define NO_BUTTON_XSIZE OK_BUTTON_XSIZE -#define NO_BUTTON_YSIZE OK_BUTTON_YSIZE -#define CONFIRM_BUTTON_XPOS 2 -#define CONFIRM_BUTTON_GFX_YPOS 30 -#define CONFIRM_BUTTON_YPOS OK_BUTTON_YPOS -#define CONFIRM_BUTTON_XSIZE 96 -#define CONFIRM_BUTTON_YSIZE OK_BUTTON_YSIZE - -#define ON_CHOOSE_BUTTON(x,y) (((x)>=(DX+OK_BUTTON_XPOS) && \ - (x)< (DX+OK_BUTTON_XPOS + \ - OK_BUTTON_XSIZE) && \ - (y)>=(DY+OK_BUTTON_YPOS) && \ - (y)< (DY+OK_BUTTON_YPOS + \ - OK_BUTTON_YSIZE)) || \ - ((x)>=(DX+NO_BUTTON_XPOS) && \ - (x)< (DX+NO_BUTTON_XPOS + \ - NO_BUTTON_XSIZE) && \ - (y)>=(DY+NO_BUTTON_YPOS) && \ - (y)< (DY+NO_BUTTON_YPOS + \ - NO_BUTTON_YSIZE))) -#define ON_CONFIRM_BUTTON(x,y) (((x)>=(DX+CONFIRM_BUTTON_XPOS) && \ - (x)< (DX+CONFIRM_BUTTON_XPOS + \ - CONFIRM_BUTTON_XSIZE) && \ - (y)>=(DY+CONFIRM_BUTTON_YPOS) && \ - (y)< (DY+CONFIRM_BUTTON_YPOS + \ - CONFIRM_BUTTON_YSIZE))) -#define CHOOSE_BUTTON(x) (((x)-(DX+OK_BUTTON_XPOS))/OK_BUTTON_XSIZE) - -/* values for asking control */ -#define BUTTON_OK (1L<<0) -#define BUTTON_NO (1L<<1) -#define BUTTON_CONFIRM (1L<<2) - #endif diff --git a/src/misc.c b/src/misc.c index a066cff5..a17b1da5 100644 --- a/src/misc.c +++ b/src/misc.c @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * misc.c * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #include "misc.h" @@ -36,6 +34,74 @@ void microsleep(unsigned long usec) progname); } +long mainCounter(int mode) +{ + static struct timeval base_time = { 0, 0 }; + struct timeval current_time; + long counter_ms; + + gettimeofday(¤t_time,NULL); + if (mode==0 || current_time.tv_sec0) + microsleep(wait*10000); +} + +void WaitCounter2(long value) /* wait for counter to reach value */ +{ + long wait; + + while((wait=value-Counter2())>0) + microsleep(wait*1000); +} + +void Delay(long value) +{ + microsleep(value); +} + +BOOL DelayReached(long *counter_var, int delay) +{ + long actual_counter = Counter(); + + if (actual_counter>*counter_var+delay || actual_counter<*counter_var) + { + *counter_var = actual_counter; + return(TRUE); + } + else + return(FALSE); +} + unsigned long be2long(unsigned long *be) /* big-endian -> longword */ { unsigned char *ptr = (unsigned char *)be; @@ -83,63 +149,6 @@ char *GetLoginName() return(pwd->pw_name); } -static struct AnimInfo toon[NUM_TOONS] = -{ - DWARF_XSIZE, DWARF_YSIZE, - DWARF_X, DWARF_Y, - DWARF_FRAMES, - DWARF_FPS, - DWARF_STEPSIZE, - FALSE, - ANIMDIR_RIGHT, - ANIMPOS_DOWN, - - DWARF_XSIZE, DWARF_YSIZE, - DWARF_X, DWARF2_Y, - DWARF_FRAMES, - DWARF_FPS, - DWARF_STEPSIZE, - FALSE, - ANIMDIR_LEFT, - ANIMPOS_DOWN, - - JUMPER_XSIZE, JUMPER_YSIZE, - JUMPER_X, JUMPER_Y, - JUMPER_FRAMES, - JUMPER_FPS, - JUMPER_STEPSIZE, - FALSE, - ANIMDIR_LEFT, - ANIMPOS_DOWN, - - CLOWN_XSIZE, CLOWN_YSIZE, - CLOWN_X, CLOWN_Y, - CLOWN_FRAMES, - CLOWN_FPS, - CLOWN_STEPSIZE, - FALSE, - ANIMDIR_UP, - ANIMPOS_ANY, - - BIRD_XSIZE, BIRD_YSIZE, - BIRD1_X, BIRD1_Y, - BIRD_FRAMES, - BIRD_FPS, - BIRD_STEPSIZE, - TRUE, - ANIMDIR_RIGHT, - ANIMPOS_UPPER, - - BIRD_XSIZE, BIRD_YSIZE, - BIRD2_X, BIRD2_Y, - BIRD_FRAMES, - BIRD_FPS, - BIRD_STEPSIZE, - TRUE, - ANIMDIR_LEFT, - ANIMPOS_UPPER -}; - void InitAnimation() { HandleAnimation(ANIM_START); @@ -210,12 +219,68 @@ BOOL AnimateToon(int toon_nr, BOOL restart) static BOOL horiz_move, vert_move; static long anim_delay = 0; static int anim_delay_value = 0; - struct AnimInfo *anim = &toon[toon_nr]; static int width,height; static int pad_x,pad_y; static int cut_x,cut_y; static int src_x, src_y; static int dest_x, dest_y; + static struct AnimInfo toon[NUM_TOONS] = + { + DWARF_XSIZE, DWARF_YSIZE, + DWARF_X, DWARF_Y, + DWARF_FRAMES, + DWARF_FPS, + DWARF_STEPSIZE, + FALSE, + ANIMDIR_RIGHT, + ANIMPOS_DOWN, + + DWARF_XSIZE, DWARF_YSIZE, + DWARF_X, DWARF2_Y, + DWARF_FRAMES, + DWARF_FPS, + DWARF_STEPSIZE, + FALSE, + ANIMDIR_LEFT, + ANIMPOS_DOWN, + + JUMPER_XSIZE, JUMPER_YSIZE, + JUMPER_X, JUMPER_Y, + JUMPER_FRAMES, + JUMPER_FPS, + JUMPER_STEPSIZE, + FALSE, + ANIMDIR_LEFT, + ANIMPOS_DOWN, + + CLOWN_XSIZE, CLOWN_YSIZE, + CLOWN_X, CLOWN_Y, + CLOWN_FRAMES, + CLOWN_FPS, + CLOWN_STEPSIZE, + FALSE, + ANIMDIR_UP, + ANIMPOS_ANY, + + BIRD_XSIZE, BIRD_YSIZE, + BIRD1_X, BIRD1_Y, + BIRD_FRAMES, + BIRD_FPS, + BIRD_STEPSIZE, + TRUE, + ANIMDIR_RIGHT, + ANIMPOS_UPPER, + + BIRD_XSIZE, BIRD_YSIZE, + BIRD2_X, BIRD2_Y, + BIRD_FRAMES, + BIRD_FPS, + BIRD_STEPSIZE, + TRUE, + ANIMDIR_LEFT, + ANIMPOS_UPPER + }; + struct AnimInfo *anim = &toon[toon_nr]; if (restart) { @@ -348,6 +413,8 @@ void DrawAnim(int src_x, int src_y, int width, int height, { int buf_x = DOOR_GFX_PAGEX3, buf_y = DOOR_GFX_PAGEY1; +#if 1 + /* special method to avoid flickering interference with BackToFront() */ XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc,dest_x-pad_x,dest_y-pad_y, width+2*pad_x,height+2*pad_y, buf_x,buf_y); XSetClipOrigin(display,clip_gc[PIX_TOONS],dest_x-src_x,dest_y-src_y); @@ -355,13 +422,11 @@ void DrawAnim(int src_x, int src_y, int width, int height, src_x,src_y, width,height, dest_x,dest_y); XCopyArea(display,backbuffer,window,gc, dest_x-pad_x,dest_y-pad_y, width+2*pad_x,height+2*pad_y, dest_x-pad_x,dest_y-pad_y); - BackToFront(); - XCopyArea(display,pix[PIX_DB_DOOR],backbuffer,gc, buf_x,buf_y, width+2*pad_x,height+2*pad_y, dest_x-pad_x,dest_y-pad_y); - -/* +#else + /* normal method, causing flickering interference with BackToFront() */ XCopyArea(display,backbuffer,pix[PIX_DB_DOOR],gc,dest_x-pad_x,dest_y-pad_y, width+2*pad_x,height+2*pad_y, buf_x,buf_y); XSetClipOrigin(display,clip_gc[PIX_TOONS], @@ -370,7 +435,7 @@ void DrawAnim(int src_x, int src_y, int width, int height, src_x,src_y, width,height, buf_x+pad_x,buf_y+pad_y); XCopyArea(display,pix[PIX_DB_DOOR],window,gc, buf_x,buf_y, width+2*pad_x,height+2*pad_y, dest_x-pad_x,dest_y-pad_y); -*/ +#endif XFlush(display); } diff --git a/src/misc.h b/src/misc.h index c4cba8de..dba38015 100644 --- a/src/misc.h +++ b/src/misc.h @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * misc.h * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #ifndef MISC_H @@ -85,6 +83,14 @@ struct AnimInfo #define NEW_RANDOMIZE -1 void microsleep(unsigned long); +long mainCounter(int); +void InitCounter(void); +long Counter(void); +long Counter2(void); +void WaitCounter(long); +void WaitCounter2(long); +void Delay(long); +BOOL DelayReached(long *, int); unsigned long be2long(unsigned long *); char *int2str(int, int); unsigned int RND(unsigned int); diff --git a/src/screens.c b/src/screens.c index 2d5d17c1..5246fa82 100644 --- a/src/screens.c +++ b/src/screens.c @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * screens.c * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #include "screens.h" @@ -21,6 +19,8 @@ #include "tools.h" #include "editor.h" #include "misc.h" +#include "files.h" +#include "buttons.h" void DrawMainMenu() { @@ -244,8 +244,8 @@ static int helpscreen_action[] = GFX_FELSBROCKEN,4,5, HA_NEXT, GFX_BOMBE,1,50, GFX_EXPLOSION,8,1, GFX_LEERRAUM,1,10, HA_NEXT, GFX_KOKOSNUSS,1,50, GFX_CRACKINGNUT,3,1, GFX_EDELSTEIN,1,10, HA_NEXT, - GFX_ERZ_1,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT, - GFX_ERZ_2,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT, + GFX_ERZ_EDEL,1,50, GFX_EXPLOSION,8,1, GFX_EDELSTEIN,1,10, HA_NEXT, + GFX_ERZ_DIAM,1,50, GFX_EXPLOSION,8,1, GFX_DIAMANT,1,10, HA_NEXT, GFX_GEBLUBBER,4,4, HA_NEXT, GFX_SCHLUESSEL1,4,33, HA_NEXT, GFX_PFORTE1,4,33, HA_NEXT, @@ -452,7 +452,7 @@ void DrawHelpScreenMusicText(int num) PlaySoundLoop(background_loop[num]); } -void DrawHelpScreenRegistrationText() +void DrawHelpScreenCreditsText() { int ystart = 150, ystep = 30; char text[FULL_SXSIZE/FONT2_XSIZE+10]; @@ -463,13 +463,34 @@ void DrawHelpScreenRegistrationText() DrawText(SX+25+16, SY+46, "Copyright ^1995 by Holger Schemel", FS_SMALL,FC_RED); - sprintf(text,"Registration information:"); + sprintf(text,"Program information:"); DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+100, text,FS_SMALL,FC_GREEN); - sprintf(text,"Unregistered version"); - DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep, + sprintf(text,"This game is Freeware!"); + DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+0*ystep, + text,FS_SMALL,FC_YELLOW); + sprintf(text,"If you like it, send e-mail to:"); + DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+1*ystep, text,FS_SMALL,FC_YELLOW); + sprintf(text,"aeglos@valinor.owl.de"); + DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+2*ystep, + text,FS_SMALL,FC_RED); + sprintf(text,"or SnailMail to:"); + DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+3*ystep, + text,FS_SMALL,FC_YELLOW); + sprintf(text,"Holger Schemel"); + DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep, + text,FS_SMALL,FC_RED); + sprintf(text,"Sennehof 28"); + DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+20, + text,FS_SMALL,FC_RED); + sprintf(text,"33659 Bielefeld"); + DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+40, + text,FS_SMALL,FC_RED); + sprintf(text,"Germany"); + DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+ystart+4*ystep+60, + text,FS_SMALL,FC_RED); sprintf(text,"Press any key or button for main menu"); DrawText(SX+(SXSIZE-strlen(text)*FONT2_XSIZE)/2,SY+SYSIZE-20, @@ -520,7 +541,7 @@ void HandleHelpScreen(int button) else if (helpscreen_state==num_helpscreen_els_pages+num_bg_loops-1) { helpscreen_state++; - DrawHelpScreenRegistrationText(); + DrawHelpScreenCreditsText(); } else { @@ -609,6 +630,8 @@ void DrawChooseLevel() { int i; + CloseDoor(DOOR_CLOSE_2); + ClearWindow(); DrawText(SX,SY,"Level Directories",FS_BIG,FC_GREEN); for(i=0;i0 ? 13 : 11); + if (y==13) + y = (dy>0 ? 14 : 12); if (y<3) y = 3; - else if (y>14) - y = 14; + else if (y>15) + y = 15; } if (!mx && !my && !dx && !dy) @@ -835,7 +865,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) y = choice; } - if (x==1 && y>=3 && y<=14 && y!=12) + if (x==1 && y>=3 && y<=15 && y!=13) { if (button) { @@ -899,6 +929,14 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) player.setup ^= SETUP_FADING; } else if (y==9) + { + if (SETUP_QUICK_DOORS_ON(player.setup)) + DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); + else + DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); + player.setup ^= SETUP_QUICK_DOORS; + } + else if (y==10) { if (SETUP_RECORD_EACH_GAME_ON(player.setup)) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -906,7 +944,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); player.setup ^= SETUP_RECORD_EACH_GAME; } - else if (y==10) + else if (y==11) { if (SETUP_2ND_JOYSTICK_ON(player.setup)) DrawText(SX+14*32, SY+yy*32,"1st",FS_BIG,FC_YELLOW); @@ -914,14 +952,14 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"2nd",FS_BIG,FC_YELLOW); player.setup ^= SETUP_2ND_JOYSTICK; } - else if (y==11) + else if (y==12) { CalibrateJoystick(); redraw = TRUE; } - else if (y==13 || y==14) + else if (y==14 || y==15) { - if (y==14) + if (y==15) { SavePlayerInfo(PLAYER_SETUP); SaveJoystickData(); @@ -939,6 +977,133 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DoAnimation(); } +void CalibrateJoystick() +{ +#ifdef __FreeBSD__ + struct joystick joy_ctrl; +#else + struct joystick_control + { + int buttons; + int x; + int y; + } joy_ctrl; +#endif + + int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle; + int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle; + + if (joystick_status==JOYSTICK_OFF) + goto error_out; + + ClearWindow(); + DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW); + DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW); + DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW); + BackToFront(); + +#ifdef __FreeBSD__ + joy_ctrl.b1 = joy_ctrl.b2 = 0; +#else + joy_ctrl.buttons = 0; +#endif + while(Joystick() & JOY_BUTTON); +#ifdef __FreeBSD__ + while(!(joy_ctrl.b1||joy_ctrl.b2)) +#else + while(!joy_ctrl.buttons) +#endif + { + if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) + { + joystick_status=JOYSTICK_OFF; + goto error_out; + } + Delay(10000); + } + + new_joystick_xleft = joy_ctrl.x; + new_joystick_yupper = joy_ctrl.y; + + ClearWindow(); + DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW); + DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW); + DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW); + BackToFront(); + +#ifdef __FreeBSD__ + joy_ctrl.b1 = joy_ctrl.b2 = 0; +#else + joy_ctrl.buttons = 0; +#endif + while(Joystick() & JOY_BUTTON); +#ifdef __FreeBSD__ + while(!(joy_ctrl.b1||joy_ctrl.b2)) +#else + while(!joy_ctrl.buttons) +#endif + { + if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) + { + joystick_status=JOYSTICK_OFF; + goto error_out; + } + Delay(10000); + } + + new_joystick_xright = joy_ctrl.x; + new_joystick_ylower = joy_ctrl.y; + + ClearWindow(); + DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW); + DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW); + BackToFront(); + +#ifdef __FreeBSD__ + joy_ctrl.b1 = joy_ctrl.b2 = 0; +#else + joy_ctrl.buttons = 0; +#endif + while(Joystick() & JOY_BUTTON); +#ifdef __FreeBSD__ + while(!(joy_ctrl.b1||joy_ctrl.b2)) +#else + while(!joy_ctrl.buttons) +#endif + { + if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) + { + joystick_status=JOYSTICK_OFF; + goto error_out; + } + Delay(10000); + } + + new_joystick_xmiddle = joy_ctrl.x; + new_joystick_ymiddle = joy_ctrl.y; + + joystick[joystick_nr].xleft = new_joystick_xleft; + joystick[joystick_nr].yupper = new_joystick_yupper; + joystick[joystick_nr].xright = new_joystick_xright; + joystick[joystick_nr].ylower = new_joystick_ylower; + joystick[joystick_nr].xmiddle = new_joystick_xmiddle; + joystick[joystick_nr].ymiddle = new_joystick_ymiddle; + + CheckJoystickData(); + + DrawSetupScreen(); + while(Joystick() & JOY_BUTTON); + return; + + error_out: + + ClearWindow(); + DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW); + DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW); + Delay(3000000); + DrawSetupScreen(); +} + void HandleVideoButtons(int mx, int my, int button) { if (game_status!=MAINMENU && game_status!=PLAYING) @@ -1079,307 +1244,3 @@ void HandleGameButtons(int mx, int my, int button) break; } } - -int CheckVideoButtons(int mx, int my, int button) -{ - int return_code = 0; - static int choice = -1; - static BOOL pressed = FALSE; - static int video_button[5] = - { - VIDEO_PRESS_EJECT_ON, - VIDEO_PRESS_STOP_ON, - VIDEO_PRESS_PAUSE_ON, - VIDEO_PRESS_REC_ON, - VIDEO_PRESS_PLAY_ON - }; - - if (button) - { - if (!motion_status) /* Maustaste neu gedrückt */ - { - if (ON_VIDEO_BUTTON(mx,my)) - { - choice = VIDEO_BUTTON(mx); - pressed = TRUE; - DrawVideoDisplay(video_button[choice],0); - } - } - else /* Mausbewegung bei gedrückter Maustaste */ - { - if ((!ON_VIDEO_BUTTON(mx,my) || VIDEO_BUTTON(mx)!=choice) && - choice>=0 && pressed) - { - pressed = FALSE; - DrawVideoDisplay(video_button[choice]<<1,0); - } - else if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && !pressed) - { - pressed = TRUE; - DrawVideoDisplay(video_button[choice],0); - } - } - } - else /* Maustaste wieder losgelassen */ - { - if (ON_VIDEO_BUTTON(mx,my) && VIDEO_BUTTON(mx)==choice && pressed) - { - DrawVideoDisplay(video_button[choice]<<1,0); - return_code = choice+1; - choice = -1; - pressed = FALSE; - } - else - { - choice = -1; - pressed = FALSE; - } - } - - BackToFront(); - return(return_code); -} - -int CheckSoundButtons(int mx, int my, int button) -{ - int return_code = 0; - static int choice = -1; - static BOOL pressed = FALSE; - int sound_state[3]; - - sound_state[0] = BUTTON_SOUND_MUSIC | (BUTTON_ON * sound_music_on); - sound_state[1] = BUTTON_SOUND_LOOPS | (BUTTON_ON * sound_loops_on); - sound_state[2] = BUTTON_SOUND_SOUND | (BUTTON_ON * sound_on); - - if (button) - { - if (!motion_status) /* Maustaste neu gedrückt */ - { - if (ON_SOUND_BUTTON(mx,my)) - { - choice = SOUND_BUTTON(mx); - pressed = TRUE; - DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED); - } - } - else /* Mausbewegung bei gedrückter Maustaste */ - { - if ((!ON_SOUND_BUTTON(mx,my) || SOUND_BUTTON(mx)!=choice) && - choice>=0 && pressed) - { - pressed = FALSE; - DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED); - } - else if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && !pressed) - { - pressed = TRUE; - DrawSoundDisplay(sound_state[choice] | BUTTON_PRESSED); - } - } - } - else /* Maustaste wieder losgelassen */ - { - if (ON_SOUND_BUTTON(mx,my) && SOUND_BUTTON(mx)==choice && pressed) - { - DrawSoundDisplay(sound_state[choice] | BUTTON_RELEASED); - return_code = 1<=0 && pressed) - { - pressed = FALSE; - DrawGameButton(game_state[choice] | BUTTON_RELEASED); - } - else if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && !pressed) - { - pressed = TRUE; - DrawGameButton(game_state[choice] | BUTTON_PRESSED); - } - } - } - else /* Maustaste wieder losgelassen */ - { - if (ON_GAME_BUTTON(mx,my) && GAME_BUTTON(mx)==choice && pressed) - { - DrawGameButton(game_state[choice] | BUTTON_RELEASED); - return_code = 1<=0 && pressed) - { - pressed = FALSE; - DrawChooseButton(choose_button[choice] | BUTTON_RELEASED); - } - else if (ON_CHOOSE_BUTTON(mx,my) &&CHOOSE_BUTTON(mx)==choice && !pressed) - { - pressed = TRUE; - DrawChooseButton(choose_button[choice] | BUTTON_PRESSED); - } - } - } - else /* Maustaste wieder losgelassen */ - { - if (ON_CHOOSE_BUTTON(mx,my) && CHOOSE_BUTTON(mx)==choice && pressed) - { - DrawChooseButton(choose_button[choice] | BUTTON_RELEASED); - return_code = choice+1; - choice = -1; - pressed = FALSE; - } - else - { - choice = -1; - pressed = FALSE; - } - } - - BackToFront(); - return(return_code); -} - -int CheckConfirmButton(int mx, int my, int button) -{ - int return_code = 0; - static int choice = -1; - static BOOL pressed = FALSE; - - if (button) - { - if (!motion_status) /* Maustaste neu gedrückt */ - { - if (ON_CONFIRM_BUTTON(mx,my)) - { - choice = 0; - pressed = TRUE; - DrawConfirmButton(BUTTON_PRESSED); - } - } - else /* Mausbewegung bei gedrückter Maustaste */ - { - if (!ON_CONFIRM_BUTTON(mx,my) && choice>=0 && pressed) - { - pressed = FALSE; - DrawConfirmButton(BUTTON_RELEASED); - } - else if (ON_CONFIRM_BUTTON(mx,my) && !pressed) - { - pressed = TRUE; - DrawConfirmButton(BUTTON_PRESSED); - } - } - } - else /* Maustaste wieder losgelassen */ - { - if (ON_CONFIRM_BUTTON(mx,my) && pressed) - { - DrawConfirmButton(BUTTON_RELEASED); - return_code = BUTTON_CONFIRM; - choice = -1; - pressed = FALSE; - } - else - { - choice = -1; - pressed = FALSE; - } - } - - BackToFront(); - return(return_code); -} - -void DrawCompleteVideoDisplay() -{ - XCopyArea(display,pix[PIX_DOOR],drawto,gc, - DOOR_GFX_PAGEX3,DOOR_GFX_PAGEY2, VXSIZE,VYSIZE, VX,VY); - XCopyArea(display,pix[PIX_DOOR],drawto,gc, - DOOR_GFX_PAGEX4+VIDEO_CONTROL_XPOS, - DOOR_GFX_PAGEY2+VIDEO_CONTROL_YPOS, - VIDEO_CONTROL_XSIZE,VIDEO_CONTROL_YSIZE, - VX+VIDEO_CONTROL_XPOS,VY+VIDEO_CONTROL_YPOS); - - DrawVideoDisplay(VIDEO_ALL_OFF,0); - if (tape.date && tape.length) - { - DrawVideoDisplay(VIDEO_STATE_DATE_ON,tape.date); - DrawVideoDisplay(VIDEO_STATE_TIME_ON,0); - } - - XCopyArea(display,drawto,pix[PIX_DB_DOOR],gc, - VX,VY, VXSIZE,VYSIZE, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2); -} diff --git a/src/screens.h b/src/screens.h index c76ade75..32a58401 100644 --- a/src/screens.h +++ b/src/screens.h @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * screens.h * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #ifndef SCREENS_H @@ -19,37 +17,12 @@ #include "main.h" -/* Setup-Bits */ -#define SETUP_TOONS (1<<0) -#define SETUP_SOUND (1<<1) -#define SETUP_SOUND_LOOPS (1<<2) -#define SETUP_SOUND_MUSIC (1<<3) -#define SETUP_DIRECT_DRAW (1<<4) -#define SETUP_FADING (1<<5) -#define SETUP_RECORD_EACH_GAME (1<<6) -#define SETUP_2ND_JOYSTICK (1<<7) - -#define DEFAULT_SETUP (SETUP_TOONS | \ - SETUP_SOUND | \ - SETUP_SOUND_LOOPS | \ - SETUP_SOUND_MUSIC) - -/* Setup-Voreinstellungen */ -#define SETUP_TOONS_ON(x) (((x) & SETUP_TOONS) != 0) -#define SETUP_SOUND_ON(x) (((x) & SETUP_SOUND) != 0) -#define SETUP_SOUND_LOOPS_ON(x) (((x) & SETUP_SOUND_LOOPS) != 0) -#define SETUP_SOUND_MUSIC_ON(x) (((x) & SETUP_SOUND_MUSIC) != 0) -#define SETUP_DIRECT_DRAW_ON(x) (((x) & SETUP_DIRECT_DRAW) != 0) -#define SETUP_FADING_ON(x) (((x) & SETUP_FADING) != 0) -#define SETUP_RECORD_EACH_GAME_ON(x) (((x) & SETUP_RECORD_EACH_GAME) != 0) -#define SETUP_2ND_JOYSTICK_ON(x) (((x) & SETUP_2ND_JOYSTICK) != 0) - void DrawMainMenu(); void HandleMainMenu(int, int, int, int, int); void DrawHelpScreenElAction(int); void DrawHelpScreenElText(int); void DrawHelpScreenMusicText(int); -void DrawHelpScreenRegistrationText(void); +void DrawHelpScreenCreditsText(void); void DrawHelpScreen(); void HandleHelpScreen(int); void HandleTypeName(int, KeySym); @@ -59,14 +32,9 @@ void DrawHallOfFame(int); void HandleHallOfFame(int); void DrawSetupScreen(); void HandleSetupScreen(int, int, int, int, int); +void CalibrateJoystick(void); void HandleVideoButtons(int, int, int); void HandleSoundButtons(int, int, int); void HandleGameButtons(int, int, int); -int CheckVideoButtons(int, int, int); -int CheckSoundButtons(int, int, int); -int CheckGameButtons(int, int, int); -int CheckChooseButtons(int, int, int); -int CheckConfirmButton(int, int, int); -void DrawCompleteVideoDisplay(void); #endif diff --git a/src/sound.c b/src/sound.c index b234a890..dc14ad55 100644 --- a/src/sound.c +++ b/src/sound.c @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * sound.c * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #include "sound.h" diff --git a/src/sound.h b/src/sound.h index be853f8c..384f77cf 100644 --- a/src/sound.h +++ b/src/sound.h @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * sound.c * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #ifndef SOUND_H @@ -29,6 +27,10 @@ extern void ioctl(long, long, void *); #endif +#ifdef __FreeBSD__ +#include +#endif + #define SND_BLOCKSIZE 4096 #ifdef _HPUX_SOURCE diff --git a/src/tools.c b/src/tools.c index f1d2e259..625159f3 100644 --- a/src/tools.c +++ b/src/tools.c @@ -10,16 +10,19 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * tools.c * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ +#ifdef __FreeBSD__ +#include +#endif + #include "tools.h" #include "game.h" #include "events.h" #include "sound.h" -#include "screens.h" #include "misc.h" +#include "buttons.h" +#include void BackToFront() { @@ -116,6 +119,35 @@ void FadeToFront() if (fading_on && (redraw_mask & REDRAW_FIELD)) { + +/* + int x,y; + + XFillRectangle(display,window,gc, + REAL_SX,REAL_SY,FULL_SXSIZE,FULL_SYSIZE); + XFlush(display); + + for(i=0;i<2*FULL_SYSIZE;i++) + { + for(y=0;y14) - { - XSetClipOrigin(display,clip_gc[PIX_DOOR],DX-i,DY); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE+14,30,i-14,DYSIZE-60,DX+DXSIZE+14-i,DY+30); - XSetClipOrigin(display,clip_gc[PIX_DOOR],DX-DXSIZE+i,DY); - XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - DXSIZE-i,30,i-14,DYSIZE-60,DX,DY+30); - } + DXSIZE-i,DOOR_GFX_PAGEY1+140, i,63, DX,DY+140-j); + + XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], + DXSIZE-i,DOOR_GFX_PAGEY1+77, i,63, + DX,DY+77-j); + XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], + DXSIZE-i,DOOR_GFX_PAGEY1+203, i,77, + DX,DY+203-j); + XSetClipOrigin(display,clip_gc[PIX_DOOR], + DX-i,(DY+j)-DOOR_GFX_PAGEY1); + XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], + DXSIZE,DOOR_GFX_PAGEY1+77, i,63, + DX+DXSIZE-i,DY+77+j); + XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], + DXSIZE,DOOR_GFX_PAGEY1+203, i,77-j, + DX+DXSIZE-i,DY+203+j); + redraw_mask |= REDRAW_DOOR_1; } if (door_state & DOOR_ACTION_2) { int i = (door_state & DOOR_OPEN_2 ? VXSIZE-x : x); + int j = (VXSIZE - i)/3; XCopyArea(display,pix[PIX_DB_DOOR],drawto,gc, DOOR_GFX_PAGEX1,DOOR_GFX_PAGEY2+i/2, @@ -1160,19 +1098,28 @@ void MoveDoor(unsigned int door_state) XFillRectangle(display,drawto,gc,VX,VY+VYSIZE-i/2,VXSIZE,i/2); XSetClipOrigin(display,clip_gc[PIX_DOOR], - VX-VXSIZE+i,VY-DOOR_GFX_PAGEY2); + VX-i,(VY+j)-DOOR_GFX_PAGEY2); + XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], + VXSIZE,DOOR_GFX_PAGEY2, i,VYSIZE/2, VX+VXSIZE-i,VY+j); + XSetClipOrigin(display,clip_gc[PIX_DOOR], + VX-VXSIZE+i,VY-(DOOR_GFX_PAGEY2+j)); + XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], + VXSIZE-i,DOOR_GFX_PAGEY2+j, i,VYSIZE/2-j, VX,VY); + XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - VXSIZE-i,DOOR_GFX_PAGEY2, i,VYSIZE, VX,VY); + VXSIZE-i,DOOR_GFX_PAGEY2+VYSIZE/2, i,VYSIZE/2, + VX,VY+VYSIZE/2-j); XSetClipOrigin(display,clip_gc[PIX_DOOR], - VX-i,VY-DOOR_GFX_PAGEY2); + VX-i,(VY+j)-DOOR_GFX_PAGEY2); XCopyArea(display,pix[PIX_DOOR],drawto,clip_gc[PIX_DOOR], - VXSIZE,DOOR_GFX_PAGEY2, i,VYSIZE, VX+VXSIZE-i,VY); + VXSIZE,DOOR_GFX_PAGEY2+VYSIZE/2, i,VYSIZE/2-j, + VX+VXSIZE-i,VY+VYSIZE/2+j); redraw_mask |= REDRAW_DOOR_2; } BackToFront(); - Delay(stepsize*5000); + Delay(door_anim_delay); if (game_status==MAINMENU) DoAnimation(); @@ -1185,74 +1132,6 @@ void MoveDoor(unsigned int door_state) door2 = door_state & DOOR_ACTION_2; } -long mainCounter(int mode) -{ - static struct timeval base_time = { 0, 0 }; - struct timeval current_time; - long counter_ms; - - gettimeofday(¤t_time,NULL); - if (mode==0 || current_time.tv_sec0) - microsleep(wait*10000); -} - -void WaitCounter2(long value) /* wait for counter to reach value */ -{ - long wait; - - while((wait=value-Counter2())>0) - microsleep(wait*1000); -} - -void Delay(long value) -{ - microsleep(value); -} - -BOOL DelayReached(long *counter_var, int delay) -{ - long actual_counter = Counter(); - - if (actual_counter>*counter_var+delay || actual_counter<*counter_var) - { - *counter_var = actual_counter; - return(TRUE); - } - else - return(FALSE); -} - int ReadPixel(Drawable d, int x, int y) { static XImage *pixelimage; @@ -1261,78 +1140,6 @@ int ReadPixel(Drawable d, int x, int y) return(XGetPixel(pixelimage,0,0)); } -static struct JoystickInfo joystick[2] = -{ - JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE, - JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE, - - JOYSTICK_XLEFT, JOYSTICK_XRIGHT, JOYSTICK_XMIDDLE, - JOYSTICK_YUPPER, JOYSTICK_YLOWER, JOYSTICK_YMIDDLE -}; - -void LoadJoystickData() -{ - int i; - char cookie[256]; - FILE *file; - - if (joystick_status==JOYSTICK_OFF) - return; - - if (!(file=fopen(JOYDAT_FILE,"r"))) - return; - - fscanf(file,"%s",cookie); - if (strcmp(cookie,JOYSTICK_COOKIE)) /* ungültiges Format? */ - { - fprintf(stderr,"%s: wrong format of joystick file!\n",progname); - fclose(file); - return; - } - - for(i=0;i<2;i++) - { - fscanf(file,"%s",cookie); - fscanf(file, "%d %d %d \n", - &joystick[i].xleft, &joystick[i].xmiddle, &joystick[i].xright); - fscanf(file, "%d %d %d \n", - &joystick[i].yupper, &joystick[i].ymiddle, &joystick[i].ylower); - } - fclose(file); - - CheckJoystickData(); -} - -void SaveJoystickData() -{ - int i; - FILE *file; - - if (joystick_status==JOYSTICK_OFF) - return; - - CheckJoystickData(); - - if (!(file=fopen(JOYDAT_FILE,"w"))) - { - fprintf(stderr,"%s: cannot save joystick calibration data!\n",progname); - return; - } - - fprintf(file,"%s\n",JOYSTICK_COOKIE); /* Formatkennung */ - for(i=0;i<2;i++) - { - fprintf(file,"JOYSTICK_%d_DATA\n",i); - fprintf(file, "%d %d %d \n", - joystick[i].xleft, joystick[i].xmiddle, joystick[i].xright); - fprintf(file, "%d %d %d \n", - joystick[i].yupper, joystick[i].ymiddle, joystick[i].ylower); - } - fclose(file); - - chmod(JOYDAT_FILE, JOYDAT_PERMS); -} - void CheckJoystickData() { int i; @@ -1367,23 +1174,27 @@ int JoystickPosition(int middle, int margin, int actual) if (margin>middle && actual100) - percentage=100; + percentage = 100; return(percentage); } int Joystick() { +#ifdef __FreeBSD__ + struct joystick joy_ctrl; +#else struct joystick_control { int buttons; int x; int y; } joy_ctrl; +#endif int js_x,js_y, js_b1,js_b2; int left, right, up, down; @@ -1394,15 +1205,21 @@ int Joystick() if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) { - fprintf(stderr,"%s: cannot read joystick settings - no joystick support\n",progname); + fprintf(stderr,"%s: cannot read joystick settings - no joystick support\n", + progname); joystick_status = JOYSTICK_OFF; return(0); } js_x = joy_ctrl.x; js_y = joy_ctrl.y; +#ifdef __FreeBSD__ + js_b1 = joy_ctrl.b1; + js_b2 = joy_ctrl.b2; +#else js_b1 = joy_ctrl.buttons & 1; js_b2 = joy_ctrl.buttons & 2; +#endif left = JoystickPosition(joystick[joystick_nr].xmiddle, joystick[joystick_nr].xleft, js_x); @@ -1431,124 +1248,118 @@ int Joystick() int JoystickButton() { - static int last_joy_button=0; - int joy_button=(Joystick() & JOY_BUTTON); + static int last_joy_button = 0; + int joy_button = (Joystick() & JOY_BUTTON); int result; if (joy_button) { if (last_joy_button) - result=JOY_BUTTON_PRESSED; + result = JOY_BUTTON_PRESSED; else - result=JOY_BUTTON_NEW_PRESSED; + result = JOY_BUTTON_NEW_PRESSED; } else { if (last_joy_button) - result=JOY_BUTTON_NEW_RELEASED; + result = JOY_BUTTON_NEW_RELEASED; else - result=JOY_BUTTON_NOT_PRESSED; + result = JOY_BUTTON_NOT_PRESSED; } last_joy_button = joy_button; return(result); } -void CalibrateJoystick() +int el2gfx(int element) { - struct joystick_control - { - int buttons; - int x; - int y; - } joy_ctrl; - - int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle; - int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle; - - if (joystick_status==JOYSTICK_OFF) - goto error_out; - - ClearWindow(); - DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW); - DrawText(SX+16, SY+8*32, " THE UPPER LEFT ",FS_BIG,FC_YELLOW); - DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW); - BackToFront(); - - joy_ctrl.buttons = 0; - while(Joystick() & JOY_BUTTON); - while(!joy_ctrl.buttons) - { - if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) - { - joystick_status=JOYSTICK_OFF; - goto error_out; - } - Delay(10000); - } - - new_joystick_xleft = joy_ctrl.x; - new_joystick_yupper = joy_ctrl.y; - - ClearWindow(); - DrawText(SX+16, SY+7*32, "MOVE JOYSTICK TO",FS_BIG,FC_YELLOW); - DrawText(SX+32, SY+8*32, "THE LOWER RIGHT",FS_BIG,FC_YELLOW); - DrawText(SX+16, SY+9*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW); - BackToFront(); - - joy_ctrl.buttons = 0; - while(Joystick() & JOY_BUTTON); - while(!joy_ctrl.buttons) - { - if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) - { - joystick_status=JOYSTICK_OFF; - goto error_out; - } - Delay(10000); - } - - new_joystick_xright = joy_ctrl.x; - new_joystick_ylower = joy_ctrl.y; - - ClearWindow(); - DrawText(SX+32, SY+16+7*32, "CENTER JOYSTICK",FS_BIG,FC_YELLOW); - DrawText(SX+16, SY+16+8*32, "AND PRESS BUTTON",FS_BIG,FC_YELLOW); - BackToFront(); - - joy_ctrl.buttons = 0; - while(Joystick() & JOY_BUTTON); - while(!joy_ctrl.buttons) + switch(element) { - if (read(joystick_device, &joy_ctrl, sizeof(joy_ctrl)) != sizeof(joy_ctrl)) + case EL_LEERRAUM: return(-1); + case EL_ERDREICH: return(GFX_ERDREICH); + case EL_MAUERWERK: return(GFX_MAUERWERK); + case EL_FELSBODEN: return(GFX_FELSBODEN); + case EL_FELSBROCKEN: return(GFX_FELSBROCKEN); + case EL_SCHLUESSEL: return(GFX_SCHLUESSEL); + case EL_EDELSTEIN: return(GFX_EDELSTEIN); + case EL_AUSGANG_ZU: return(GFX_AUSGANG_ZU); + case EL_AUSGANG_ACT: return(GFX_AUSGANG_ACT); + case EL_AUSGANG_AUF: return(GFX_AUSGANG_AUF); + case EL_SPIELFIGUR: return(GFX_SPIELFIGUR); + case EL_SPIELER1: return(GFX_SPIELER1); + case EL_SPIELER2: return(GFX_SPIELER2); + case EL_SPIELER3: return(GFX_SPIELER3); + case EL_SPIELER4: return(GFX_SPIELER4); + case EL_KAEFER: return(GFX_KAEFER); + case EL_KAEFER_R: return(GFX_KAEFER_R); + case EL_KAEFER_O: return(GFX_KAEFER_O); + case EL_KAEFER_L: return(GFX_KAEFER_L); + case EL_KAEFER_U: return(GFX_KAEFER_U); + case EL_FLIEGER: return(GFX_FLIEGER); + case EL_FLIEGER_R: return(GFX_FLIEGER_R); + case EL_FLIEGER_O: return(GFX_FLIEGER_O); + case EL_FLIEGER_L: return(GFX_FLIEGER_L); + case EL_FLIEGER_U: return(GFX_FLIEGER_U); + case EL_MAMPFER: return(GFX_MAMPFER); + case EL_ZOMBIE: return(GFX_ZOMBIE); + case EL_BETON: return(GFX_BETON); + case EL_DIAMANT: return(GFX_DIAMANT); + case EL_MORAST_LEER: return(GFX_MORAST_LEER); + case EL_MORAST_VOLL: return(GFX_MORAST_VOLL); + case EL_TROPFEN: return(GFX_TROPFEN); + case EL_BOMBE: return(GFX_BOMBE); + case EL_SIEB_LEER: return(GFX_SIEB_LEER); + case EL_SIEB_VOLL: return(GFX_SIEB_VOLL); + case EL_SIEB_TOT: return(GFX_SIEB_TOT); + case EL_SALZSAEURE: return(GFX_SALZSAEURE); + case EL_AMOEBE_TOT: return(GFX_AMOEBE_TOT); + case EL_AMOEBE_NASS: return(GFX_AMOEBE_NASS); + case EL_AMOEBE_NORM: return(GFX_AMOEBE_NORM); + case EL_AMOEBE_VOLL: return(GFX_AMOEBE_VOLL); + case EL_AMOEBA2DIAM: return(GFX_AMOEBA2DIAM); + case EL_KOKOSNUSS: return(GFX_KOKOSNUSS); + case EL_LIFE: return(GFX_LIFE); + case EL_LIFE_ASYNC: return(GFX_LIFE_ASYNC); + case EL_DYNAMIT: return(GFX_DYNAMIT); + case EL_BADEWANNE: return(GFX_BADEWANNE); + case EL_BADEWANNE1: return(GFX_BADEWANNE1); + case EL_BADEWANNE2: return(GFX_BADEWANNE2); + case EL_BADEWANNE3: return(GFX_BADEWANNE3); + case EL_BADEWANNE4: return(GFX_BADEWANNE4); + case EL_BADEWANNE5: return(GFX_BADEWANNE5); + case EL_ABLENK_AUS: return(GFX_ABLENK_AUS); + case EL_ABLENK_EIN: return(GFX_ABLENK_EIN); + case EL_SCHLUESSEL1: return(GFX_SCHLUESSEL1); + case EL_SCHLUESSEL2: return(GFX_SCHLUESSEL2); + case EL_SCHLUESSEL3: return(GFX_SCHLUESSEL3); + case EL_SCHLUESSEL4: return(GFX_SCHLUESSEL4); + case EL_PFORTE1: return(GFX_PFORTE1); + case EL_PFORTE2: return(GFX_PFORTE2); + case EL_PFORTE3: return(GFX_PFORTE3); + case EL_PFORTE4: return(GFX_PFORTE4); + case EL_PFORTE1X: return(GFX_PFORTE1X); + case EL_PFORTE2X: return(GFX_PFORTE2X); + case EL_PFORTE3X: return(GFX_PFORTE3X); + case EL_PFORTE4X: return(GFX_PFORTE4X); + case EL_DYNAMIT_AUS: return(GFX_DYNAMIT_AUS); + case EL_PACMAN: return(GFX_PACMAN); + case EL_PACMAN_R: return(GFX_PACMAN_R); + case EL_PACMAN_O: return(GFX_PACMAN_O); + case EL_PACMAN_L: return(GFX_PACMAN_L); + case EL_PACMAN_U: return(GFX_PACMAN_U); + case EL_UNSICHTBAR: return(GFX_UNSICHTBAR); + case EL_ERZ_EDEL: return(GFX_ERZ_EDEL); + case EL_ERZ_DIAM: return(GFX_ERZ_DIAM); + case EL_BIRNE_AUS: return(GFX_BIRNE_AUS); + case EL_BIRNE_EIN: return(GFX_BIRNE_EIN); + case EL_ZEIT_VOLL: return(GFX_ZEIT_VOLL); + case EL_ZEIT_LEER: return(GFX_ZEIT_LEER); + default: { - joystick_status=JOYSTICK_OFF; - goto error_out; + if (IS_CHAR(element)) + return(GFX_CHAR_START + (element-EL_CHAR_START)); + else + return(-1); } - Delay(10000); } - - new_joystick_xmiddle = joy_ctrl.x; - new_joystick_ymiddle = joy_ctrl.y; - - joystick[joystick_nr].xleft = new_joystick_xleft; - joystick[joystick_nr].yupper = new_joystick_yupper; - joystick[joystick_nr].xright = new_joystick_xright; - joystick[joystick_nr].ylower = new_joystick_ylower; - joystick[joystick_nr].xmiddle = new_joystick_xmiddle; - joystick[joystick_nr].ymiddle = new_joystick_ymiddle; - - CheckJoystickData(); - - DrawSetupScreen(); - while(Joystick() & JOY_BUTTON); - return; - - error_out: - - ClearWindow(); - DrawText(SX+16, SY+16, "NO JOYSTICK",FS_BIG,FC_YELLOW); - DrawText(SX+16, SY+48, " AVAILABLE ",FS_BIG,FC_YELLOW); - Delay(3000000); - DrawSetupScreen(); } diff --git a/src/tools.h b/src/tools.h index b3fa84e4..bec22056 100644 --- a/src/tools.h +++ b/src/tools.h @@ -10,8 +10,6 @@ * q99492@pbhrzx.uni-paderborn.de * *----------------------------------------------------------* * tools.h * -* * -* Letzte Aenderung: 15.06.1995 * ***********************************************************/ #ifndef TOOLS_H @@ -62,7 +60,6 @@ void DrawElementThruMask(int, int, int); void DrawMiniGraphic(int, int, int); void DrawMiniGraphicExt(Drawable, GC, int, int, int); void DrawMiniGraphicExtHiRes(Drawable, GC, int, int, int); -int el2gfx(int); void DrawGraphicShifted(int, int, int, int, int, int); void DrawElementShifted(int, int, int, int, int, int); void ErdreichAnbroeckeln(int, int); @@ -80,22 +77,11 @@ BOOL AreYouSure(char *, unsigned int); void OpenDoor(unsigned int); void CloseDoor(unsigned int); void MoveDoor(unsigned int); -long mainCounter(int); -void InitCounter(void); -long Counter(void); -long Counter2(void); -void WaitCounter(long); -void WaitCounter2(long); -void Delay(long); -BOOL DelayReached(long *, int); int ReadPixel(Drawable, int, int); -int el2gfx(int); -void LoadJoystickData(void); -void SaveJoystickData(void); void CheckJoystickData(void); int JoystickPosition(int, int, int); int Joystick(void); int JoystickButton(void); -void CalibrateJoystick(void); +int el2gfx(int); #endif -- 2.34.1