summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.appveyor.yml8
-rw-r--r--src/audio/AudioManager.cpp192
-rw-r--r--src/audio/AudioManager.h42
-rw-r--r--src/audio/MusicManager.cpp172
-rw-r--r--src/audio/MusicManager.h5
-rw-r--r--src/core/common.h4
6 files changed, 269 insertions, 154 deletions
diff --git a/.appveyor.yml b/.appveyor.yml
index 39352f0e..03045599 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -1,5 +1,5 @@
version: 1.0.{build}
-image: Visual Studio 2019
+image: Visual Studio 2017
configuration:
- Debug
- Release
@@ -10,7 +10,7 @@ install:
- cmd: >-
git submodule update --init --recursive
- premake-vs2019.cmd
+ premake-vs2017.cmd
build:
project: build/re3.sln
verbosity: minimal
@@ -29,12 +29,10 @@ after_build:
$url = "$releases/download/$latestVersion/$name"
-
Start-FileDownload $url -FileName 'C:\Ultimate-ASI-Loader.zip'
7z e c:\Ultimate-ASI-Loader.zip -oc:\Projects\re3\bin\${env:CONFIGURATION}
-
cd "bin\${env:CONFIGURATION}"
copy re3.dll re3.asi
@@ -44,4 +42,4 @@ after_build:
Get-ChildItem .\*.zip | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
artifacts:
- path: bin/%CONFIGURATION%/re3.dll
- name: re3.dll \ No newline at end of file
+ name: re3.dll
diff --git a/src/audio/AudioManager.cpp b/src/audio/AudioManager.cpp
index ae520684..20542c46 100644
--- a/src/audio/AudioManager.cpp
+++ b/src/audio/AudioManager.cpp
@@ -41,6 +41,7 @@ bool &bPlayerJustEnteredCar = *(bool *)0x6508C4;
bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E;
uint32 *gMinTimeToNextReport = (uint32 *)0x8E2828;
uint8 &gSpecialSuspectLastSeenReport = *(uint8 *)0x95CD4D;
+uint32 *gOneShotCol = (uint32 *)0x604BD0;
constexpr int totalAudioEntitiesSlots = 200;
constexpr int maxVolume = 127;
@@ -3136,9 +3137,9 @@ cAudioManager::Initialise()
void
cAudioManager::InitialisePoliceRadio()
{
- unk2 = 0;
+ policeChannelTimer = 0;
unk3 = 0;
- unk4 = 0;
+ policeChannelCounterSeconds = 0;
for(int32 i = 0; i < 10; i++) { crimes[i].type = 0; }
SampleManager.SetChannelReverbFlag(28, 0);
@@ -8170,9 +8171,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
void
cAudioManager::ReportCrime(int32 type, const CVector *pos)
{
- int32 lastCrime;
-
- lastCrime = 10;
+ int32 lastCrime = 10;
if(m_bIsInitialised && MusicManager.m_nMusicMode != 2 &&
FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && (type > 0 || type < 17) &&
m_nTimeOfRecentCrime >= gMinTimeToNextReport[type]) {
@@ -8257,10 +8256,22 @@ cAudioManager::ResetTimers(uint32 time)
}
}
-WRAPPER void
+void
cAudioManager::Service()
{
- EAXJMP(0x57A2A0);
+ GenerateIntegerRandomNumberTable();
+ if(m_bTimerJustReset) {
+ ResetAudioLogicTimers(m_nTimer);
+ MusicManager.ResetTimers(m_nTimer);
+ m_bTimerJustReset = 0;
+ }
+ if(m_bIsInitialised) {
+ m_bPreviousUserPause = m_bUserPause;
+ m_bUserPause = CTimer::GetIsUserPaused();
+ UpdateReflections();
+ ServiceSoundEffects();
+ MusicManager.Service();
+ }
}
WRAPPER
@@ -8273,7 +8284,7 @@ cAudioManager::ServiceCollisions()
void
cAudioManager::ServicePoliceRadio()
{
- int wantedLevel = 0; // bug?;
+ int32 wantedLevel = 0; // bug?;
static uint32 nLastSeen = 300;
if(m_bIsInitialised) {
@@ -8298,7 +8309,6 @@ cAudioManager::ServicePoliceRadio()
void
cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
{
-
bool processed = false;
uint32 sample;
int32 freq;
@@ -8322,12 +8332,12 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
bMissionAudioPhysicalPlayingStatus == 1) {
SampleManager.PauseStream(0, 1u);
}
- if(!unk2) bChannelOpen = 0;
+ if(!policeChannelTimer) bChannelOpen = 0;
if(cWait) {
--cWait;
return;
}
- if(g_nMissionAudioSfx != 3032 && !bChannelOpen) {
+ if(g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && !bChannelOpen) {
if(g_nMissionAudioPlayingStatus) {
if(g_nMissionAudioPlayingStatus == 1 &&
!bMissionAudioPhysicalPlayingStatus &&
@@ -8358,11 +8368,12 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
if(bChannelOpen) DoPoliceRadioCrackle();
if((g_nMissionAudioSfx == TOTAL_AUDIO_SAMPLES ||
g_nMissionAudioPlayingStatus != 1) &&
- !SampleManager.GetChannelUsedFlag(policeChannel) && unk2) {
- if(unk2) {
- sample = *(uint32 *)&stuff[4 * unk4];
- --unk2;
- unk4 = (unk4 + 1) % 60;
+ !SampleManager.GetChannelUsedFlag(policeChannel) && policeChannelTimer) {
+ if(policeChannelTimer) {
+ sample = *(uint32 *)&stuff[4 * policeChannelCounterSeconds];
+ --policeChannelTimer;
+ policeChannelCounterSeconds =
+ (policeChannelCounterSeconds + 1) % 60;
} else {
sample = TOTAL_AUDIO_SAMPLES;
}
@@ -8403,15 +8414,6 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
}
}
}
-#if 1
-WRAPPER
-void
-cAudioManager::ServiceSoundEffects()
-{
-
-}
-
-#else
void
cAudioManager::ServiceSoundEffects()
@@ -8460,7 +8462,7 @@ cAudioManager::ServiceSoundEffects()
}
m_nScriptObjectEntityTotal = 0;
}
-#endif
+
int8
cAudioManager::SetCurrent3DProvider(uint8 which)
{
@@ -8502,9 +8504,10 @@ cAudioManager::SetEffectsMasterVolume(uint8 volume) const
void
cAudioManager::SetEntityStatus(int32 id, bool status)
{
- if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots) {
- if(m_asAudioEntities[id].m_bIsUsed) { m_asAudioEntities[id].m_bStatus = status; }
- }
+ if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots &&
+ m_asAudioEntities[id].m_bIsUsed) {
+ m_asAudioEntities[id].m_bStatus = status;
+ }
}
uint32
@@ -8591,7 +8594,7 @@ cAudioManager::SetMusicMasterVolume(uint8 volume) const
void
cAudioManager::SetSpeakerConfig(int32 conf) const
{
- SampleManager.SetSpeakerConfig(conf);
+ SampleManager.SetSpeakerConfig(conf);
}
void
@@ -8628,6 +8631,113 @@ cAudioManager::SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter)
}
}
+void
+cAudioManager::SetUpOneShotCollisionSound(cAudioCollision *col)
+{
+ int16 s1;
+ int16 s2;
+
+ int32 emittingVol;
+ float ratio;
+
+ static uint16 counter = 28;
+
+ for(int32 i = 0; i < 2; i++) {
+ if(i) {
+ s1 = col->m_bSurface2;
+ s2 = col->m_bSurface1;
+ } else {
+ s1 = col->m_bSurface1;
+ s2 = col->m_bSurface2;
+ }
+ ratio = GetCollisionOneShotRatio(s1, col->m_fIntensity1);
+ if(s1 == SURFACE_METAL6 && s2 == SURFACE_FLESH) ratio = 0.25f * ratio;
+ if(s1 == SURFACE_METAL6 && ratio < 0.6f) {
+ s1 = SURFACE_BILLBOARD;
+ ratio = min(1.f, 2.f * ratio);
+ }
+ emittingVol = 40.f * ratio;
+ if(emittingVol) {
+ m_sQueueSample.m_fDistance = Sqrt(col->m_fDistance);
+ m_sQueueSample.m_bVolume =
+ ComputeVolume(emittingVol, 60.f, m_sQueueSample.m_fDistance);
+ if(m_sQueueSample.m_bVolume) {
+ m_sQueueSample.m_nSampleIndex = gOneShotCol[s1];
+ switch(m_sQueueSample.m_nSampleIndex) {
+ case AUDIO_SAMPLE_COLLISION_PAVEMENT:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[3] % 5u;
+ break;
+ case AUDIO_SAMPLE_CAR_DOOR_MOVEMENT_1:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[0] % 6u;
+ break;
+ case AUDIO_SAMPLE_COLLISION_METAL_13:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[1] & 1;
+ break;
+ case AUDIO_SAMPLE_COLLISION_FENCE:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[3] & 3;
+ break;
+ case AUDIO_SAMPLE_COLLISION_FLESH:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[4] % 5u;
+ break;
+ case AUDIO_SAMPLE_COLLISION_WOOD:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[4] & 3;
+ break;
+ case AUDIO_SAMPLE_COLLISION_WOOD_BOX:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[1] & 3;
+ break;
+ case AUDIO_SAMPLE_COLLISION_HEDGE:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[2] % 5u;
+ break;
+ case AUDIO_SAMPLE_COLLISION_METAL_28:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[2] % 3u;
+ break;
+ case AUDIO_SAMPLE_COLLISION_METAL:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[1] % 5u;
+ break;
+ case AUDIO_SAMPLE_COLLISION_LOOSE:
+ m_sQueueSample.m_nSampleIndex += m_anRandomTable[3] & 1;
+ break;
+ default: break;
+ }
+ switch(s1) {
+ case SURFACE_GLASS: m_sQueueSample.m_nFrequency = 13500; break;
+ case SURFACE_METAL15: m_sQueueSample.m_nFrequency = 8819; break;
+ case SURFACE_PUDDLE:
+ m_sQueueSample.m_nFrequency =
+ 2 * SampleManager.GetSampleBaseFrequency(
+ m_sQueueSample.m_nSampleIndex);
+ break;
+ case SURFACE_TIRE: m_sQueueSample.m_nFrequency = 6000; break;
+ case SURFACE_HARD24: m_sQueueSample.m_nFrequency = 8000; break;
+ default:
+ m_sQueueSample.m_nFrequency =
+ SampleManager.GetSampleBaseFrequency(
+ m_sQueueSample.m_nSampleIndex);
+ break;
+ }
+ m_sQueueSample.m_nFrequency +=
+ RandomDisplacement(m_sQueueSample.m_nFrequency / 16);
+ m_sQueueSample.m_counter = counter++;
+ if(counter >= 255u) counter = 28;
+ m_sQueueSample.m_vecPos = col->m_vecPosition;
+ m_sQueueSample.m_bBankIndex = 0;
+ m_sQueueSample.m_bIsDistant = 0;
+ m_sQueueSample.field_16 = 11;
+ m_sQueueSample.m_nLoopCount = 1;
+ m_sQueueSample.m_bEmittingVolume = emittingVol;
+ m_sQueueSample.m_nLoopStart = 0;
+ m_sQueueSample.m_nLoopEnd = -1;
+ m_sQueueSample.field_48 = 4.0;
+ m_sQueueSample.m_fSoundIntensity = 60.0;
+ m_sQueueSample.field_56 = 1;
+ m_sQueueSample.m_bReverbFlag = 1;
+ m_sQueueSample.m_bRequireReflection = 0;
+ AddSampleToRequestedQueue();
+ }
+ }
+ }
+}
+
WRAPPER
bool
cAudioManager::SetupCrimeReport()
@@ -8641,11 +8751,9 @@ bool cAudioManager::SetupJumboEngineSound(uint8, int32) { EAXJMP(0x56F140); }
bool
cAudioManager::SetupJumboFlySound(uint8 emittingVol)
{
- int32 vol;
-
if(m_sQueueSample.m_fDistance >= 440.0f) return 0;
- vol = ComputeVolume(emittingVol, 440.0f, m_sQueueSample.m_fDistance);
+ int32 vol = ComputeVolume(emittingVol, 440.0f, m_sQueueSample.m_fDistance);
m_sQueueSample.m_bVolume = vol;
if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_FLY_SOUND;
@@ -8712,11 +8820,9 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol)
bool
cAudioManager::SetupJumboTaxiSound(uint8 vol)
{
- uint8 emittingVol;
-
if(m_sQueueSample.m_fDistance >= 180.f) return 0;
- emittingVol = (vol + (vol * m_sQueueSample.m_fDistance / 180)) / 2;
+ uint8 emittingVol = (vol + (vol * m_sQueueSample.m_fDistance / 180)) / 2;
if(m_sQueueSample.m_fDistance / 180 < 0.7f)
emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100;
@@ -8969,6 +9075,13 @@ cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile)
automobile->m_fGasPedalAudio = newGasPedalAudio;
}
+WRAPPER
+void
+cAudioManager::UpdateReflections()
+{
+ EAXJMP(0x57B470);
+}
+
bool
cAudioManager::UsesReverseWarning(int32 model) const
{
@@ -9210,19 +9323,23 @@ InjectHook(0x5803D0, &cAudioManager::ReportCrime, PATCH_JUMP);
InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP);
InjectHook(0x57EFF0, &cAudioManager::ResetPoliceRadio, PATCH_JUMP);
InjectHook(0x57A7B0, &cAudioManager::ResetTimers, PATCH_JUMP);
+InjectHook(0x57A2A0, &cAudioManager::Service, PATCH_JUMP);
InjectHook(0x57F110, &cAudioManager::ServicePoliceRadio, PATCH_JUMP);
InjectHook(0x57F1B0, &cAudioManager::ServicePoliceRadioChannel, PATCH_JUMP);
-//InjectHook(0x57AA60, &cAudioManager::ServiceSoundEffects, PATCH_JUMP);
+InjectHook(0x57AA60, &cAudioManager::ServiceSoundEffects, PATCH_JUMP);
InjectHook(0x57A910, &cAudioManager::SetCurrent3DProvider, PATCH_JUMP);
InjectHook(0x57AA00, &cAudioManager::SetDynamicAcousticModelingStatus, PATCH_JUMP);
InjectHook(0x57A770, &cAudioManager::SetEffectsFadeVolume, PATCH_JUMP);
InjectHook(0x57A730, &cAudioManager::SetEffectsMasterVolume, PATCH_JUMP);
InjectHook(0x57A4C0, &cAudioManager::SetEntityStatus, PATCH_JUMP);
+InjectHook(0x568E20, &cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol, PATCH_JUMP);
InjectHook(0x5795F0, &cAudioManager::SetMissionAudioLocation, PATCH_JUMP);
InjectHook(0x57F020, &cAudioManager::SetMissionScriptPoliceAudio, PATCH_JUMP);
InjectHook(0x57A790, &cAudioManager::SetMusicFadeVolume, PATCH_JUMP);
InjectHook(0x57A750, &cAudioManager::SetMusicMasterVolume, PATCH_JUMP);
InjectHook(0x57A9A0, &cAudioManager::SetSpeakerConfig, PATCH_JUMP);
+InjectHook(0x568D30, &cAudioManager::SetUpLoopingCollisionSound, PATCH_JUMP);
+InjectHook(0x5689D0, &cAudioManager::SetUpOneShotCollisionSound, PATCH_JUMP);
InjectHook(0x56F230, &cAudioManager::SetupJumboFlySound, PATCH_JUMP);
InjectHook(0x56F310, &cAudioManager::SetupJumboRumbleSound, PATCH_JUMP);
InjectHook(0x56EF20, &cAudioManager::SetupJumboTaxiSound, PATCH_JUMP);
@@ -9238,4 +9355,5 @@ InjectHook(0x57C320, &cAudioManager::sub_57C320, PATCH_JUMP);
InjectHook(0x5755C0, &cPedComments::Add, PATCH_JUMP);
InjectHook(0x575730, &cPedComments::Process, PATCH_JUMP);
InjectHook(0x5685E0, &cAudioCollisionManager::AddCollisionToRequestedQueue, PATCH_JUMP);
+InjectHook(0x57C430, &cAudioScriptObject::Reset, PATCH_JUMP);
ENDPATCHES
diff --git a/src/audio/AudioManager.h b/src/audio/AudioManager.h
index 59a92a48..35c6f257 100644
--- a/src/audio/AudioManager.h
+++ b/src/audio/AudioManager.h
@@ -200,7 +200,7 @@ public:
CVector Posn;
int32 AudioEntity;
- void Reset(); // todo hook
+ void Reset(); /// ok
static void *operator new(size_t);
static void *operator new(size_t, int);
@@ -284,9 +284,9 @@ public:
int32 m_nPoliceChannelEntity;
uint8 stuff[239];
uint8 unk1;
- uint8 unk2;
+ uint8 policeChannelTimer;
uint8 unk3;
- uint8 unk4;
+ uint8 policeChannelCounterSeconds;
uint8 unk5;
Crime crimes[10];
int32 m_nFrontEndEntity;
@@ -417,7 +417,7 @@ public:
uint8 GetCDAudioDriveLetter() const;
int8 GetCurrent3DProviderIndex() const; /// ok
float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used
- float GetCollisionOneShotRatio(int32 a, float b) const; /// ok
+ float GetCollisionOneShotRatio(int32 a, float b) const; /// ok
float GetCollisionRatio(float a, float b, float c, float d) const; /// ok
float GetDistanceSquared(CVector *v) const; /// ok
int32 GetJumboTaxiFreq() const; /// ok
@@ -528,12 +528,12 @@ public:
void ReleaseDigitalHandle() const;
void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2,
float collisionPower, float intensity2); /// ok
- void ReportCrime(int32 crime, const CVector *pos); /// ok
- void ResetAudioLogicTimers(int32 timer); /// ok
- void ResetPoliceRadio(); /// ok
- void ResetTimers(uint32 time); /// ok
+ void ReportCrime(int32 crime, const CVector *pos); /// ok
+ void ResetAudioLogicTimers(int32 timer); /// ok
+ void ResetPoliceRadio(); /// ok
+ void ResetTimers(uint32 time); /// ok
- void Service(); // todo
+ void Service(); /// ok
void ServiceCollisions(); // todo
void ServicePoliceRadio(); /// ok
void ServicePoliceRadioChannel(int32 wantedLevel); /// ok
@@ -543,28 +543,30 @@ public:
void SetEffectsFadeVolume(uint8 volume) const;
void SetEffectsMasterVolume(uint8 volume) const;
void SetEntityStatus(int32 id, bool status);
- uint32 SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision); // todo hook
+ uint32
+ SetLoopingCollisionRequestedSfxFreqAndGetVol(cAudioCollision *audioCollision); /// ok
void SetMissionAudioLocation(float x, float y, float z);
void SetMissionScriptPoliceAudio(int32 sfx) const;
void SetMonoMode(uint8); // todo (mobile)
void SetMusicFadeVolume(uint8 volume) const;
void SetMusicMasterVolume(uint8 volume) const;
void SetSpeakerConfig(int32 conf) const;
- void SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter); // todo hook
- void SetUpOneShotCollisionSound(int a2); // todo
- bool SetupCrimeReport(); // todo
- bool SetupJumboEngineSound(uint8 a2, int32 a3); // todo
- bool SetupJumboFlySound(uint8 emittingVol); /// ok
- bool SetupJumboRumbleSound(uint8 emittingVol); /// ok
- bool SetupJumboTaxiSound(uint8 vol); /// ok
- bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok
- void SetupPedComments(cPedParams *params, uint32 sound); /// ok
- void SetupSuspectLastSeenReport(); // todo
+ void SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter); /// ok
+ void SetUpOneShotCollisionSound(cAudioCollision *col); /// ok
+ bool SetupCrimeReport(); // todo
+ bool SetupJumboEngineSound(uint8 a2, int32 a3); // todo
+ bool SetupJumboFlySound(uint8 emittingVol); /// ok
+ bool SetupJumboRumbleSound(uint8 emittingVol); /// ok
+ bool SetupJumboTaxiSound(uint8 vol); /// ok
+ bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok
+ void SetupPedComments(cPedParams *params, uint32 sound); /// ok
+ void SetupSuspectLastSeenReport(); // todo
void Terminate();
void TranslateEntity(CVector *v1, CVector *v2) const;
void UpdateGasPedalAudio(CAutomobile *automobile);
+ void UpdateReflections(); // todo
bool UsesReverseWarning(int32 model) const;
bool UsesSiren(int32 model) const;
bool UsesSirenSwitching(int32 model) const;
diff --git a/src/audio/MusicManager.cpp b/src/audio/MusicManager.cpp
index a14994cd..fa1a9390 100644
--- a/src/audio/MusicManager.cpp
+++ b/src/audio/MusicManager.cpp
@@ -1,34 +1,38 @@
-#include "common.h"
-#include "patcher.h"
#include "MusicManager.h"
+#include "Camera.h"
#include "Font.h"
#include "Hud.h"
+#include "ModelIndices.h"
+#include "Replay.h"
#include "Text.h"
#include "Timer.h"
-#include "Camera.h"
#include "World.h"
-#include "ModelIndices.h"
#include "sampman.h"
-#include "Replay.h"
+#include "patcher.h"
-cMusicManager &MusicManager = *(cMusicManager*)0x8F3964;
-int32 &gNumRetunePresses = *(int32*)0x650B80;
-wchar *pCurrentStation = (wchar*)0x650B9C;
-uint8 &cDisplay = *(uint8*)0x650BA1;
+cMusicManager &MusicManager = *(cMusicManager *)0x8F3964;
+int32 &gNumRetunePresses = *(int32 *)0x650B80;
+wchar *pCurrentStation = (wchar *)0x650B9C;
+uint8 &cDisplay = *(uint8 *)0x650BA1;
-WRAPPER char* cMusicManager::Get3DProviderName(char) { EAXJMP(0x57A8C0); }
+WRAPPER char *
+cMusicManager::Get3DProviderName(char)
+{
+ EAXJMP(0x57A8C0);
+}
-bool cMusicManager::PlayerInCar()
+bool
+cMusicManager::PlayerInCar()
{
- if (!FindPlayerVehicle())
+ if(!FindPlayerVehicle())
return false;
else {
int32 State = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_nPedState;
- if (State == PED_DRAG_FROM_CAR || State == PED_EXIT_CAR || State == PED_ARRESTED)
+ if(State == PED_DRAG_FROM_CAR || State == PED_EXIT_CAR || State == PED_ARRESTED)
return false;
- switch (FindPlayerVehicle()->m_modelIndex) {
+ switch(FindPlayerVehicle()->m_modelIndex) {
case MI_FIRETRUCK:
case MI_AMBULAN:
case MI_MRWHOOP:
@@ -36,10 +40,8 @@ bool cMusicManager::PlayerInCar()
case MI_TRAIN:
case MI_SPEEDER:
case MI_REEFER:
- case MI_GHOST:
- return false;
- default:
- return true;
+ case MI_GHOST: return false;
+ default: return true;
}
}
}
@@ -47,56 +49,53 @@ bool cMusicManager::PlayerInCar()
#if 0
WRAPPER void cMusicManager::DisplayRadioStationName(void) { EAXJMP(0x57E6D0); }
#else
-void cMusicManager::DisplayRadioStationName()
+void
+cMusicManager::DisplayRadioStationName()
{
int8 pRetune;
int8 gStreamedSound;
int8 gRetuneCounter;
- if (!CTimer::GetIsPaused() && !TheCamera.m_WideScreenOn && cMusicManager::PlayerInCar() && !CReplay::IsPlayingBack()) {
- if (MusicManager.m_bPlayerInCar && !MusicManager.m_bPreviousPlayerInCar)
+ if(!CTimer::GetIsPaused() && !TheCamera.m_WideScreenOn && cMusicManager::PlayerInCar() &&
+ !CReplay::IsPlayingBack()) {
+ if(MusicManager.m_bPlayerInCar && !MusicManager.m_bPreviousPlayerInCar)
pCurrentStation = nil;
- if (SampleManager.IsMP3RadioChannelAvailable()) {
+ if(SampleManager.IsMP3RadioChannelAvailable()) {
gStreamedSound = MusicManager.m_nCurrentStreamedSound;
- if (gStreamedSound != STREAMED_SOUND_CITY_AMBIENT && gStreamedSound != STREAMED_SOUND_WATER_AMBIENT) {
- if (gStreamedSound > STREAMED_SOUND_RADIO_MP3_PLAYER)
- return;
- }
- else {
+ if(gStreamedSound != STREAMED_SOUND_CITY_AMBIENT &&
+ gStreamedSound != STREAMED_SOUND_WATER_AMBIENT) {
+ if(gStreamedSound > STREAMED_SOUND_RADIO_MP3_PLAYER) return;
+ } else {
gStreamedSound = STREAMED_SOUND_RADIO_POLICE;
}
pRetune = gNumRetunePresses + gStreamedSound;
- if (pRetune == POLICE_RADIO) {
+ if(pRetune == POLICE_RADIO) {
pRetune = RADIO_OFF;
- }
- else if (pRetune > POLICE_RADIO) {
+ } else if(pRetune > POLICE_RADIO) {
pRetune = pRetune - 11;
}
- }
- else {
+ } else {
gStreamedSound = MusicManager.m_nCurrentStreamedSound;
pRetune = gNumRetunePresses + gStreamedSound;
- if (pRetune >= USERTRACK) {
+ if(pRetune >= USERTRACK) {
gRetuneCounter = gNumRetunePresses;
pRetune = MusicManager.m_nCurrentStreamedSound;
- if (gStreamedSound == STREAMED_SOUND_WATER_AMBIENT)
+ if(gStreamedSound == STREAMED_SOUND_WATER_AMBIENT)
pRetune = RADIO_OFF;
- while (gRetuneCounter) {
- if (pRetune == RADIO_OFF) {
+ while(gRetuneCounter) {
+ if(pRetune == RADIO_OFF) {
pRetune = HEAD_RADIO;
- }
- else if (pRetune < USERTRACK) {
+ } else if(pRetune < USERTRACK) {
pRetune = pRetune + 1;
}
- if (pRetune == USERTRACK)
- pRetune = RADIO_OFF;
+ if(pRetune == USERTRACK) pRetune = RADIO_OFF;
--gRetuneCounter;
}
@@ -105,52 +104,29 @@ void cMusicManager::DisplayRadioStationName()
wchar *string = nil;
- switch (pRetune) {
- case HEAD_RADIO:
- string = TheText.Get("FEA_FM0");
- break;
- case DOUBLE_CLEF:
- string = TheText.Get("FEA_FM1");
- break;
- case JAH_RADIO:
- string = TheText.Get("FEA_FM2");
- break;
- case RISE_FM:
- string = TheText.Get("FEA_FM3");
- break;
- case LIPS_106:
- string = TheText.Get("FEA_FM4");
- break;
- case GAME_FM:
- string = TheText.Get("FEA_FM5");
- break;
- case MSX_FM:
- string = TheText.Get("FEA_FM6");
- break;
- case FLASHBACK:
- string = TheText.Get("FEA_FM7");
- break;
- case CHATTERBOX:
- string = TheText.Get("FEA_FM8");
- break;
- case USERTRACK:
- string = TheText.Get("FEA_FM9");
- break;
- default:
- return;
+ switch(pRetune) {
+ case HEAD_RADIO: string = TheText.Get("FEA_FM0"); break;
+ case DOUBLE_CLEF: string = TheText.Get("FEA_FM1"); break;
+ case JAH_RADIO: string = TheText.Get("FEA_FM2"); break;
+ case RISE_FM: string = TheText.Get("FEA_FM3"); break;
+ case LIPS_106: string = TheText.Get("FEA_FM4"); break;
+ case GAME_FM: string = TheText.Get("FEA_FM5"); break;
+ case MSX_FM: string = TheText.Get("FEA_FM6"); break;
+ case FLASHBACK: string = TheText.Get("FEA_FM7"); break;
+ case CHATTERBOX: string = TheText.Get("FEA_FM8"); break;
+ case USERTRACK: string = TheText.Get("FEA_FM9"); break;
+ default: return;
};
- if (pRetune > CHATTERBOX && !SampleManager.IsMP3RadioChannelAvailable()) {
- return;
- }
+ if(pRetune > CHATTERBOX && !SampleManager.IsMP3RadioChannelAvailable()) { return; }
- if (string && pCurrentStation != string || MusicManager.m_nCurrentStreamedSound == STREAMED_SOUND_RADIO_MP3_PLAYER && MusicManager.m_nPreviousStreamedSound != STREAMED_SOUND_RADIO_MP3_PLAYER) {
+ if(string && pCurrentStation != string ||
+ MusicManager.m_nCurrentStreamedSound == STREAMED_SOUND_RADIO_MP3_PLAYER &&
+ MusicManager.m_nPreviousStreamedSound != STREAMED_SOUND_RADIO_MP3_PLAYER) {
pCurrentStation = string;
cDisplay = 60;
- }
- else {
- if (!cDisplay)
- return;
+ } else {
+ if(!cDisplay) return;
--cDisplay;
}
@@ -164,7 +140,7 @@ void cMusicManager::DisplayRadioStationName()
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_WIDTH / 2 + SCREEN_SCALE_X(2.0f), SCREEN_SCALE_Y(22.0f) + SCREEN_SCALE_Y(2.0f), pCurrentStation);
- if (gNumRetunePresses)
+ if(gNumRetunePresses)
CFont::SetColor(CRGBA(102, 133, 143, 255));
else
CFont::SetColor(CRGBA(147, 196, 211, 255));
@@ -203,38 +179,44 @@ cMusicManager::StopFrontEndTrack()
EAXJMP(0x57E3D0);
}
-
-WRAPPER void cMusicManager::PlayAnnouncement(unsigned char)
+WRAPPER void
+cMusicManager::PlayAnnouncement(unsigned char)
{
EAXJMP(0x57E430);
}
-WRAPPER void cMusicManager::PlayFrontEndTrack(unsigned char, unsigned char)
+WRAPPER void
+cMusicManager::PlayFrontEndTrack(unsigned char, unsigned char)
{
EAXJMP(0x57E2E0);
}
-WRAPPER void cMusicManager::PreloadCutSceneMusic(unsigned char)
+WRAPPER void
+cMusicManager::PreloadCutSceneMusic(unsigned char)
{
EAXJMP(0x57E210);
}
-WRAPPER void cMusicManager::PlayPreloadedCutSceneMusic(void)
+WRAPPER void
+cMusicManager::PlayPreloadedCutSceneMusic(void)
{
EAXJMP(0x57E290);
}
-WRAPPER void cMusicManager::StopCutSceneMusic(void)
+WRAPPER void
+cMusicManager::StopCutSceneMusic(void)
{
EAXJMP(0x57E2B0);
}
-WRAPPER int32 cMusicManager::GetRadioInCar(void)
+WRAPPER int32
+cMusicManager::GetRadioInCar(void)
{
EAXJMP(0x57D1D0);
}
-WRAPPER void cMusicManager::SetRadioInCar(unsigned int)
+WRAPPER void
+cMusicManager::SetRadioInCar(unsigned int)
{
EAXJMP(0x57D2C0);
}
@@ -250,4 +232,14 @@ void
cMusicManager::ResetMusicAfterReload()
{
EAXJMP(0x57CF30);
+}
+
+WRAPPER
+void cMusicManager::ResetTimers(int32) { EAXJMP(0x57D420); }
+
+WRAPPER
+void
+cMusicManager::Service()
+{
+ EAXJMP(0x57D440);
} \ No newline at end of file
diff --git a/src/audio/MusicManager.h b/src/audio/MusicManager.h
index 6ced08f7..47f3ad68 100644
--- a/src/audio/MusicManager.h
+++ b/src/audio/MusicManager.h
@@ -1,5 +1,7 @@
#pragma once
+#include "common.h"
+
enum eRadioStation
{
HEAD_RADIO,
@@ -297,6 +299,9 @@ public:
void SetRadioChannelByScript(unsigned char, int);
void ResetMusicAfterReload();
+
+ void ResetTimers(int32);
+ void Service();
};
static_assert(sizeof(cMusicManager) == 0x95C, "cMusicManager: error");
diff --git a/src/core/common.h b/src/core/common.h
index 0a2e6768..d3d4e049 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -197,8 +197,8 @@ void re3_assert(const char *expr, const char *filename, unsigned int lineno, con
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
#define BIT(num) (1<<(num))
-auto max = [](auto a, auto b) { return ((a) > (b)) ? (a) : (b); };
-auto min = [](auto a, auto b) { return ((a) < (b)) ? (a) : (b); };
+//auto max = [](auto a, auto b) { return ((a) > (b)) ? (a) : (b); };
+//auto min = [](auto a, auto b) { return ((a) < (b)) ? (a) : (b); };
#define ABS(a) (((a) < 0) ? (-(a)) : (a))
#define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min)))))