mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-11-22 00:40:18 +01:00
Compare commits
No commits in common. "bbbdb2d9d4bfb94acd335f193c597bfcc9d08ed4" and "ab7184ef861f12eb877c698fba227a8cb5dcb38c" have entirely different histories.
bbbdb2d9d4
...
ab7184ef86
6 changed files with 22 additions and 30 deletions
|
@ -114,10 +114,10 @@ void Sound::Enable(int channelFrom, int channelTo, int enableFlag)
|
|||
}
|
||||
}
|
||||
|
||||
void Sound::Idle(bool performCleanup)
|
||||
void Sound::Idle()
|
||||
{
|
||||
if (pMem)
|
||||
WaveMix::Pump(performCleanup);
|
||||
WaveMix::Pump();
|
||||
}
|
||||
|
||||
void Sound::Activate()
|
||||
|
|
|
@ -6,7 +6,7 @@ class Sound
|
|||
public:
|
||||
static int Init(HINSTANCE hInstance, int voices, void (* someFuncPtr)(int, MIXWAVE*, int));
|
||||
static void Enable(int channelFrom, int channelTo, int enableFlag);
|
||||
static void Idle(bool performCleanup = true);
|
||||
static void Idle();
|
||||
static void Activate();
|
||||
static void Deactivate();
|
||||
static void Close();
|
||||
|
|
|
@ -308,8 +308,6 @@
|
|||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -352,8 +350,6 @@
|
|||
<ConformanceMode>false</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -396,8 +392,6 @@
|
|||
<ConformanceMode>true</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
@ -440,8 +434,6 @@
|
|||
<ConformanceMode>false</ConformanceMode>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
|
|
|
@ -550,7 +550,7 @@ int WaveMix::Activate(HANDLE hMixSession, bool fActivate)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void WaveMix::Pump(bool performCleanup)
|
||||
void WaveMix::Pump()
|
||||
{
|
||||
Globals = GlobalsActive;
|
||||
if (GlobalsActive)
|
||||
|
@ -567,8 +567,7 @@ void WaveMix::Pump(bool performCleanup)
|
|||
else
|
||||
xHDR = xHDR->QNext;
|
||||
}
|
||||
if (performCleanup)
|
||||
FreePlayedBlocks();
|
||||
FreePlayedBlocks();
|
||||
while (MixerPlay(GetWaveBlock(), 1));
|
||||
}
|
||||
}
|
||||
|
@ -1383,12 +1382,12 @@ int WaveMix::GetConfig(HANDLE hMixSession, MIXCONFIG* lpConfig)
|
|||
|
||||
unsigned WaveMix::MyWaveOutGetPosition(HWAVEOUT hWaveOut, int fGoodGetPos)
|
||||
{
|
||||
MMTIME pmmt{};
|
||||
mmtime_tag pmmt{};
|
||||
|
||||
if (!fGoodGetPos)
|
||||
return (timeGetTime() - Globals->dwBaseTime) * Globals->PCM.wf.nAvgBytesPerSec / 0x3E8 & 0xFFFFFFF8;
|
||||
pmmt.wType = TIME_BYTES;
|
||||
waveOutGetPosition(hWaveOut, &pmmt, sizeof(MMTIME));
|
||||
waveOutGetPosition(hWaveOut, &pmmt, 0xCu);
|
||||
return Globals->pfnSampleAdjust(pmmt.u.ms, Globals->dwWaveOutPos);
|
||||
}
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ public:
|
|||
static MIXWAVE* OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE hInst, unsigned int dwFlags);
|
||||
static int FreeWave(HANDLE hMixSession, MIXWAVE* lpMixWave);
|
||||
static int Activate(HANDLE hMixSession, bool fActivate);
|
||||
static void Pump(bool performCleanup = true);
|
||||
static void Pump();
|
||||
static int Play(MIXPLAYPARAMS* lpMixPlayParams);
|
||||
|
||||
private:
|
||||
|
|
|
@ -228,10 +228,9 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
float sleepRemainder = 0, frameDuration = TargetFrameTime;
|
||||
while (true)
|
||||
{
|
||||
if (someTimeCounter == 0)
|
||||
if (!someTimeCounter)
|
||||
{
|
||||
someTimeCounter = 300;
|
||||
|
||||
if (DispFrameRate)
|
||||
{
|
||||
auto curTime = timeGetTime();
|
||||
|
@ -258,10 +257,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
}
|
||||
}
|
||||
|
||||
// Don't look for and free already played blocks at every single frame,
|
||||
// as it is quite costly to look up. Only do that "sometimes".
|
||||
bool performSoundCleanup = someTimeCounter == 300;
|
||||
Sound::Idle(performSoundCleanup);
|
||||
Sound::Idle();
|
||||
if (!ProcessWindowMessages() || bQuit)
|
||||
break;
|
||||
|
||||
|
@ -290,20 +286,25 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
|
|||
if (DispGRhistory)
|
||||
{
|
||||
auto width = render::vscreen.Width / 2;
|
||||
auto height = 64, halfHeight = height / 2;
|
||||
auto height = 64;
|
||||
if (!gfr_display.BmpBufPtr1)
|
||||
{
|
||||
gdrv::create_bitmap(&gfr_display, width, height);
|
||||
}
|
||||
|
||||
gdrv::ScrollBitmapHorizontal(&gfr_display, -1);
|
||||
gdrv::fill_bitmap(&gfr_display, 1, halfHeight, width - 1, 0, 0); // Background
|
||||
gdrv::fill_bitmap(&gfr_display, 1, halfHeight, width - 1, halfHeight, -1); // Target
|
||||
|
||||
auto scale = halfHeight / TargetFrameTime;
|
||||
auto diffHeight = min(static_cast<int>(std::round(std::abs(TargetFrameTime - dt) * scale)), halfHeight);
|
||||
auto yOffset = dt < TargetFrameTime ? halfHeight : halfHeight - diffHeight;
|
||||
gdrv::fill_bitmap(&gfr_display, 1, diffHeight, width - 1, yOffset, 1); // Target diff
|
||||
float target = TargetFrameTime;
|
||||
auto scale = height / target / 2;
|
||||
gdrv::fill_bitmap(&gfr_display, 1, height, width - 1, 0, 0); // Background
|
||||
|
||||
auto targetVal = dt < target ? dt : target;
|
||||
auto targetHeight = min(static_cast<int>(std::floor(targetVal * scale)), height);
|
||||
gdrv::fill_bitmap(&gfr_display, 1, targetHeight, width - 1, height - targetHeight, -1); // Target
|
||||
|
||||
auto diffVal = dt < target ? target - dt : dt - target;
|
||||
auto diffHeight = min(static_cast<int>(std::floor(diffVal * scale)), height);
|
||||
gdrv::fill_bitmap(&gfr_display, 1, diffHeight, width - 1, height - targetHeight - diffHeight, 1); // Target diff
|
||||
|
||||
gdrv::blit(&gfr_display, 0, 0, render::vscreen.Width - width, 0, width, height);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue