diff options
author | Sergeanur <s.anureev@yandex.ua> | 2021-08-21 12:02:07 +0200 |
---|---|---|
committer | Sergeanur <s.anureev@yandex.ua> | 2021-08-21 12:02:07 +0200 |
commit | 7c80093efa18bac0598bf6481ccad479c90e47af (patch) | |
tree | 90e77d41de1559f95b068cba3b3f56c187f953d3 /src/audio/PolRadio.h | |
parent | Audio: bits of PS2 code (diff) | |
download | re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.gz re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.bz2 re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.lz re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.xz re3-7c80093efa18bac0598bf6481ccad479c90e47af.tar.zst re3-7c80093efa18bac0598bf6481ccad479c90e47af.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio/PolRadio.h | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/src/audio/PolRadio.h b/src/audio/PolRadio.h index d7c928e2..55b2c9f7 100644 --- a/src/audio/PolRadio.h +++ b/src/audio/PolRadio.h @@ -1,6 +1,7 @@ #pragma once #include "Crime.h" +#include "AudioSamples.h" struct cAMCrime { int32 type; @@ -17,30 +18,50 @@ struct cAMCrime { VALIDATE_SIZE(cAMCrime, 20); +#define POLICE_RADIO_QUEUE_MAX_SAMPLES 60 + class cPoliceRadioQueue { public: - int32 crimesSamples[60]; - uint8 policeChannelTimer; - uint8 policeChannelTimerSeconds; - uint8 policeChannelCounterSeconds; - cAMCrime crimes[10]; + uint32 m_aSamples[POLICE_RADIO_QUEUE_MAX_SAMPLES]; + uint8 m_nSamplesInQueue; + uint8 m_nAddOffset; + uint8 m_nRemoveOffset; cPoliceRadioQueue() { - policeChannelTimerSeconds = 0; - policeChannelCounterSeconds = 0; - policeChannelTimer = 0; + Reset(); + } + + void Reset() + { + m_nAddOffset = 0; + m_nRemoveOffset = 0; + m_nSamplesInQueue = 0; } - void Add(uint32 sample) + bool8 Add(uint32 sample) { - if (policeChannelTimer != 60) { - crimesSamples[policeChannelTimerSeconds] = sample; - policeChannelTimer++; - policeChannelTimerSeconds = (policeChannelTimerSeconds + 1) % 60; + if (m_nSamplesInQueue != POLICE_RADIO_QUEUE_MAX_SAMPLES) { + m_aSamples[m_nAddOffset] = sample; + m_nSamplesInQueue++; + m_nAddOffset = (m_nAddOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES; + return TRUE; } + return FALSE; } + + uint32 Remove() + { + if (m_nSamplesInQueue != 0) { + uint32 sample = m_aSamples[m_nRemoveOffset]; + m_nSamplesInQueue--; + m_nRemoveOffset = (m_nRemoveOffset + 1) % POLICE_RADIO_QUEUE_MAX_SAMPLES; + return sample; + } + return NO_SAMPLE; + } + }; -VALIDATE_SIZE(cPoliceRadioQueue, 0x1BC); +VALIDATE_SIZE(cPoliceRadioQueue, 244); |