X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_mm%2Fmm_game.c;h=cda5e6aee9db15eba2061ac419ba873fe2125ae9;hb=c602135de533bbffabc4e284156b79fe156e884c;hp=9629e20cd620b32b4704a33fec529397c11836c6;hpb=5d1d7972c0b10aabb014e3952c1cda475f2b31c4;p=rocksndiamonds.git diff --git a/src/game_mm/mm_game.c b/src/game_mm/mm_game.c index 9629e20c..cda5e6ae 100644 --- a/src/game_mm/mm_game.c +++ b/src/game_mm/mm_game.c @@ -99,6 +99,22 @@ static void InitMovingField_MM(int, int, int); static void ContinueMoving_MM(int, int); static void Moving2Blocked_MM(int, int, int *, int *); +static void AddLaserEdge(int, int); +static void ScanLaser(void); +static void DrawLaser(int, int); +static boolean HitElement(int, int); +static boolean HitOnlyAnEdge(int); +static boolean HitPolarizer(int, int); +static boolean HitBlock(int, int); +static boolean HitLaserSource(int, int); +static boolean HitLaserDestination(int, int); +static boolean HitReflectingWalls(int, int); +static boolean HitAbsorbingWalls(int, int); +static void RotateMirror(int, int, int); +static boolean ObjHit(int, int, int); +static void DeletePacMan(int, int); +static void MovePacMen(void); + // bitmap for laser beam detection static Bitmap *laser_bitmap = NULL; @@ -744,8 +760,6 @@ void InitGameActions_MM(void) BackToFront(); - ColorCycling(); - #ifdef DEBUG if (setup.quick_doors) continue; @@ -807,7 +821,7 @@ static void GameOver_MM(int game_over_cause) SetTileCursorActive(FALSE); } -void AddLaserEdge(int lx, int ly) +static void AddLaserEdge(int lx, int ly) { int clx = dSX + lx; int cly = dSY + ly; @@ -826,7 +840,7 @@ void AddLaserEdge(int lx, int ly) laser.redraw = TRUE; } -void AddDamagedField(int ex, int ey) +static void AddDamagedField(int ex, int ey) { // prevent adding the same field position again if (laser.num_damages > 0 && @@ -971,7 +985,7 @@ static void DeactivateLaserTargetElement(void) } } -void ScanLaser(void) +static void ScanLaser(void) { int element = EL_EMPTY; int last_element = EL_EMPTY; @@ -1487,7 +1501,7 @@ void DrawLaser_MM(void) DrawLaser(0, game_mm.laser_enabled); } -boolean HitElement(int element, int hit_mask) +static boolean HitElement(int element, int hit_mask) { if (HitOnlyAnEdge(hit_mask)) return FALSE; @@ -1677,6 +1691,8 @@ boolean HitElement(int element, int hit_mask) element == EL_MINE ? EL_MINE_ACTIVE : EL_GRAY_BALL_ACTIVE); + GfxFrame[ELX][ELY] = 0; // restart animation + laser.dest_element_last = Tile[ELX][ELY]; laser.dest_element_last_x = ELX; laser.dest_element_last_y = ELY; @@ -1835,7 +1851,7 @@ boolean HitElement(int element, int hit_mask) return TRUE; } -boolean HitOnlyAnEdge(int hit_mask) +static boolean HitOnlyAnEdge(int hit_mask) { // check if the laser hit only the edge of an element and, if so, go on @@ -1892,7 +1908,7 @@ boolean HitOnlyAnEdge(int hit_mask) return FALSE; } -boolean HitPolarizer(int element, int hit_mask) +static boolean HitPolarizer(int element, int hit_mask) { if (HitOnlyAnEdge(hit_mask)) return FALSE; @@ -1969,7 +1985,7 @@ boolean HitPolarizer(int element, int hit_mask) return TRUE; } -boolean HitBlock(int element, int hit_mask) +static boolean HitBlock(int element, int hit_mask) { boolean check = FALSE; @@ -2090,7 +2106,7 @@ boolean HitBlock(int element, int hit_mask) return TRUE; } -boolean HitLaserSource(int element, int hit_mask) +static boolean HitLaserSource(int element, int hit_mask) { if (HitOnlyAnEdge(hit_mask)) return FALSE; @@ -2102,7 +2118,7 @@ boolean HitLaserSource(int element, int hit_mask) return TRUE; } -boolean HitLaserDestination(int element, int hit_mask) +static boolean HitLaserDestination(int element, int hit_mask) { if (HitOnlyAnEdge(hit_mask)) return FALSE; @@ -2148,7 +2164,7 @@ boolean HitLaserDestination(int element, int hit_mask) return TRUE; } -boolean HitReflectingWalls(int element, int hit_mask) +static boolean HitReflectingWalls(int element, int hit_mask) { // 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 || @@ -2350,7 +2366,7 @@ boolean HitReflectingWalls(int element, int hit_mask) return FALSE; } -boolean HitAbsorbingWalls(int element, int hit_mask) +static boolean HitAbsorbingWalls(int element, int hit_mask) { if (HitOnlyAnEdge(hit_mask)) return FALSE; @@ -2444,7 +2460,7 @@ boolean HitAbsorbingWalls(int element, int hit_mask) if (IS_90_ANGLE(laser.current_angle)) mask += mask * (2 + IS_HORIZ_ANGLE(laser.current_angle) * 2); - laser.dest_element = element2 | EL_WALL_AMOEBA; + laser.dest_element = element2 | EL_WALL_AMOEBA_BASE; laser.wall_mask = mask; } @@ -2477,7 +2493,7 @@ static void OpenExit(int x, int y) } } -static void OpenSurpriseBall(int x, int y) +static void OpenGrayBall(int x, int y) { int delay = 2; @@ -2591,7 +2607,7 @@ static void MeltIce(int x, int y) { int phase; int wall_mask = Store2[x][y]; - int real_element = Tile[x][y] - EL_WALL_CHANGING + EL_WALL_ICE; + int real_element = Tile[x][y] - EL_WALL_CHANGING_BASE + EL_WALL_ICE_BASE; MovDelay[x][y]--; phase = frames - MovDelay[x][y] / delay - 1; @@ -2603,7 +2619,7 @@ static void MeltIce(int x, int y) DrawWalls_MM(x, y, Tile[x][y]); - if (Tile[x][y] == EL_WALL_ICE) + if (Tile[x][y] == EL_WALL_ICE_BASE) Tile[x][y] = EL_EMPTY; ScanLaser_FromLastMirror(); @@ -2629,7 +2645,7 @@ static void GrowAmoeba(int x, int y) { int phase; int wall_mask = Store2[x][y]; - int real_element = Tile[x][y] - EL_WALL_CHANGING + EL_WALL_AMOEBA; + int real_element = Tile[x][y] - EL_WALL_CHANGING_BASE + EL_WALL_AMOEBA_BASE; MovDelay[x][y]--; phase = MovDelay[x][y] / delay; @@ -2694,12 +2710,13 @@ static void Explode_MM(int x, int y, int phase, int mode) int num_phase = 9, delay = 2; int last_phase = num_phase * delay; int half_phase = (num_phase / 2) * delay; + int center_element; laser.redraw = TRUE; if (phase == EX_PHASE_START) // initialize 'Store[][]' field { - int center_element = Tile[x][y]; + center_element = Tile[x][y]; if (IS_MOVING(x, y) || IS_BLOCKED(x, y)) { @@ -2710,8 +2727,8 @@ static void Explode_MM(int x, int y, int phase, int mode) Tile[x][y] = center_element; } - Store[x][y] = center_element; - Store2[x][y] = mode; + Store[x][y] = EL_EMPTY; + Store2[x][y] = center_element; Tile[x][y] = EL_EXPLODING_OPAQUE; @@ -2731,7 +2748,9 @@ static void Explode_MM(int x, int y, int phase, int mode) ExplodePhase[x][y] = (phase < last_phase ? phase + 1 : 0); - if (phase == half_phase) + center_element = Store2[x][y]; + + if (phase == half_phase && Store[x][y] == EL_EMPTY) { Tile[x][y] = EL_EXPLODING_TRANSP; @@ -2741,7 +2760,7 @@ static void Explode_MM(int x, int y, int phase, int mode) if (phase == last_phase) { - if (Store[x][y] == EL_BOMB_ACTIVE) + if (center_element == EL_BOMB_ACTIVE) { DrawLaser(0, DL_LASER_DISABLED); InitLaser(); @@ -2752,12 +2771,12 @@ static void Explode_MM(int x, int y, int phase, int mode) laser.overloaded = FALSE; } - else if (IS_MCDUFFIN(Store[x][y])) + else if (IS_MCDUFFIN(center_element)) { GameOver_MM(GAME_OVER_BOMB); } - Tile[x][y] = EL_EMPTY; + Tile[x][y] = Store[x][y]; Store[x][y] = Store2[x][y] = 0; MovDir[x][y] = MovPos[x][y] = MovDelay[x][y] = 0; @@ -2780,10 +2799,6 @@ static void Bang_MM(int x, int y) { int element = Tile[x][y]; -#if 0 - DrawLaser(0, DL_LASER_ENABLED); -#endif - if (IS_PACMAN(element)) PlayLevelSound_MM(x, y, element, MM_ACTION_EXPLODING); else if (element == EL_BOMB_ACTIVE || IS_MCDUFFIN(element)) @@ -2796,7 +2811,7 @@ static void Bang_MM(int x, int y) Explode_MM(x, y, EX_PHASE_START, EX_TYPE_NORMAL); } -void TurnRound(int x, int y) +static void TurnRound(int x, int y) { static struct { @@ -3079,7 +3094,7 @@ boolean ClickElement(int x, int y, int button) return element_clicked; } -void RotateMirror(int x, int y, int button) +static void RotateMirror(int x, int y, int button) { if (button == MB_RELEASED) { @@ -3201,7 +3216,7 @@ static void AutoRotateMirrors(void) } } -boolean ObjHit(int obx, int oby, int bits) +static boolean ObjHit(int obx, int oby, int bits) { int i; @@ -3234,7 +3249,7 @@ boolean ObjHit(int obx, int oby, int bits) return FALSE; } -void DeletePacMan(int px, int py) +static void DeletePacMan(int px, int py) { int i, j; @@ -3260,50 +3275,6 @@ void DeletePacMan(int px, int py) } } -void ColorCycling(void) -{ - static int CC, Cc = 0; - - static int color, old = 0xF00, new = 0x010, mult = 1; - static unsigned short red, green, blue; - - if (color_status == STATIC_COLORS) - return; - - CC = FrameCounter; - - if (CC < Cc || CC > Cc + 2) - { - Cc = CC; - - color = old + new * mult; - if (mult > 0) - mult++; - else - mult--; - - if (ABS(mult) == 16) - { - mult =- mult / 16; - old = color; - new = new << 4; - - if (new > 0x100) - new = 0x001; - } - - red = 0x0e00 * ((color & 0xF00) >> 8); - green = 0x0e00 * ((color & 0x0F0) >> 4); - blue = 0x0e00 * ((color & 0x00F)); - SetRGB(pen_magicolor[0], red, green, blue); - - red = 0x1111 * ((color & 0xF00) >> 8); - green = 0x1111 * ((color & 0x0F0) >> 4); - blue = 0x1111 * ((color & 0x00F)); - SetRGB(pen_magicolor[1], red, green, blue); - } -} - static void GameActions_MM_Ext(void) { int element; @@ -3327,12 +3298,12 @@ static void GameActions_MM_Ext(void) else if (element == EL_EXIT_OPENING) OpenExit(x, y); else if (element == EL_GRAY_BALL_OPENING) - OpenSurpriseBall(x, y); + OpenGrayBall(x, y); else if (IS_ENVELOPE_OPENING(element)) OpenEnvelope(x, y); - else if (IS_WALL_CHANGING(element) && Store[x][y] == EL_WALL_ICE) + else if (IS_WALL_CHANGING(element) && Store[x][y] == EL_WALL_ICE_BASE) MeltIce(x, y); - else if (IS_WALL_CHANGING(element) && Store[x][y] == EL_WALL_AMOEBA) + else if (IS_WALL_CHANGING(element) && Store[x][y] == EL_WALL_AMOEBA_BASE) GrowAmoeba(x, y); else if (IS_MIRROR(element) || IS_MIRROR_FIXED(element) || @@ -3449,30 +3420,6 @@ static void GameActions_MM_Ext(void) else PlaySound_MM(SND_MM_GAME_HEALTH_CHARGING); - if (laser.overloaded) - { -#if 0 - BlitBitmap(pix[PIX_DOOR], drawto, - DOOR_GFX_PAGEX4 + XX_OVERLOAD, - DOOR_GFX_PAGEY1 + YY_OVERLOAD + OVERLOAD_YSIZE - - laser.overload_value, - OVERLOAD_XSIZE, laser.overload_value, - DX_OVERLOAD, DY_OVERLOAD + OVERLOAD_YSIZE - - laser.overload_value); -#endif - redraw_mask |= REDRAW_DOOR_1; - } - else - { -#if 0 - BlitBitmap(pix[PIX_DOOR], drawto, - DOOR_GFX_PAGEX5 + XX_OVERLOAD, DOOR_GFX_PAGEY1 + YY_OVERLOAD, - OVERLOAD_XSIZE, OVERLOAD_YSIZE - laser.overload_value, - DX_OVERLOAD, DY_OVERLOAD); -#endif - redraw_mask |= REDRAW_DOOR_1; - } - if (laser.overload_value == MAX_LASER_OVERLOAD) { UpdateAndDisplayGameControlValues(); @@ -3532,12 +3479,12 @@ static void GameActions_MM_Ext(void) game_mm.ball_choice_pos++; int new_element = native_mm_level.ball_content[element_pos]; - int new_element_unmapped = unmap_element(new_element); + int new_element_base = map_wall_to_base_element(new_element); - if (IS_WALL(new_element_unmapped)) + if (IS_WALL(new_element_base)) { // always use completely filled wall element - new_element = new_element_unmapped | 0x000f; + new_element = new_element_base | 0x000f; } else if (native_mm_level.rotate_ball_content && get_num_elements(new_element) > 1) @@ -3554,96 +3501,6 @@ static void GameActions_MM_Ext(void) laser.dest_element_last = Tile[ELX][ELY]; - return; - -#if 0 - int graphic; - - switch (RND(5)) - { - case 0: - element = EL_MIRROR_START + RND(16); - break; - case 1: - { - int rnd = RND(3); - - element = (rnd == 0 ? EL_KETTLE : rnd == 1 ? EL_BOMB : EL_PRISM); - } - break; - default: - { - int rnd = RND(3); - - element = (rnd == 0 ? EL_FUSE_ON : - rnd >= 1 && rnd <= 4 ? EL_PACMAN_RIGHT + rnd - 1 : - rnd >= 5 && rnd <= 20 ? EL_POLAR_START + rnd - 5 : - rnd >= 21 && rnd <= 24 ? EL_POLAR_CROSS_START + rnd - 21 : - EL_MIRROR_FIXED_START + rnd - 25); - } - break; - } - - graphic = el2gfx(element); - - for (i = 0; i < 50; i++) - { - int x = RND(26); - int y = RND(26); - -#if 0 - BlitBitmap(pix[PIX_BACK], drawto, - SX + (graphic % GFX_PER_LINE) * TILEX + x, - SY + (graphic / GFX_PER_LINE) * TILEY + y, 6, 6, - SX + ELX * TILEX + x, - SY + ELY * TILEY + y); -#endif - MarkTileDirty(ELX, ELY); - BackToFront(); - - DrawLaser(0, DL_LASER_ENABLED); - - Delay_WithScreenUpdates(50); - } - - Tile[ELX][ELY] = element; - DrawField_MM(ELX, ELY); - -#if 0 - Debug("game:mm:GameActions_MM_Ext", "NEW ELEMENT: (%d, %d)", ELX, ELY); -#endif - - // above stuff: GRAY BALL -> PRISM !!! -/* - LX = ELX * TILEX + 14; - LY = ELY * TILEY + 14; - if (laser.current_angle == (laser.current_angle >> 1) << 1) - OK = 8; - else - OK = 4; - LX -= OK * XS; - LY -= OK * YS; - - laser.num_edges -= 2; - laser.num_damages--; -*/ - -#if 0 - for (i = (laser.num_damages > 0 ? laser.num_damages - 1 : 0); i>=0; i--) - if (laser.damage[i].is_mirror) - break; - - if (i > 0) - DrawLaser(laser.damage[i].edge - 1, DL_LASER_DISABLED); - else - DrawLaser(0, DL_LASER_DISABLED); -#else - DrawLaser(0, DL_LASER_DISABLED); -#endif - - ScanLaser(); -#endif - return; } @@ -3651,48 +3508,18 @@ static void GameActions_MM_Ext(void) { PlayLevelSound_MM(ELX, ELY, element, MM_ACTION_SHRINKING); - { - Tile[ELX][ELY] = Tile[ELX][ELY] - EL_WALL_ICE + EL_WALL_CHANGING; - Store[ELX][ELY] = EL_WALL_ICE; - Store2[ELX][ELY] = laser.wall_mask; - - laser.dest_element = Tile[ELX][ELY]; - - return; - } - - for (i = 0; i < 5; i++) - { - int phase = i + 1; - - if (i == 4) - { - Tile[ELX][ELY] &= (laser.wall_mask ^ 0xFF); - phase = 0; - } - - DrawWallsAnimation_MM(ELX, ELY, Tile[ELX][ELY], phase, laser.wall_mask); - BackToFront(); - Delay_WithScreenUpdates(100); - } - - if (Tile[ELX][ELY] == EL_WALL_ICE) - Tile[ELX][ELY] = EL_EMPTY; - -/* - laser.num_edges--; - LX = laser.edge[laser.num_edges].x - cSX2; - LY = laser.edge[laser.num_edges].y - cSY2; -*/ + Tile[ELX][ELY] = Tile[ELX][ELY] - EL_WALL_ICE_BASE + EL_WALL_CHANGING_BASE; + Store[ELX][ELY] = EL_WALL_ICE_BASE; + Store2[ELX][ELY] = laser.wall_mask; - ScanLaser_FromLastMirror(); + laser.dest_element = Tile[ELX][ELY]; return; } if (IS_WALL_AMOEBA(element) && CT > 60) { - int k1, k2, k3, dx, dy, de, dm; + int k1, k2, k3; int element2 = Tile[ELX][ELY]; if (element2 != EL_EMPTY && !IS_WALL_AMOEBA(element)) @@ -3763,44 +3590,17 @@ static void GameActions_MM_Ext(void) Tile[ELX][ELY] = element | laser.wall_mask; - dx = ELX; - dy = ELY; - de = Tile[ELX][ELY]; - dm = laser.wall_mask; + int x = ELX, y = ELY; + int wall_mask = laser.wall_mask; -#if 1 - { - int x = ELX, y = ELY; - int wall_mask = laser.wall_mask; - - ScanLaser(); - DrawLaser(0, DL_LASER_ENABLED); - - PlayLevelSound_MM(dx, dy, element, MM_ACTION_GROWING); - - Tile[x][y] = Tile[x][y] - EL_WALL_AMOEBA + EL_WALL_CHANGING; - Store[x][y] = EL_WALL_AMOEBA; - Store2[x][y] = wall_mask; - - return; - } -#endif - - DrawWallsAnimation_MM(dx, dy, de, 4, dm); ScanLaser(); DrawLaser(0, DL_LASER_ENABLED); - PlayLevelSound_MM(dx, dy, element, MM_ACTION_GROWING); - - for (i = 4; i >= 0; i--) - { - DrawWallsAnimation_MM(dx, dy, de, i, dm); + PlayLevelSound_MM(x, y, element, MM_ACTION_GROWING); - BackToFront(); - Delay_WithScreenUpdates(20); - } - - DrawLaser(0, DL_LASER_ENABLED); + Tile[x][y] = Tile[x][y] - EL_WALL_AMOEBA_BASE + EL_WALL_CHANGING_BASE; + Store[x][y] = EL_WALL_AMOEBA_BASE; + Store2[x][y] = wall_mask; return; } @@ -3892,8 +3692,6 @@ static void GameActions_MM_Ext(void) return; } - - return; } void GameActions_MM(struct MouseActionInfo action) @@ -3906,7 +3704,7 @@ void GameActions_MM(struct MouseActionInfo action) CheckSingleStepMode_MM(element_clicked, button_released); } -void MovePacMen(void) +static void MovePacMen(void) { int mx, my, ox, oy, nx, ny; int element; @@ -4068,16 +3866,6 @@ static int MovingOrBlocked2Element_MM(int x, int y) return element; } -#if 0 -static void RemoveField(int x, int y) -{ - Tile[x][y] = EL_EMPTY; - MovPos[x][y] = 0; - MovDir[x][y] = 0; - MovDelay[x][y] = 0; -} -#endif - static void RemoveMovingField_MM(int x, int y) { int oldx = x, oldy = y, newx = x, newy = y; @@ -4107,44 +3895,6 @@ static void RemoveMovingField_MM(int x, int y) DrawLevelField_MM(newx, newy); } -void PlaySoundLevel(int x, int y, int sound_nr) -{ - int sx = SCREENX(x), sy = SCREENY(y); - int volume, stereo; - int silence_distance = 8; - - if ((!setup.sound_simple && !IS_LOOP_SOUND(sound_nr)) || - (!setup.sound_loops && IS_LOOP_SOUND(sound_nr))) - return; - - if (!IN_LEV_FIELD(x, y) || - sx < -silence_distance || sx >= SCR_FIELDX+silence_distance || - sy < -silence_distance || sy >= SCR_FIELDY+silence_distance) - return; - - volume = SOUND_MAX_VOLUME; - -#ifndef MSDOS - stereo = (sx - SCR_FIELDX/2) * 12; -#else - stereo = SOUND_MIDDLE + (2 * sx - (SCR_FIELDX - 1)) * 5; - if (stereo > SOUND_MAX_RIGHT) - stereo = SOUND_MAX_RIGHT; - if (stereo < SOUND_MAX_LEFT) - stereo = SOUND_MAX_LEFT; -#endif - - if (!IN_SCR_FIELD(sx, sy)) - { - int dx = ABS(sx - SCR_FIELDX/2) - SCR_FIELDX/2; - int dy = ABS(sy - SCR_FIELDY/2) - SCR_FIELDY/2; - - volume -= volume * (dx > dy ? dx : dy) / silence_distance; - } - - PlaySoundExt(sound_nr, volume, stereo, SND_CTRL_PLAY_SOUND); -} - static void RaiseScore_MM(int value) { game_mm.score += value;