1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 12:30:00 +00:00

More work

This commit is contained in:
Filip Gawin 2019-09-21 22:10:35 +02:00
parent 12ee71e4f7
commit 003ac856c6
6 changed files with 270 additions and 155 deletions

View file

@ -1,5 +1,5 @@
version: 1.0.{build} version: 1.0.{build}
image: Visual Studio 2019 image: Visual Studio 2017
configuration: configuration:
- Debug - Debug
- Release - Release
@ -10,7 +10,7 @@ install:
- cmd: >- - cmd: >-
git submodule update --init --recursive git submodule update --init --recursive
premake-vs2019.cmd premake-vs2017.cmd
build: build:
project: build/re3.sln project: build/re3.sln
verbosity: minimal verbosity: minimal
@ -29,12 +29,10 @@ after_build:
$url = "$releases/download/$latestVersion/$name" $url = "$releases/download/$latestVersion/$name"
Start-FileDownload $url -FileName 'C:\Ultimate-ASI-Loader.zip' Start-FileDownload $url -FileName 'C:\Ultimate-ASI-Loader.zip'
7z e c:\Ultimate-ASI-Loader.zip -oc:\Projects\re3\bin\${env:CONFIGURATION} 7z e c:\Ultimate-ASI-Loader.zip -oc:\Projects\re3\bin\${env:CONFIGURATION}
cd "bin\${env:CONFIGURATION}" cd "bin\${env:CONFIGURATION}"
copy re3.dll re3.asi copy re3.dll re3.asi

View file

@ -41,6 +41,7 @@ bool &bPlayerJustEnteredCar = *(bool *)0x6508C4;
bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E; bool &g_bMissionAudioLoadFailed = *(bool *)0x95CD8E;
uint32 *gMinTimeToNextReport = (uint32 *)0x8E2828; uint32 *gMinTimeToNextReport = (uint32 *)0x8E2828;
uint8 &gSpecialSuspectLastSeenReport = *(uint8 *)0x95CD4D; uint8 &gSpecialSuspectLastSeenReport = *(uint8 *)0x95CD4D;
uint32 *gOneShotCol = (uint32 *)0x604BD0;
constexpr int totalAudioEntitiesSlots = 200; constexpr int totalAudioEntitiesSlots = 200;
constexpr int maxVolume = 127; constexpr int maxVolume = 127;
@ -3136,9 +3137,9 @@ cAudioManager::Initialise()
void void
cAudioManager::InitialisePoliceRadio() cAudioManager::InitialisePoliceRadio()
{ {
unk2 = 0; policeChannelTimer = 0;
unk3 = 0; unk3 = 0;
unk4 = 0; policeChannelCounterSeconds = 0;
for(int32 i = 0; i < 10; i++) { crimes[i].type = 0; } for(int32 i = 0; i < 10; i++) { crimes[i].type = 0; }
SampleManager.SetChannelReverbFlag(28, 0); SampleManager.SetChannelReverbFlag(28, 0);
@ -8170,9 +8171,7 @@ cAudioManager::ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface
void void
cAudioManager::ReportCrime(int32 type, const CVector *pos) cAudioManager::ReportCrime(int32 type, const CVector *pos)
{ {
int32 lastCrime; int32 lastCrime = 10;
lastCrime = 10;
if(m_bIsInitialised && MusicManager.m_nMusicMode != 2 && if(m_bIsInitialised && MusicManager.m_nMusicMode != 2 &&
FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && (type > 0 || type < 17) && FindPlayerPed()->m_pWanted->m_nWantedLevel > 0 && (type > 0 || type < 17) &&
m_nTimeOfRecentCrime >= gMinTimeToNextReport[type]) { m_nTimeOfRecentCrime >= gMinTimeToNextReport[type]) {
@ -8257,10 +8256,22 @@ cAudioManager::ResetTimers(uint32 time)
} }
} }
WRAPPER void void
cAudioManager::Service() 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 WRAPPER
@ -8273,7 +8284,7 @@ cAudioManager::ServiceCollisions()
void void
cAudioManager::ServicePoliceRadio() cAudioManager::ServicePoliceRadio()
{ {
int wantedLevel = 0; // bug?; int32 wantedLevel = 0; // bug?;
static uint32 nLastSeen = 300; static uint32 nLastSeen = 300;
if(m_bIsInitialised) { if(m_bIsInitialised) {
@ -8298,7 +8309,6 @@ cAudioManager::ServicePoliceRadio()
void void
cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel) cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
{ {
bool processed = false; bool processed = false;
uint32 sample; uint32 sample;
int32 freq; int32 freq;
@ -8322,12 +8332,12 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
bMissionAudioPhysicalPlayingStatus == 1) { bMissionAudioPhysicalPlayingStatus == 1) {
SampleManager.PauseStream(0, 1u); SampleManager.PauseStream(0, 1u);
} }
if(!unk2) bChannelOpen = 0; if(!policeChannelTimer) bChannelOpen = 0;
if(cWait) { if(cWait) {
--cWait; --cWait;
return; return;
} }
if(g_nMissionAudioSfx != 3032 && !bChannelOpen) { if(g_nMissionAudioSfx != TOTAL_AUDIO_SAMPLES && !bChannelOpen) {
if(g_nMissionAudioPlayingStatus) { if(g_nMissionAudioPlayingStatus) {
if(g_nMissionAudioPlayingStatus == 1 && if(g_nMissionAudioPlayingStatus == 1 &&
!bMissionAudioPhysicalPlayingStatus && !bMissionAudioPhysicalPlayingStatus &&
@ -8358,11 +8368,12 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
if(bChannelOpen) DoPoliceRadioCrackle(); if(bChannelOpen) DoPoliceRadioCrackle();
if((g_nMissionAudioSfx == TOTAL_AUDIO_SAMPLES || if((g_nMissionAudioSfx == TOTAL_AUDIO_SAMPLES ||
g_nMissionAudioPlayingStatus != 1) && g_nMissionAudioPlayingStatus != 1) &&
!SampleManager.GetChannelUsedFlag(policeChannel) && unk2) { !SampleManager.GetChannelUsedFlag(policeChannel) && policeChannelTimer) {
if(unk2) { if(policeChannelTimer) {
sample = *(uint32 *)&stuff[4 * unk4]; sample = *(uint32 *)&stuff[4 * policeChannelCounterSeconds];
--unk2; --policeChannelTimer;
unk4 = (unk4 + 1) % 60; policeChannelCounterSeconds =
(policeChannelCounterSeconds + 1) % 60;
} else { } else {
sample = TOTAL_AUDIO_SAMPLES; sample = TOTAL_AUDIO_SAMPLES;
} }
@ -8403,15 +8414,6 @@ cAudioManager::ServicePoliceRadioChannel(int32 wantedLevel)
} }
} }
} }
#if 1
WRAPPER
void
cAudioManager::ServiceSoundEffects()
{
}
#else
void void
cAudioManager::ServiceSoundEffects() cAudioManager::ServiceSoundEffects()
@ -8460,7 +8462,7 @@ cAudioManager::ServiceSoundEffects()
} }
m_nScriptObjectEntityTotal = 0; m_nScriptObjectEntityTotal = 0;
} }
#endif
int8 int8
cAudioManager::SetCurrent3DProvider(uint8 which) cAudioManager::SetCurrent3DProvider(uint8 which)
{ {
@ -8502,9 +8504,10 @@ cAudioManager::SetEffectsMasterVolume(uint8 volume) const
void void
cAudioManager::SetEntityStatus(int32 id, bool status) cAudioManager::SetEntityStatus(int32 id, bool status)
{ {
if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots) { if(m_bIsInitialised && id >= 0 && id < totalAudioEntitiesSlots &&
if(m_asAudioEntities[id].m_bIsUsed) { m_asAudioEntities[id].m_bStatus = status; } m_asAudioEntities[id].m_bIsUsed) {
} m_asAudioEntities[id].m_bStatus = status;
}
} }
uint32 uint32
@ -8591,7 +8594,7 @@ cAudioManager::SetMusicMasterVolume(uint8 volume) const
void void
cAudioManager::SetSpeakerConfig(int32 conf) const cAudioManager::SetSpeakerConfig(int32 conf) const
{ {
SampleManager.SetSpeakerConfig(conf); SampleManager.SetSpeakerConfig(conf);
} }
void 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 WRAPPER
bool bool
cAudioManager::SetupCrimeReport() cAudioManager::SetupCrimeReport()
@ -8641,11 +8751,9 @@ bool cAudioManager::SetupJumboEngineSound(uint8, int32) { EAXJMP(0x56F140); }
bool bool
cAudioManager::SetupJumboFlySound(uint8 emittingVol) cAudioManager::SetupJumboFlySound(uint8 emittingVol)
{ {
int32 vol;
if(m_sQueueSample.m_fDistance >= 440.0f) return 0; 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; m_sQueueSample.m_bVolume = vol;
if(m_sQueueSample.m_bVolume) { if(m_sQueueSample.m_bVolume) {
m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_FLY_SOUND; m_sQueueSample.m_nSampleIndex = AUDIO_SAMPLE_JUMBO_FLY_SOUND;
@ -8712,11 +8820,9 @@ cAudioManager::SetupJumboRumbleSound(uint8 emittingVol)
bool bool
cAudioManager::SetupJumboTaxiSound(uint8 vol) cAudioManager::SetupJumboTaxiSound(uint8 vol)
{ {
uint8 emittingVol;
if(m_sQueueSample.m_fDistance >= 180.f) return 0; 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) if(m_sQueueSample.m_fDistance / 180 < 0.7f)
emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100; emittingVol -= emittingVol * gJumboVolOffsetPercentage / 100;
@ -8969,6 +9075,13 @@ cAudioManager::UpdateGasPedalAudio(CAutomobile *automobile)
automobile->m_fGasPedalAudio = newGasPedalAudio; automobile->m_fGasPedalAudio = newGasPedalAudio;
} }
WRAPPER
void
cAudioManager::UpdateReflections()
{
EAXJMP(0x57B470);
}
bool bool
cAudioManager::UsesReverseWarning(int32 model) const cAudioManager::UsesReverseWarning(int32 model) const
{ {
@ -9210,19 +9323,23 @@ InjectHook(0x5803D0, &cAudioManager::ReportCrime, PATCH_JUMP);
InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP); InjectHook(0x569650, &cAudioManager::ResetAudioLogicTimers, PATCH_JUMP);
InjectHook(0x57EFF0, &cAudioManager::ResetPoliceRadio, PATCH_JUMP); InjectHook(0x57EFF0, &cAudioManager::ResetPoliceRadio, PATCH_JUMP);
InjectHook(0x57A7B0, &cAudioManager::ResetTimers, PATCH_JUMP); InjectHook(0x57A7B0, &cAudioManager::ResetTimers, PATCH_JUMP);
InjectHook(0x57A2A0, &cAudioManager::Service, PATCH_JUMP);
InjectHook(0x57F110, &cAudioManager::ServicePoliceRadio, PATCH_JUMP); InjectHook(0x57F110, &cAudioManager::ServicePoliceRadio, PATCH_JUMP);
InjectHook(0x57F1B0, &cAudioManager::ServicePoliceRadioChannel, 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(0x57A910, &cAudioManager::SetCurrent3DProvider, PATCH_JUMP);
InjectHook(0x57AA00, &cAudioManager::SetDynamicAcousticModelingStatus, PATCH_JUMP); InjectHook(0x57AA00, &cAudioManager::SetDynamicAcousticModelingStatus, PATCH_JUMP);
InjectHook(0x57A770, &cAudioManager::SetEffectsFadeVolume, PATCH_JUMP); InjectHook(0x57A770, &cAudioManager::SetEffectsFadeVolume, PATCH_JUMP);
InjectHook(0x57A730, &cAudioManager::SetEffectsMasterVolume, PATCH_JUMP); InjectHook(0x57A730, &cAudioManager::SetEffectsMasterVolume, PATCH_JUMP);
InjectHook(0x57A4C0, &cAudioManager::SetEntityStatus, PATCH_JUMP); InjectHook(0x57A4C0, &cAudioManager::SetEntityStatus, PATCH_JUMP);
InjectHook(0x568E20, &cAudioManager::SetLoopingCollisionRequestedSfxFreqAndGetVol, PATCH_JUMP);
InjectHook(0x5795F0, &cAudioManager::SetMissionAudioLocation, PATCH_JUMP); InjectHook(0x5795F0, &cAudioManager::SetMissionAudioLocation, PATCH_JUMP);
InjectHook(0x57F020, &cAudioManager::SetMissionScriptPoliceAudio, PATCH_JUMP); InjectHook(0x57F020, &cAudioManager::SetMissionScriptPoliceAudio, PATCH_JUMP);
InjectHook(0x57A790, &cAudioManager::SetMusicFadeVolume, PATCH_JUMP); InjectHook(0x57A790, &cAudioManager::SetMusicFadeVolume, PATCH_JUMP);
InjectHook(0x57A750, &cAudioManager::SetMusicMasterVolume, PATCH_JUMP); InjectHook(0x57A750, &cAudioManager::SetMusicMasterVolume, PATCH_JUMP);
InjectHook(0x57A9A0, &cAudioManager::SetSpeakerConfig, 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(0x56F230, &cAudioManager::SetupJumboFlySound, PATCH_JUMP);
InjectHook(0x56F310, &cAudioManager::SetupJumboRumbleSound, PATCH_JUMP); InjectHook(0x56F310, &cAudioManager::SetupJumboRumbleSound, PATCH_JUMP);
InjectHook(0x56EF20, &cAudioManager::SetupJumboTaxiSound, 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(0x5755C0, &cPedComments::Add, PATCH_JUMP);
InjectHook(0x575730, &cPedComments::Process, PATCH_JUMP); InjectHook(0x575730, &cPedComments::Process, PATCH_JUMP);
InjectHook(0x5685E0, &cAudioCollisionManager::AddCollisionToRequestedQueue, PATCH_JUMP); InjectHook(0x5685E0, &cAudioCollisionManager::AddCollisionToRequestedQueue, PATCH_JUMP);
InjectHook(0x57C430, &cAudioScriptObject::Reset, PATCH_JUMP);
ENDPATCHES ENDPATCHES

View file

@ -200,7 +200,7 @@ public:
CVector Posn; CVector Posn;
int32 AudioEntity; int32 AudioEntity;
void Reset(); // todo hook void Reset(); /// ok
static void *operator new(size_t); static void *operator new(size_t);
static void *operator new(size_t, int); static void *operator new(size_t, int);
@ -284,9 +284,9 @@ public:
int32 m_nPoliceChannelEntity; int32 m_nPoliceChannelEntity;
uint8 stuff[239]; uint8 stuff[239];
uint8 unk1; uint8 unk1;
uint8 unk2; uint8 policeChannelTimer;
uint8 unk3; uint8 unk3;
uint8 unk4; uint8 policeChannelCounterSeconds;
uint8 unk5; uint8 unk5;
Crime crimes[10]; Crime crimes[10];
int32 m_nFrontEndEntity; int32 m_nFrontEndEntity;
@ -417,7 +417,7 @@ public:
uint8 GetCDAudioDriveLetter() const; uint8 GetCDAudioDriveLetter() const;
int8 GetCurrent3DProviderIndex() const; /// ok int8 GetCurrent3DProviderIndex() const; /// ok
float GetCollisionLoopingRatio(uint32 a, uint32 b, float c) const; // not used 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 GetCollisionRatio(float a, float b, float c, float d) const; /// ok
float GetDistanceSquared(CVector *v) const; /// ok float GetDistanceSquared(CVector *v) const; /// ok
int32 GetJumboTaxiFreq() const; /// ok int32 GetJumboTaxiFreq() const; /// ok
@ -528,12 +528,12 @@ public:
void ReleaseDigitalHandle() const; void ReleaseDigitalHandle() const;
void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2, void ReportCollision(CEntity *entity1, CEntity *entity2, uint8 surface1, uint8 surface2,
float collisionPower, float intensity2); /// ok float collisionPower, float intensity2); /// ok
void ReportCrime(int32 crime, const CVector *pos); /// ok void ReportCrime(int32 crime, const CVector *pos); /// ok
void ResetAudioLogicTimers(int32 timer); /// ok void ResetAudioLogicTimers(int32 timer); /// ok
void ResetPoliceRadio(); /// ok void ResetPoliceRadio(); /// ok
void ResetTimers(uint32 time); /// ok void ResetTimers(uint32 time); /// ok
void Service(); // todo void Service(); /// ok
void ServiceCollisions(); // todo void ServiceCollisions(); // todo
void ServicePoliceRadio(); /// ok void ServicePoliceRadio(); /// ok
void ServicePoliceRadioChannel(int32 wantedLevel); /// ok void ServicePoliceRadioChannel(int32 wantedLevel); /// ok
@ -543,28 +543,30 @@ public:
void SetEffectsFadeVolume(uint8 volume) const; void SetEffectsFadeVolume(uint8 volume) const;
void SetEffectsMasterVolume(uint8 volume) const; void SetEffectsMasterVolume(uint8 volume) const;
void SetEntityStatus(int32 id, bool status); 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 SetMissionAudioLocation(float x, float y, float z);
void SetMissionScriptPoliceAudio(int32 sfx) const; void SetMissionScriptPoliceAudio(int32 sfx) const;
void SetMonoMode(uint8); // todo (mobile) void SetMonoMode(uint8); // todo (mobile)
void SetMusicFadeVolume(uint8 volume) const; void SetMusicFadeVolume(uint8 volume) const;
void SetMusicMasterVolume(uint8 volume) const; void SetMusicMasterVolume(uint8 volume) const;
void SetSpeakerConfig(int32 conf) const; void SetSpeakerConfig(int32 conf) const;
void SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter); // todo hook void SetUpLoopingCollisionSound(cAudioCollision *col, uint8 counter); /// ok
void SetUpOneShotCollisionSound(int a2); // todo void SetUpOneShotCollisionSound(cAudioCollision *col); /// ok
bool SetupCrimeReport(); // todo bool SetupCrimeReport(); // todo
bool SetupJumboEngineSound(uint8 a2, int32 a3); // todo bool SetupJumboEngineSound(uint8 a2, int32 a3); // todo
bool SetupJumboFlySound(uint8 emittingVol); /// ok bool SetupJumboFlySound(uint8 emittingVol); /// ok
bool SetupJumboRumbleSound(uint8 emittingVol); /// ok bool SetupJumboRumbleSound(uint8 emittingVol); /// ok
bool SetupJumboTaxiSound(uint8 vol); /// ok bool SetupJumboTaxiSound(uint8 vol); /// ok
bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok bool SetupJumboWhineSound(uint8 emittingVol, int32 freq); /// ok
void SetupPedComments(cPedParams *params, uint32 sound); /// ok void SetupPedComments(cPedParams *params, uint32 sound); /// ok
void SetupSuspectLastSeenReport(); // todo void SetupSuspectLastSeenReport(); // todo
void Terminate(); void Terminate();
void TranslateEntity(CVector *v1, CVector *v2) const; void TranslateEntity(CVector *v1, CVector *v2) const;
void UpdateGasPedalAudio(CAutomobile *automobile); void UpdateGasPedalAudio(CAutomobile *automobile);
void UpdateReflections(); // todo
bool UsesReverseWarning(int32 model) const; bool UsesReverseWarning(int32 model) const;
bool UsesSiren(int32 model) const; bool UsesSiren(int32 model) const;
bool UsesSirenSwitching(int32 model) const; bool UsesSirenSwitching(int32 model) const;

View file

@ -1,34 +1,38 @@
#include "common.h"
#include "patcher.h"
#include "MusicManager.h" #include "MusicManager.h"
#include "Camera.h"
#include "Font.h" #include "Font.h"
#include "Hud.h" #include "Hud.h"
#include "ModelIndices.h"
#include "Replay.h"
#include "Text.h" #include "Text.h"
#include "Timer.h" #include "Timer.h"
#include "Camera.h"
#include "World.h" #include "World.h"
#include "ModelIndices.h"
#include "sampman.h" #include "sampman.h"
#include "Replay.h" #include "patcher.h"
cMusicManager &MusicManager = *(cMusicManager*)0x8F3964; cMusicManager &MusicManager = *(cMusicManager *)0x8F3964;
int32 &gNumRetunePresses = *(int32*)0x650B80; int32 &gNumRetunePresses = *(int32 *)0x650B80;
wchar *pCurrentStation = (wchar*)0x650B9C; wchar *pCurrentStation = (wchar *)0x650B9C;
uint8 &cDisplay = *(uint8*)0x650BA1; uint8 &cDisplay = *(uint8 *)0x650BA1;
WRAPPER char* cMusicManager::Get3DProviderName(char) { EAXJMP(0x57A8C0); } WRAPPER char *
cMusicManager::Get3DProviderName(char)
bool cMusicManager::PlayerInCar()
{ {
if (!FindPlayerVehicle()) EAXJMP(0x57A8C0);
}
bool
cMusicManager::PlayerInCar()
{
if(!FindPlayerVehicle())
return false; return false;
else { else {
int32 State = CWorld::Players[CWorld::PlayerInFocus].m_pPed->m_nPedState; 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; return false;
switch (FindPlayerVehicle()->m_modelIndex) { switch(FindPlayerVehicle()->m_modelIndex) {
case MI_FIRETRUCK: case MI_FIRETRUCK:
case MI_AMBULAN: case MI_AMBULAN:
case MI_MRWHOOP: case MI_MRWHOOP:
@ -36,10 +40,8 @@ bool cMusicManager::PlayerInCar()
case MI_TRAIN: case MI_TRAIN:
case MI_SPEEDER: case MI_SPEEDER:
case MI_REEFER: case MI_REEFER:
case MI_GHOST: case MI_GHOST: return false;
return false; default: return true;
default:
return true;
} }
} }
} }
@ -47,56 +49,53 @@ bool cMusicManager::PlayerInCar()
#if 0 #if 0
WRAPPER void cMusicManager::DisplayRadioStationName(void) { EAXJMP(0x57E6D0); } WRAPPER void cMusicManager::DisplayRadioStationName(void) { EAXJMP(0x57E6D0); }
#else #else
void cMusicManager::DisplayRadioStationName() void
cMusicManager::DisplayRadioStationName()
{ {
int8 pRetune; int8 pRetune;
int8 gStreamedSound; int8 gStreamedSound;
int8 gRetuneCounter; int8 gRetuneCounter;
if (!CTimer::GetIsPaused() && !TheCamera.m_WideScreenOn && cMusicManager::PlayerInCar() && !CReplay::IsPlayingBack()) { if(!CTimer::GetIsPaused() && !TheCamera.m_WideScreenOn && cMusicManager::PlayerInCar() &&
if (MusicManager.m_bPlayerInCar && !MusicManager.m_bPreviousPlayerInCar) !CReplay::IsPlayingBack()) {
if(MusicManager.m_bPlayerInCar && !MusicManager.m_bPreviousPlayerInCar)
pCurrentStation = nil; pCurrentStation = nil;
if (SampleManager.IsMP3RadioChannelAvailable()) { if(SampleManager.IsMP3RadioChannelAvailable()) {
gStreamedSound = MusicManager.m_nCurrentStreamedSound; gStreamedSound = MusicManager.m_nCurrentStreamedSound;
if (gStreamedSound != STREAMED_SOUND_CITY_AMBIENT && gStreamedSound != STREAMED_SOUND_WATER_AMBIENT) { if(gStreamedSound != STREAMED_SOUND_CITY_AMBIENT &&
if (gStreamedSound > STREAMED_SOUND_RADIO_MP3_PLAYER) gStreamedSound != STREAMED_SOUND_WATER_AMBIENT) {
return; if(gStreamedSound > STREAMED_SOUND_RADIO_MP3_PLAYER) return;
} } else {
else {
gStreamedSound = STREAMED_SOUND_RADIO_POLICE; gStreamedSound = STREAMED_SOUND_RADIO_POLICE;
} }
pRetune = gNumRetunePresses + gStreamedSound; pRetune = gNumRetunePresses + gStreamedSound;
if (pRetune == POLICE_RADIO) { if(pRetune == POLICE_RADIO) {
pRetune = RADIO_OFF; pRetune = RADIO_OFF;
} } else if(pRetune > POLICE_RADIO) {
else if (pRetune > POLICE_RADIO) {
pRetune = pRetune - 11; pRetune = pRetune - 11;
} }
} } else {
else {
gStreamedSound = MusicManager.m_nCurrentStreamedSound; gStreamedSound = MusicManager.m_nCurrentStreamedSound;
pRetune = gNumRetunePresses + gStreamedSound; pRetune = gNumRetunePresses + gStreamedSound;
if (pRetune >= USERTRACK) { if(pRetune >= USERTRACK) {
gRetuneCounter = gNumRetunePresses; gRetuneCounter = gNumRetunePresses;
pRetune = MusicManager.m_nCurrentStreamedSound; pRetune = MusicManager.m_nCurrentStreamedSound;
if (gStreamedSound == STREAMED_SOUND_WATER_AMBIENT) if(gStreamedSound == STREAMED_SOUND_WATER_AMBIENT)
pRetune = RADIO_OFF; pRetune = RADIO_OFF;
while (gRetuneCounter) { while(gRetuneCounter) {
if (pRetune == RADIO_OFF) { if(pRetune == RADIO_OFF) {
pRetune = HEAD_RADIO; pRetune = HEAD_RADIO;
} } else if(pRetune < USERTRACK) {
else if (pRetune < USERTRACK) {
pRetune = pRetune + 1; pRetune = pRetune + 1;
} }
if (pRetune == USERTRACK) if(pRetune == USERTRACK) pRetune = RADIO_OFF;
pRetune = RADIO_OFF;
--gRetuneCounter; --gRetuneCounter;
} }
@ -105,52 +104,29 @@ void cMusicManager::DisplayRadioStationName()
wchar *string = nil; wchar *string = nil;
switch (pRetune) { switch(pRetune) {
case HEAD_RADIO: case HEAD_RADIO: string = TheText.Get("FEA_FM0"); break;
string = TheText.Get("FEA_FM0"); case DOUBLE_CLEF: string = TheText.Get("FEA_FM1"); break;
break; case JAH_RADIO: string = TheText.Get("FEA_FM2"); break;
case DOUBLE_CLEF: case RISE_FM: string = TheText.Get("FEA_FM3"); break;
string = TheText.Get("FEA_FM1"); case LIPS_106: string = TheText.Get("FEA_FM4"); break;
break; case GAME_FM: string = TheText.Get("FEA_FM5"); break;
case JAH_RADIO: case MSX_FM: string = TheText.Get("FEA_FM6"); break;
string = TheText.Get("FEA_FM2"); case FLASHBACK: string = TheText.Get("FEA_FM7"); break;
break; case CHATTERBOX: string = TheText.Get("FEA_FM8"); break;
case RISE_FM: case USERTRACK: string = TheText.Get("FEA_FM9"); break;
string = TheText.Get("FEA_FM3"); default: return;
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()) { if(pRetune > CHATTERBOX && !SampleManager.IsMP3RadioChannelAvailable()) { return; }
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; pCurrentStation = string;
cDisplay = 60; cDisplay = 60;
} } else {
else { if(!cDisplay) return;
if (!cDisplay)
return;
--cDisplay; --cDisplay;
} }
@ -164,7 +140,7 @@ void cMusicManager::DisplayRadioStationName()
CFont::SetColor(CRGBA(0, 0, 0, 255)); 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); 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)); CFont::SetColor(CRGBA(102, 133, 143, 255));
else else
CFont::SetColor(CRGBA(147, 196, 211, 255)); CFont::SetColor(CRGBA(147, 196, 211, 255));
@ -203,38 +179,44 @@ cMusicManager::StopFrontEndTrack()
EAXJMP(0x57E3D0); EAXJMP(0x57E3D0);
} }
WRAPPER void
WRAPPER void cMusicManager::PlayAnnouncement(unsigned char) cMusicManager::PlayAnnouncement(unsigned char)
{ {
EAXJMP(0x57E430); EAXJMP(0x57E430);
} }
WRAPPER void cMusicManager::PlayFrontEndTrack(unsigned char, unsigned char) WRAPPER void
cMusicManager::PlayFrontEndTrack(unsigned char, unsigned char)
{ {
EAXJMP(0x57E2E0); EAXJMP(0x57E2E0);
} }
WRAPPER void cMusicManager::PreloadCutSceneMusic(unsigned char) WRAPPER void
cMusicManager::PreloadCutSceneMusic(unsigned char)
{ {
EAXJMP(0x57E210); EAXJMP(0x57E210);
} }
WRAPPER void cMusicManager::PlayPreloadedCutSceneMusic(void) WRAPPER void
cMusicManager::PlayPreloadedCutSceneMusic(void)
{ {
EAXJMP(0x57E290); EAXJMP(0x57E290);
} }
WRAPPER void cMusicManager::StopCutSceneMusic(void) WRAPPER void
cMusicManager::StopCutSceneMusic(void)
{ {
EAXJMP(0x57E2B0); EAXJMP(0x57E2B0);
} }
WRAPPER int32 cMusicManager::GetRadioInCar(void) WRAPPER int32
cMusicManager::GetRadioInCar(void)
{ {
EAXJMP(0x57D1D0); EAXJMP(0x57D1D0);
} }
WRAPPER void cMusicManager::SetRadioInCar(unsigned int) WRAPPER void
cMusicManager::SetRadioInCar(unsigned int)
{ {
EAXJMP(0x57D2C0); EAXJMP(0x57D2C0);
} }
@ -251,3 +233,13 @@ cMusicManager::ResetMusicAfterReload()
{ {
EAXJMP(0x57CF30); EAXJMP(0x57CF30);
} }
WRAPPER
void cMusicManager::ResetTimers(int32) { EAXJMP(0x57D420); }
WRAPPER
void
cMusicManager::Service()
{
EAXJMP(0x57D440);
}

View file

@ -1,5 +1,7 @@
#pragma once #pragma once
#include "common.h"
enum eRadioStation enum eRadioStation
{ {
HEAD_RADIO, HEAD_RADIO,
@ -297,6 +299,9 @@ public:
void SetRadioChannelByScript(unsigned char, int); void SetRadioChannelByScript(unsigned char, int);
void ResetMusicAfterReload(); void ResetMusicAfterReload();
void ResetTimers(int32);
void Service();
}; };
static_assert(sizeof(cMusicManager) == 0x95C, "cMusicManager: error"); static_assert(sizeof(cMusicManager) == 0x95C, "cMusicManager: error");

View file

@ -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 ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
#define BIT(num) (1<<(num)) #define BIT(num) (1<<(num))
auto max = [](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); }; //auto min = [](auto a, auto b) { return ((a) < (b)) ? (a) : (b); };
#define ABS(a) (((a) < 0) ? (-(a)) : (a)) #define ABS(a) (((a) < 0) ? (-(a)) : (a))
#define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min))))) #define norm(value, min, max) (((value) < (min)) ? 0 : (((value) > (max)) ? 1 : (((value) - (min)) / ((max) - (min)))))