| 1951 | |
| 1952 | |
| 1953 | void cFodder::Music_Check_MapTile_TrackChange() { |
| 1954 | if (mPhase_Completed_Timer != 0 || mGame_Data.mGamePhase_Data.mIsComplete || mMapTile_Music_Play) |
| 1955 | return; |
| 1956 | |
| 1957 | if (mSquad_Leader == INVALID_SPRITE_PTR || mSquad_Leader == 0) |
| 1958 | return; |
| 1959 | |
| 1960 | int16_t spriteX = mSquad_Leader->field_0 >> 4; |
| 1961 | int16_t spriteY = mSquad_Leader->field_4 >> 4; |
| 1962 | |
| 1963 | int16_t BestDistance = 0x10; |
| 1964 | int16_t PlaySong = 0; |
| 1965 | |
| 1966 | for (const auto& tile : mMapTileTracks) { |
| 1967 | if (tile.X < 0) |
| 1968 | break; |
| 1969 | |
| 1970 | if (tile.Track > 4) |
| 1971 | continue; |
| 1972 | |
| 1973 | // Call to sub_A10F2 |
| 1974 | int16_t d0 = spriteX; |
| 1975 | int16_t d1 = spriteY; |
| 1976 | int16_t d2 = tile.X; |
| 1977 | int16_t d3 = tile.Y; |
| 1978 | int16_t d4 = 0x0F; |
| 1979 | int16_t result = Map_Get_Distance_BetweenPoints(d0, d1, d2, d4, d3); |
| 1980 | |
| 1981 | if (result < BestDistance) { |
| 1982 | BestDistance = result; |
| 1983 | PlaySong = tile.Track; |
| 1984 | } |
| 1985 | } |
| 1986 | |
| 1987 | |
| 1988 | int16_t d0, d1; |
| 1989 | |
| 1990 | if (BestDistance > 4) { |
| 1991 | if (BestDistance >= 0xA) { |
| 1992 | d0 = 1; |
| 1993 | d1 = (BestDistance - 8) << 1; |
| 1994 | d1 = d1 < 0x30 ? d1 : 0x30; |
| 1995 | } |
| 1996 | else { |
| 1997 | d0 = PlaySong; |
| 1998 | d1 = (BestDistance - 5) << 3; |
| 1999 | d1 = 0x38 - d1; |
| 2000 | } |
| 2001 | } |
| 2002 | else { |
| 2003 | d0 = PlaySong; |
| 2004 | d1 = 0x40; |
| 2005 | } |
| 2006 | |
| 2007 | Music_setup_track_unk(d0, d1); |
| 2008 | } |
| 2009 | |
| 2010 | void cFodder::Music_Fade_SwitchTrack() { |
nothing calls this directly
no outgoing calls
no test coverage detected