X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame_mm%2Fmm_game.c;h=6da722c13dd62de101a7a4c391442286dc2df383;hp=7d22eb30013d94876aed548f120b7846243f9270;hb=a29d462b1da802456be5d55e67337541aa0cbcc5;hpb=14801844faf14be284c590b66f030c6bf7cea5c2 diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index 7d22eb30..6da722c1 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -17,19 +17,19 @@ #include "mm_game.h" #include "mm_tools.h" -/* graphic position values for game controls */ +// graphic position values for game controls #define ENERGY_XSIZE 32 #define ENERGY_YSIZE MAX_LASER_ENERGY #define OVERLOAD_XSIZE ENERGY_XSIZE #define OVERLOAD_YSIZE MAX_LASER_OVERLOAD -/* values for Explode_MM() */ +// values for Explode_MM() #define EX_PHASE_START 0 #define EX_NORMAL 0 #define EX_KETTLE 1 #define EX_SHORT 2 -/* special positions in the game control window (relative to control window) */ +// special positions in the game control window (relative to control window) #define XX_LEVEL 36 #define YY_LEVEL 23 #define XX_KETTLES 29 @@ -41,7 +41,7 @@ #define XX_OVERLOAD 60 #define YY_OVERLOAD YY_ENERGY -/* special positions in the game control window (relative to main window) */ +// special positions in the game control window (relative to main window) #define DX_LEVEL (DX + XX_LEVEL) #define DY_LEVEL (DY + YY_LEVEL) #define DX_KETTLES (DX + XX_KETTLES) @@ -56,20 +56,20 @@ #define IS_LOOP_SOUND(s) ((s) == SND_FUEL) #define IS_MUSIC_SOUND(s) ((s) == SND_TYGER || (s) == SND_VOYAGER) -/* game button identifiers */ +// game button identifiers #define GAME_CTRL_ID_LEFT 0 #define GAME_CTRL_ID_MIDDLE 1 #define GAME_CTRL_ID_RIGHT 2 #define NUM_GAME_BUTTONS 3 -/* values for DrawLaser() */ +// values for DrawLaser() #define DL_LASER_DISABLED 0 #define DL_LASER_ENABLED 1 -/* values for 'click_delay_value' in ClickElement() */ -#define CLICK_DELAY_FIRST 12 /* delay (frames) after first click */ -#define CLICK_DELAY 6 /* delay (frames) for pressed butten */ +// values for 'click_delay_value' in ClickElement() +#define CLICK_DELAY_FIRST 12 // delay (frames) after first click +#define CLICK_DELAY 6 // delay (frames) for pressed butten #define AUTO_ROTATE_DELAY CLICK_DELAY #define INIT_GAME_ACTIONS_DELAY (ONE_SECOND_DELAY / GAME_FRAME_DELAY) @@ -90,7 +90,7 @@ program.headless = last_headless; \ } \ -/* forward declaration for internal use */ +// forward declaration for internal use static int MovingOrBlocked2Element_MM(int, int); static void Bang_MM(int, int); static void RaiseScore_MM(int); @@ -100,23 +100,23 @@ static void InitMovingField_MM(int, int, int); static void ContinueMoving_MM(int, int); static void Moving2Blocked_MM(int, int, int *, int *); -/* bitmap for laser beam detection */ +// bitmap for laser beam detection static Bitmap *laser_bitmap = NULL; -/* variables for laser control */ +// variables for laser control static int last_LX = 0, last_LY = 0, last_hit_mask = 0; static int hold_x = -1, hold_y = -1; -/* variables for pacman control */ +// variables for pacman control static int pacman_nr = -1; -/* various game engine delay counters */ +// various game engine delay counters static unsigned int rotate_delay = 0; static unsigned int pacman_delay = 0; static unsigned int energy_delay = 0; static unsigned int overload_delay = 0; -/* element masks for scanning pixels of MM elements */ +// element masks for scanning pixels of MM elements static const char mm_masks[10][16][16 + 1] = { { @@ -318,7 +318,7 @@ static int get_opposite_angle(int angle) { int opposite_angle = angle + ANG_RAY_180; - /* make sure "opposite_angle" is in valid interval [0, 15] */ + // make sure "opposite_angle" is in valid interval [0, 15] return (opposite_angle + 16) % 16; } @@ -326,7 +326,7 @@ static int get_mirrored_angle(int laser_angle, int mirror_angle) { int reflected_angle = 16 - laser_angle + mirror_angle; - /* make sure "reflected_angle" is in valid interval [0, 15] */ + // make sure "reflected_angle" is in valid interval [0, 15] return (reflected_angle + 16) % 16; } @@ -357,7 +357,7 @@ static boolean CheckLaserPixel(int x, int y) return (pixel == WHITE_PIXEL); } -static void CheckExitMM() +static void CheckExitMM(void) { int exit_element = EL_EMPTY; int exit_x = 0; @@ -377,7 +377,7 @@ static void CheckExitMM() { if (Feld[x][y] == EL_EXIT_CLOSED) { - /* initiate opening animation of exit door */ + // initiate opening animation of exit door Feld[x][y] = EL_EXIT_OPENING; exit_element = EL_EXIT_OPEN; @@ -386,7 +386,7 @@ static void CheckExitMM() } else if (IS_RECEIVER(Feld[x][y])) { - /* remove field that blocks receiver */ + // remove field that blocks receiver int phase = Feld[x][y] - EL_RECEIVER_START; int blocking_x, blocking_y; @@ -478,7 +478,7 @@ static void InitField(int x, int y, boolean init_game) { static int steps_grid_auto = 0; - if (game_mm.num_cycle == 0) /* initialize cycle steps for grids */ + if (game_mm.num_cycle == 0) // initialize cycle steps for grids steps_grid_auto = RND(16) * (RND(2) ? -1 : +1); if (IS_GRID_STEEL_AUTO(element) || @@ -517,11 +517,11 @@ static void InitField(int x, int y, boolean init_game) } } -static void InitCycleElements_RotateSingleStep() +static void InitCycleElements_RotateSingleStep(void) { int i; - if (game_mm.num_cycle == 0) /* no elements to cycle */ + if (game_mm.num_cycle == 0) // no elements to cycle return; for (i = 0; i < game_mm.num_cycle; i++) @@ -542,7 +542,7 @@ static void InitCycleElements_RotateSingleStep() } } -static void InitLaser() +static void InitLaser(void) { int start_element = Feld[laser.start_edge.x][laser.start_edge.y]; int step = (IS_LASER(start_element) ? 4 : 0); @@ -572,7 +572,7 @@ static void InitLaser() laser.dest_element = EL_EMPTY; laser.wall_mask = 0; - AddLaserEdge(LX, LY); /* set laser starting edge */ + AddLaserEdge(LX, LY); // set laser starting edge pen_ray = GetPixelFromRGB(window, native_mm_level.laser_red * 0xFF, @@ -580,19 +580,19 @@ static void InitLaser() native_mm_level.laser_blue * 0xFF); } -void InitGameEngine_MM() +void InitGameEngine_MM(void) { int i, x, y; BEGIN_NO_HEADLESS { - /* initialize laser bitmap to current playfield (screen) size */ + // initialize laser bitmap to current playfield (screen) size ReCreateBitmap(&laser_bitmap, drawto->width, drawto->height); ClearRectangle(laser_bitmap, 0, 0, drawto->width, drawto->height); } END_NO_HEADLESS - /* set global game control values */ + // set global game control values game_mm.num_cycle = 0; game_mm.num_pacman = 0; @@ -610,7 +610,7 @@ void InitGameEngine_MM() game_mm.laser_overload_value = 0; game_mm.laser_enabled = FALSE; - /* set global laser control values (must be set before "InitLaser()") */ + // set global laser control values (must be set before "InitLaser()") laser.start_edge.x = 0; laser.start_edge.y = 0; laser.start_angle = 0; @@ -660,14 +660,10 @@ void InitGameEngine_MM() } } -#if 0 - CloseDoor(DOOR_CLOSE_1); -#endif - DrawLevel_MM(); } -void InitGameActions_MM() +void InitGameActions_MM(void) { int num_init_game_frames = INIT_GAME_ACTIONS_DELAY; int cycle_steps_done = 0; @@ -675,36 +671,6 @@ void InitGameActions_MM() InitLaser(); -#if 0 - /* copy default game door content to main double buffer */ - BlitBitmap(pix[PIX_DOOR], drawto, - DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY); -#endif - -#if 0 - DrawText(DX_LEVEL, DY_LEVEL, - int2str(level_nr, 2), FONT_TEXT_2); - DrawText(DX_KETTLES, DY_KETTLES, - int2str(game_mm.kettles_still_needed, 3), FONT_TEXT_2); - DrawText(DX_SCORE, DY_SCORE, - int2str(game_mm.score, 4), FONT_TEXT_2); -#endif - -#if 0 - UnmapGameButtons(); - MapGameButtons(); -#endif - -#if 0 - /* copy actual game door content to door double buffer for OpenDoor() */ - BlitBitmap(drawto, pix[PIX_DB_DOOR], - DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1); -#endif - -#if 0 - OpenDoor(DOOR_OPEN_ALL); -#endif - for (i = 0; i <= num_init_game_frames; i++) { if (i == num_init_game_frames) @@ -735,11 +701,6 @@ void InitGameActions_MM() #endif } -#if 0 - if (setup.sound_music && num_bg_loops) - PlayMusic(level_nr % num_bg_loops); -#endif - ScanLaser(); if (game_mm.kettles_still_needed == 0) @@ -778,7 +739,7 @@ void AddDamagedField(int ex, int ey) laser.num_damages++; } -boolean StepBehind() +static boolean StepBehind(void) { if (laser.num_edges) { @@ -805,7 +766,7 @@ static int getMaskFromElement(int element) return IMG_MM_MASK_CIRCLE; } -int ScanPixel() +static int ScanPixel(void) { int hit_mask = 0; @@ -814,13 +775,13 @@ int ScanPixel() LX, LY, LX / TILEX, LY / TILEY, LX % TILEX, LY % TILEY); #endif - /* follow laser beam until it hits something (at least the screen border) */ + // follow laser beam until it hits something (at least the screen border) while (hit_mask == HIT_MASK_NO_HIT) { int i; #if 0 - /* for safety */ + // for safety if (SX + LX < REAL_SX || SX + LX >= REAL_SX + FULL_SXSIZE || SY + LY < REAL_SY || SY + LY >= REAL_SY + FULL_SYSIZE) { @@ -836,8 +797,8 @@ int ScanPixel() int py = LY + (i / 2) * 2; int dx = px % TILEX; int dy = py % TILEY; - int lx = (px + TILEX) / TILEX - 1; /* ...+TILEX...-1 to get correct */ - int ly = (py + TILEY) / TILEY - 1; /* negative values! */ + int lx = (px + TILEX) / TILEX - 1; // ...+TILEX...-1 to get correct + int ly = (py + TILEY) / TILEY - 1; // negative values! Pixel pixel; if (IN_LEV_FIELD(lx, ly)) @@ -873,7 +834,7 @@ int ScanPixel() if (hit_mask == HIT_MASK_NO_HIT) { - /* hit nothing -- go on with another step */ + // hit nothing -- go on with another step LX += XS; LY += YS; } @@ -882,12 +843,12 @@ int ScanPixel() return hit_mask; } -void ScanLaser() +void ScanLaser(void) { int element; int end = 0, rf = laser.num_edges; - /* do not scan laser again after the game was lost for whatever reason */ + // do not scan laser again after the game was lost for whatever reason if (game_mm.game_over) return; @@ -920,7 +881,7 @@ void ScanLaser() LX, LY, XS, YS); #endif - /* hit something -- check out what it was */ + // hit something -- check out what it was ELX = (LX + XS) / TILEX; ELY = (LY + YS) / TILEY; @@ -952,7 +913,7 @@ void ScanLaser() { /* we have hit the top-left and bottom-right element -- choose the top-left one */ - /* !!! SEE ABOVE !!! */ + // !!! SEE ABOVE !!! ELX = (LX - 2) / TILEX; ELY = (LY - 2) / TILEY; } @@ -1069,7 +1030,7 @@ void ScanLaser() #endif } -void DrawLaserExt(int start_edge, int num_edges, int mode) +static void DrawLaserExt(int start_edge, int num_edges, int mode) { int element; int elx, ely; @@ -1100,7 +1061,7 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) } #endif - /* now draw the laser to the backbuffer and (if enabled) to the screen */ + // now draw the laser to the backbuffer and (if enabled) to the screen DrawLaserLines(&laser.edge[start_edge], num_edges, mode); redraw_mask |= REDRAW_FIELD; @@ -1108,13 +1069,13 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) if (mode == DL_LASER_ENABLED) return; - /* after the laser was deleted, the "damaged" graphics must be restored */ + // after the laser was deleted, the "damaged" graphics must be restored if (laser.num_damages) { int damage_start = 0; int i; - /* determine the starting edge, from which graphics need to be restored */ + // determine the starting edge, from which graphics need to be restored if (start_edge > 0) { for (i = 0; i < laser.num_damages; i++) @@ -1128,7 +1089,7 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) } } - /* restore graphics from this starting edge to the end of damage list */ + // restore graphics from this starting edge to the end of damage list for (i = damage_start; i < laser.num_damages; i++) { int lx = laser.damage[i].x; @@ -1168,7 +1129,7 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) laser.num_beamers > 0 && start_edge == laser.beamer_edge[laser.num_beamers - 1]) { - /* element is outgoing beamer */ + // element is outgoing beamer laser.num_damages = damage_start + 1; if (IS_BEAMER(element)) @@ -1176,14 +1137,14 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) } else { - /* element is incoming beamer or other element */ + // element is incoming beamer or other element laser.num_damages = damage_start; laser.current_angle = laser.damage[laser.num_damages].angle; } } else { - /* no damages but McDuffin himself (who needs to be redrawn anyway) */ + // no damages but McDuffin himself (who needs to be redrawn anyway) elx = laser.start_edge.x; ely = laser.start_edge.y; @@ -1219,7 +1180,7 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) printf("element == %d\n", element); #endif - if (IS_22_5_ANGLE(laser.current_angle)) /* neither 90° nor 45° angle */ + if (IS_22_5_ANGLE(laser.current_angle)) // neither 90° nor 45° angle step_size = ((IS_BEAMER(element) || IS_FIBRE_OPTIC(element)) ? 4 : 3); else step_size = 8; @@ -1229,7 +1190,7 @@ void DrawLaserExt(int start_edge, int num_edges, int mode) (laser.num_beamers == 0 || start_edge != laser.beamer_edge[laser.num_beamers - 1]))) { - /* element is incoming beamer or other element */ + // element is incoming beamer or other element step_size = -step_size; laser.num_edges--; } @@ -1268,7 +1229,7 @@ void DrawLaser(int start_edge, int mode) return; } - /* check if laser is interrupted by beamer element */ + // check if laser is interrupted by beamer element if (laser.num_beamers > 0 && start_edge < laser.beamer_edge[laser.num_beamers - 1]) { @@ -1277,7 +1238,7 @@ void DrawLaser(int start_edge, int mode) int i; int tmp_start_edge = start_edge; - /* draw laser segments forward from the start to the last beamer */ + // draw laser segments forward from the start to the last beamer for (i = 0; i < laser.num_beamers; i++) { int tmp_num_edges = laser.beamer_edge[i] - tmp_start_edge; @@ -1295,7 +1256,7 @@ void DrawLaser(int start_edge, int mode) tmp_start_edge = laser.beamer_edge[i]; } - /* draw last segment from last beamer to the end */ + // draw last segment from last beamer to the end DrawLaserExt(tmp_start_edge, laser.num_edges - tmp_start_edge, DL_LASER_ENABLED); } @@ -1305,7 +1266,7 @@ void DrawLaser(int start_edge, int mode) int last_num_edges = laser.num_edges; int num_beamers = laser.num_beamers; - /* delete laser segments backward from the end to the first beamer */ + // delete laser segments backward from the end to the first beamer for (i = num_beamers - 1; i >= 0; i--) { int tmp_num_edges = last_num_edges - laser.beamer_edge[i]; @@ -1330,7 +1291,7 @@ void DrawLaser(int start_edge, int mode) if (last_num_edges - start_edge == 1 && start_edge > 0) DrawLaserLines(&laser.edge[start_edge - 1], 2, DL_LASER_DISABLED); - /* delete first segment from start to the first beamer */ + // delete first segment from start to the first beamer DrawLaserExt(start_edge, last_num_edges - start_edge, DL_LASER_DISABLED); } } @@ -1342,7 +1303,7 @@ void DrawLaser(int start_edge, int mode) game_mm.laser_enabled = mode; } -void DrawLaser_MM() +void DrawLaser_MM(void) { DrawLaser(0, game_mm.laser_enabled); } @@ -1368,10 +1329,10 @@ boolean HitElement(int element, int hit_mask) AddDamagedField(ELX, ELY); - /* this is more precise: check if laser would go through the center */ + // this is more precise: check if laser would go through the center if ((ELX * TILEX + 14 - LX) * YS != (ELY * TILEY + 14 - LY) * XS) { - /* skip the whole element before continuing the scan */ + // skip the whole element before continuing the scan do { LX += XS; @@ -1483,7 +1444,7 @@ boolean HitElement(int element, int hit_mask) XS = 2 * Step[laser.current_angle].x; YS = 2 * Step[laser.current_angle].y; - if (!IS_22_5_ANGLE(laser.current_angle)) /* 90° or 45° angle */ + if (!IS_22_5_ANGLE(laser.current_angle)) // 90° or 45° angle step_size = 8; else step_size = 4; @@ -1492,7 +1453,7 @@ boolean HitElement(int element, int hit_mask) LY += step_size * YS; #if 0 - /* draw sparkles on mirror */ + // draw sparkles on mirror if ((IS_MIRROR(element) || IS_MIRROR_FIXED(element)) && current_angle != laser.current_angle) { @@ -1672,7 +1633,7 @@ boolean HitElement(int element, int hit_mask) boolean HitOnlyAnEdge(int element, int hit_mask) { - /* check if the laser hit only the edge of an element and, if so, go on */ + // check if the laser hit only the edge of an element and, if so, go on #if 0 printf("LX, LY, hit_mask == %d, %d, %d\n", LX, LY, hit_mask); @@ -1682,7 +1643,7 @@ boolean HitOnlyAnEdge(int element, int hit_mask) hit_mask == HIT_MASK_TOPRIGHT || hit_mask == HIT_MASK_BOTTOMLEFT || hit_mask == HIT_MASK_BOTTOMRIGHT) && - laser.current_angle % 4) /* angle is not 90° */ + laser.current_angle % 4) // angle is not 90° { int dx, dy; @@ -1701,7 +1662,7 @@ boolean HitOnlyAnEdge(int element, int hit_mask) dx = -1; dy = +1; } - else /* (hit_mask == HIT_MASK_BOTTOMRIGHT) */ + else // (hit_mask == HIT_MASK_BOTTOMRIGHT) { dx = +1; dy = +1; @@ -1749,7 +1710,7 @@ boolean HitPolarizer(int element, int hit_mask) if (laser.current_angle == grid_angle || laser.current_angle == get_opposite_angle(grid_angle)) { - /* skip the whole element before continuing the scan */ + // skip the whole element before continuing the scan do { LX += XS; @@ -1795,7 +1756,7 @@ boolean HitPolarizer(int element, int hit_mask) { return HitReflectingWalls(element, hit_mask); } - else /* IS_GRID_WOOD */ + else // IS_GRID_WOOD { return HitAbsorbingWalls(element, hit_mask); } @@ -1984,7 +1945,7 @@ boolean HitLaserDestination(int element, int hit_mask) boolean HitReflectingWalls(int element, int hit_mask) { - /* check if laser hits side of a wall with an angle that is not 90° */ + // check if laser hits side of a wall with an angle that is not 90° if (!IS_90_ANGLE(laser.current_angle) && (hit_mask == HIT_MASK_TOP || hit_mask == HIT_MASK_LEFT || hit_mask == HIT_MASK_RIGHT || @@ -1998,7 +1959,7 @@ boolean HitReflectingWalls(int element, int hit_mask) if (!IS_DF_GRID(element)) AddLaserEdge(LX, LY); - /* check if laser hits wall with an angle of 45° */ + // check if laser hits wall with an angle of 45° if (!IS_22_5_ANGLE(laser.current_angle)) { if (hit_mask == HIT_MASK_TOP || hit_mask == HIT_MASK_BOTTOM) @@ -2007,7 +1968,7 @@ boolean HitReflectingWalls(int element, int hit_mask) laser.current_angle = get_mirrored_angle(laser.current_angle, ANG_MIRROR_0); } - else /* hit_mask == HIT_MASK_LEFT || hit_mask == HIT_MASK_RIGHT */ + else // hit_mask == HIT_MASK_LEFT || hit_mask == HIT_MASK_RIGHT { LY += 2 * YS; laser.current_angle = get_mirrored_angle(laser.current_angle, @@ -2046,7 +2007,7 @@ boolean HitReflectingWalls(int element, int hit_mask) return FALSE; } - else /* hit_mask == HIT_MASK_LEFT || hit_mask == HIT_MASK_RIGHT */ + else // hit_mask == HIT_MASK_LEFT || hit_mask == HIT_MASK_RIGHT { laser.current_angle = get_mirrored_angle(laser.current_angle, ANG_MIRROR_90); @@ -2073,7 +2034,7 @@ boolean HitReflectingWalls(int element, int hit_mask) } } - /* reflection at the edge of reflecting DF style wall */ + // reflection at the edge of reflecting DF style wall if (IS_DF_WALL_STEEL(element) && IS_22_5_ANGLE(laser.current_angle)) { if (((laser.current_angle == 1 || laser.current_angle == 3) && @@ -2108,7 +2069,7 @@ boolean HitReflectingWalls(int element, int hit_mask) } } - /* reflection inside an edge of reflecting DF style wall */ + // reflection inside an edge of reflecting DF style wall if (IS_DF_WALL_STEEL(element) && IS_22_5_ANGLE(laser.current_angle)) { if (((laser.current_angle == 1 || laser.current_angle == 3) && @@ -2149,7 +2110,7 @@ boolean HitReflectingWalls(int element, int hit_mask) } } - /* check if laser hits DF style wall with an angle of 90° */ + // check if laser hits DF style wall with an angle of 90° if (IS_DF_WALL(element) && IS_90_ANGLE(laser.current_angle)) { if ((IS_HORIZ_ANGLE(laser.current_angle) && @@ -2157,7 +2118,7 @@ boolean HitReflectingWalls(int element, int hit_mask) (IS_VERT_ANGLE(laser.current_angle) && (!(hit_mask & HIT_MASK_LEFT) || !(hit_mask & HIT_MASK_RIGHT)))) { - /* laser at last step touched nothing or the same side of the wall */ + // laser at last step touched nothing or the same side of the wall if (LX != last_LX || LY != last_LY || hit_mask == last_hit_mask) { AddDamagedField(ELX, ELY); @@ -2225,10 +2186,10 @@ boolean HitAbsorbingWalls(int element, int hit_mask) { int mask; - mask = (LX + XS) / MINI_TILEX - ELX * 2 + 1; /* Quadrant (horizontal) */ - mask <<= (((LY + YS) / MINI_TILEY - ELY * 2) > 0) * 2; /* || (vertical) */ + mask = (LX + XS) / MINI_TILEX - ELX * 2 + 1; // Quadrant (horizontal) + mask <<= (((LY + YS) / MINI_TILEY - ELY * 2) > 0) * 2; // || (vertical) - /* check if laser hits wall with an angle of 90° */ + // check if laser hits wall with an angle of 90° if (IS_90_ANGLE(laser.current_angle)) mask += mask * (2 + IS_HORIZ_ANGLE(laser.current_angle) * 2); @@ -2286,14 +2247,14 @@ boolean HitAbsorbingWalls(int element, int hit_mask) return TRUE; } -void OpenExit(int x, int y) +static void OpenExit(int x, int y) { int delay = 6; - if (!MovDelay[x][y]) /* next animation frame */ + if (!MovDelay[x][y]) // next animation frame MovDelay[x][y] = 4 * delay; - if (MovDelay[x][y]) /* wait some time before next frame */ + if (MovDelay[x][y]) // wait some time before next frame { int phase; @@ -2311,14 +2272,14 @@ void OpenExit(int x, int y) } } -void OpenSurpriseBall(int x, int y) +static void OpenSurpriseBall(int x, int y) { int delay = 2; - if (!MovDelay[x][y]) /* next animation frame */ + if (!MovDelay[x][y]) // next animation frame MovDelay[x][y] = 50 * delay; - if (MovDelay[x][y]) /* wait some time before next frame */ + if (MovDelay[x][y]) // wait some time before next frame { MovDelay[x][y]--; @@ -2348,15 +2309,15 @@ void OpenSurpriseBall(int x, int y) } } -void MeltIce(int x, int y) +static void MeltIce(int x, int y) { int frames = 5; int delay = 5; - if (!MovDelay[x][y]) /* next animation frame */ + if (!MovDelay[x][y]) // next animation frame MovDelay[x][y] = frames * delay; - if (MovDelay[x][y]) /* wait some time before next frame */ + if (MovDelay[x][y]) // wait some time before next frame { int phase; int wall_mask = Store2[x][y]; @@ -2397,15 +2358,15 @@ void MeltIce(int x, int y) } } -void GrowAmoeba(int x, int y) +static void GrowAmoeba(int x, int y) { int frames = 5; int delay = 1; - if (!MovDelay[x][y]) /* next animation frame */ + if (!MovDelay[x][y]) // next animation frame MovDelay[x][y] = frames * delay; - if (MovDelay[x][y]) /* wait some time before next frame */ + if (MovDelay[x][y]) // wait some time before next frame { int phase; int wall_mask = Store2[x][y]; @@ -2437,13 +2398,13 @@ static void Explode_MM(int x, int y, int phase, int mode) laser.redraw = TRUE; - if (phase == EX_PHASE_START) /* initialize 'Store[][]' field */ + if (phase == EX_PHASE_START) // initialize 'Store[][]' field { int center_element = Feld[x][y]; if (IS_MOVING(x, y) || IS_BLOCKED(x, y)) { - /* put moving element to center field (and let it explode there) */ + // put moving element to center field (and let it explode there) center_element = MovingOrBlocked2Element_MM(x, y); RemoveMovingField_MM(x, y); @@ -2494,7 +2455,7 @@ static void Explode_MM(int x, int y, int phase, int mode) { Store[x][y] = EL_EMPTY; - game.restart_game_message = "Bomb killed Mc Duffin ! Play it again ?"; + game.restart_game_message = "Bomb killed Mc Duffin! Play it again?"; } Feld[x][y] = Store[x][y]; @@ -2650,7 +2611,7 @@ static void StartMoving_MM(int x, int y) { int newx, newy; - if (MovDelay[x][y]) /* wait some time before next movement */ + if (MovDelay[x][y]) // wait some time before next movement { MovDelay[x][y]--; @@ -2658,9 +2619,9 @@ static void StartMoving_MM(int x, int y) return; } - /* now make next step */ + // now make next step - Moving2Blocked_MM(x, y, &newx, &newy); /* get next screen position */ + Moving2Blocked_MM(x, y, &newx, &newy); // get next screen position if (element == EL_PACMAN && IN_LEV_FIELD(newx, newy) && IS_EATABLE4PACMAN(Feld[newx][newy]) && @@ -2674,7 +2635,7 @@ static void StartMoving_MM(int x, int y) else if (!IN_LEV_FIELD(newx, newy) || !IS_FREE(newx, newy) || ObjHit(newx, newy, HIT_POS_CENTER)) { - /* object was running against a wall */ + // object was running against a wall TurnRound(x, y); @@ -2700,7 +2661,7 @@ static void ContinueMoving_MM(int x, int y) MovPos[x][y] += step; - if (ABS(MovPos[x][y]) >= TILEX) /* object reached its destination */ + if (ABS(MovPos[x][y]) >= TILEX) // object reached its destination { Feld[x][y] = EL_EMPTY; Feld[newx][newy] = element; @@ -2730,7 +2691,7 @@ static void ContinueMoving_MM(int x, int y) } } } - else /* still moving on */ + else // still moving on { DrawField_MM(x, y); } @@ -2748,7 +2709,7 @@ boolean ClickElement(int x, int y, int button) if (button == -1) { - /* initialize static variables */ + // initialize static variables click_delay = 0; click_delay_value = CLICK_DELAY; new_button = TRUE; @@ -2756,7 +2717,7 @@ boolean ClickElement(int x, int y, int button) return FALSE; } - /* do not rotate objects hit by the laser after the game was solved */ + // do not rotate objects hit by the laser after the game was solved if (game_mm.level_solved && Hit[x][y]) return FALSE; @@ -2765,7 +2726,7 @@ boolean ClickElement(int x, int y, int button) new_button = TRUE; click_delay_value = CLICK_DELAY; - /* release eventually hold auto-rotating mirror */ + // release eventually hold auto-rotating mirror RotateMirror(x, y, MB_RELEASED); return FALSE; @@ -2774,7 +2735,7 @@ boolean ClickElement(int x, int y, int button) if (!FrameReached(&click_delay, click_delay_value) && !new_button) return FALSE; - if (button == MB_MIDDLEBUTTON) /* middle button has no function */ + if (button == MB_MIDDLEBUTTON) // middle button has no function return FALSE; if (!IN_LEV_FIELD(x, y)) @@ -2868,7 +2829,7 @@ void RotateMirror(int x, int y, int button) { if (button == MB_RELEASED) { - /* release eventually hold auto-rotating mirror */ + // release eventually hold auto-rotating mirror hold_x = -1; hold_y = -1; @@ -2889,8 +2850,8 @@ void RotateMirror(int x, int y, int button) { if (button == MB_LEFTBUTTON) { - /* left mouse button only for manual adjustment, no auto-rotating; - freeze mirror for until mouse button released */ + // left mouse button only for manual adjustment, no auto-rotating; + // freeze mirror for until mouse button released hold_x = x; hold_y = y; } @@ -2959,7 +2920,7 @@ void RotateMirror(int x, int y, int button) } } -void AutoRotateMirrors() +static void AutoRotateMirrors(void) { int x, y; @@ -2972,7 +2933,7 @@ void AutoRotateMirrors() { int element = Feld[x][y]; - /* do not rotate objects hit by the laser after the game was solved */ + // do not rotate objects hit by the laser after the game was solved if (game_mm.level_solved && Hit[x][y]) continue; @@ -3121,9 +3082,9 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) AutoRotateMirrors(); #if 1 - /* !!! CHANGE THIS: REDRAW ONLY WHEN NEEDED !!! */ + // !!! CHANGE THIS: REDRAW ONLY WHEN NEEDED !!! - /* redraw after Explode_MM() ... */ + // redraw after Explode_MM() ... if (laser.redraw) DrawLaser(0, DL_LASER_ENABLED); laser.redraw = FALSE; @@ -3148,12 +3109,6 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) { game_mm.energy_left--; -#if 0 - BlitBitmap(pix[PIX_DOOR], drawto, - DOOR_GFX_PAGEX5 + XX_ENERGY, DOOR_GFX_PAGEY1 + YY_ENERGY, - ENERGY_XSIZE, ENERGY_YSIZE - game_mm.energy_left, - DX_ENERGY, DY_ENERGY); -#endif redraw_mask |= REDRAW_DOOR_1; } else if (setup.time_limit && !game_mm.game_over) @@ -3172,7 +3127,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) DrawLaser(0, DL_LASER_ENABLED); BackToFront(); - Delay(50); + Delay_WithScreenUpdates(50); } StopSound_MM(SND_MM_GAME_HEALTH_CHARGING); @@ -3186,10 +3141,10 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) SetTileCursorActive(FALSE); - game.restart_game_message = "Out of magic energy ! Play it again ?"; + game.restart_game_message = "Out of magic energy! Play it again?"; #if 0 - if (Request("Out of magic energy ! Play it again ?", + if (Request("Out of magic energy! Play it again?", REQ_ASK | REQ_STAY_CLOSED)) { InitGame(); @@ -3260,9 +3215,6 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) (native_mm_level.laser_blue ? color_down : 0x00)); DrawLaser(0, DL_LASER_ENABLED); -#if 0 - BackToFront(); -#endif } if (!laser.overloaded) @@ -3300,6 +3252,8 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) { int i; + UpdateAndDisplayGameControlValues(); + for (i = 15; i >= 0; i--) { #if 0 @@ -3310,7 +3264,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) DrawLaser(0, DL_LASER_ENABLED); BackToFront(); - Delay(50); + Delay_WithScreenUpdates(50); } DrawLaser(0, DL_LASER_DISABLED); @@ -3320,10 +3274,10 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) SetTileCursorActive(FALSE); - game.restart_game_message = "Magic spell hit Mc Duffin ! Play it again ?"; + game.restart_game_message = "Magic spell hit Mc Duffin! Play it again?"; #if 0 - if (Request("Magic spell hit Mc Duffin ! Play it again ?", + if (Request("Magic spell hit Mc Duffin! Play it again?", REQ_ASK | REQ_STAY_CLOSED)) { InitGame(); @@ -3367,7 +3321,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) laser.num_edges = 0; Bang_MM(laser.start_edge.x, laser.start_edge.y); - if (Request("Bomb killed Mc Duffin ! Play it again ?", + if (Request("Bomb killed Mc Duffin! Play it again?", REQ_ASK | REQ_STAY_CLOSED)) { InitGame(); @@ -3411,7 +3365,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) Store[ELX][ELY] = new_element + RND(get_num_elements(new_element)); Feld[ELX][ELY] = EL_GRAY_BALL_OPENING; - /* !!! CHECK AGAIN: Laser on Polarizer !!! */ + // !!! CHECK AGAIN: Laser on Polarizer !!! ScanLaser(); return; @@ -3463,7 +3417,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) DrawLaser(0, DL_LASER_ENABLED); - Delay(50); + Delay_WithScreenUpdates(50); } Feld[ELX][ELY] = element; @@ -3473,7 +3427,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) printf("NEW ELEMENT: (%d, %d)\n", ELX, ELY); #endif - /* above stuff: GRAY BALL -> PRISM !!! */ + // above stuff: GRAY BALL -> PRISM !!! /* LX = ELX * TILEX + 14; LY = ELY * TILEY + 14; @@ -3537,7 +3491,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) DrawWallsAnimation_MM(ELX, ELY, Feld[ELX][ELY], phase, laser.wall_mask); BackToFront(); - Delay(100); + Delay_WithScreenUpdates(100); } if (Feld[ELX][ELY] == EL_WALL_ICE) @@ -3670,7 +3624,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) DrawWallsAnimation_MM(dx, dy, de, i, dm); BackToFront(); - Delay(20); + Delay_WithScreenUpdates(20); } DrawLaser(0, DL_LASER_ENABLED); @@ -3751,7 +3705,7 @@ static void GameActions_MM_Ext(struct MouseActionInfo action, boolean warp_mode) redraw_mask |= REDRAW_DOOR_1; BackToFront(); - Delay(20); + Delay_WithScreenUpdates(20); } game_mm.energy_left = MAX_LASER_ENERGY; @@ -3776,7 +3730,7 @@ void GameActions_MM(struct MouseActionInfo action, boolean warp_mode) CheckSingleStepMode_MM(element_clicked, button_released); } -void MovePacMen() +void MovePacMen(void) { int mx, my, ox, oy, nx, ny; int element; @@ -3881,7 +3835,7 @@ void MovePacMen() } } -void GameWon_MM() +void GameWon_MM(void) { int hi_pos; boolean raise_level = FALSE; @@ -3924,13 +3878,13 @@ void GameWon_MM() } BackToFront(); - Delay(10); + Delay_WithScreenUpdates(10); } if (setup.sound_loops) StopSound(SND_SIRR); } - else if (native_mm_level.time == 0) /* level without time limit */ + else if (native_mm_level.time == 0) // level without time limit { if (setup.sound_loops) PlaySoundExt(SND_SIRR, SOUND_MAX_VOLUME, SOUND_MAX_RIGHT, @@ -3952,20 +3906,16 @@ void GameWon_MM() */ BackToFront(); - Delay(10); + Delay_WithScreenUpdates(10); } if (setup.sound_loops) StopSound(SND_SIRR); } -#if 0 - FadeSounds(); -#endif - CloseDoor(DOOR_CLOSE_1); - Request("Level solved !", REQ_CONFIRM); + Request("Level solved!", REQ_CONFIRM); if (level_nr == leveldir_current->handicap_level) { @@ -3974,9 +3924,9 @@ void GameWon_MM() } if (level_editor_test_game) - game_mm.score = -1; /* no highscore when playing from editor */ + game_mm.score = -1; // no highscore when playing from editor else if (level_nr < leveldir_current->last_level) - raise_level = TRUE; /* advance to next level */ + raise_level = TRUE; // advance to next level if ((hi_pos = NewHiScore_MM()) >= 0) { @@ -4000,7 +3950,7 @@ void GameWon_MM() BackToFront(); } -int NewHiScore_MM() +int NewHiScore_MM(void) { int k, l; int position = -1; @@ -4015,7 +3965,7 @@ int NewHiScore_MM() { if (game_mm.score > highscore[k].Score) { - /* player has made it to the hall of fame */ + // player has made it to the hall of fame if (k < MAX_SCORE_ENTRIES - 1) { @@ -4025,7 +3975,7 @@ int NewHiScore_MM() for (l = k; l < MAX_SCORE_ENTRIES; l++) if (!strcmp(setup.player_name, highscore[l].Name)) m = l; - if (m == k) /* player's new highscore overwrites his old one */ + if (m == k) // player's new highscore overwrites his old one goto put_into_list; #endif @@ -4050,7 +4000,7 @@ int NewHiScore_MM() #ifdef ONE_PER_NAME else if (!strncmp(setup.player_name, highscore[k].Name, MAX_PLAYER_NAME_LEN)) - break; /* player already there with a higher score */ + break; // player already there with a higher score #endif } @@ -4198,11 +4148,6 @@ void PlaySoundLevel(int x, int y, int sound_nr) static void RaiseScore_MM(int value) { game_mm.score += value; - -#if 0 - DrawText(DX_SCORE, DY_SCORE, int2str(game_mm.score, 4), - FONT_TEXT_2); -#endif } void RaiseScoreElement_MM(int element) @@ -4236,9 +4181,9 @@ void RaiseScoreElement_MM(int element) } -/* ------------------------------------------------------------------------- */ -/* Mirror Magic game engine snapshot handling functions */ -/* ------------------------------------------------------------------------- */ +// ---------------------------------------------------------------------------- +// Mirror Magic game engine snapshot handling functions +// ---------------------------------------------------------------------------- void SaveEngineSnapshotValues_MM(ListNode **buffers) { @@ -4281,11 +4226,11 @@ void SaveEngineSnapshotValues_MM(ListNode **buffers) engine_snapshot_mm.overload_delay = overload_delay; } -void LoadEngineSnapshotValues_MM() +void LoadEngineSnapshotValues_MM(void) { int x, y; - /* stored engine snapshot buffers already restored at this point */ + // stored engine snapshot buffers already restored at this point game_mm = engine_snapshot_mm.game_mm; laser = engine_snapshot_mm.laser; @@ -4323,7 +4268,7 @@ void LoadEngineSnapshotValues_MM() energy_delay = engine_snapshot_mm.energy_delay; overload_delay = engine_snapshot_mm.overload_delay; - RedrawPlayfield_MM(TRUE); + RedrawPlayfield_MM(); } static int getAngleFromTouchDelta(int dx, int dy, int base)