Replaced GlobalAlloc with malloc.

WaveMix keeps GlobalAlloc for authenticity.
Fixed float to double casts.
Some cleanup.
This commit is contained in:
Muzychenko Andrey 2021-02-18 12:53:25 +03:00
parent 55984fbb08
commit 98f234fce3
33 changed files with 171 additions and 174 deletions

View file

@ -49,7 +49,7 @@ int Sound::Init(HINSTANCE hInstance, int voices, void (* someFuncPtr)(int, MIXWA
{
/*FT does not have the file, defaults work OK*/
if (!pb::FullTiltMode)
MessageBoxA(winmain::hwnd_frame, pinball::get_rc_string(42, 0), pinball::WindowName, 0x2000u);
MessageBoxA(winmain::hwnd_frame, pinball::get_rc_string(42, 0), "", 0x2000u);
}
WndClass.style = 0;

View file

@ -16,18 +16,18 @@
#include "winmain.h"
int main()
{
{
{
// Testing with UI
char cmdLine[1]{};
WinMain(GetModuleHandleA(nullptr), 0, cmdLine, 10);
WinMain(GetModuleHandleA(nullptr), nullptr, cmdLine, 10);
return 0;
}
std::cout << "Hello World!\n";
gdrv::init(0, 0);
gdrv::init(nullptr, nullptr);
auto dib = gdrv::DibCreate(8, 1, 1);
gdrv::DibSetUsage(dib, 0, 1);
gdrv::DibSetUsage(dib, nullptr, 1);
auto d = objlist_class<void>(2, 4);
for (size_t i = 0; i < 100; i++)

View file

@ -57,7 +57,7 @@ int TBlocker::Message(int code, float value)
timer::kill(Timer);
float timerTime;
if (value <= 0.0)
if (value <= 0.0f)
timerTime = 0.0;
else
timerTime = value;

View file

@ -70,7 +70,7 @@ int TCollisionComponent::DefaultCollision(TBall* ball, vector_type* nextPosition
auto projSpeed = maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, Threshold, Boost);
if (projSpeed <= Threshold)
{
if (projSpeed > 0.2)
if (projSpeed > 0.2f)
{
if (SoftHitSoundId)
loader::play_sound(SoftHitSoundId);
@ -92,7 +92,7 @@ void TCollisionComponent::Collision(TBall* ball, vector_type* nextPosition, vect
maths::basic_collision(ball, nextPosition, direction, Elasticity, Smoothness, 1000000000.0, 0.0);
return;
}
double projSpeed = maths::basic_collision(
auto projSpeed = maths::basic_collision(
ball,
nextPosition,
direction,
@ -102,7 +102,7 @@ void TCollisionComponent::Collision(TBall* ball, vector_type* nextPosition, vect
Boost);
if (projSpeed <= Threshold)
{
if (projSpeed <= 0.2)
if (projSpeed <= 0.2f)
return;
soundIndex = SoftHitSoundId;
}

View file

@ -45,7 +45,7 @@ int TComponentGroup::Message(int code, float value)
timer::kill(this->Timer);
this->Timer = 0;
}
if (value > 0.0)
if (value > 0.0f)
this->Timer = timer::set(value, this, NotifyTimerExpired);
}
else if (code <= 1007 || code > 1011 && code != 1020 && code != 1022)

View file

@ -87,15 +87,15 @@ TEdgeSegment* TEdgeSegment::install_wall(float* floatArr, TCollisionComponent* c
center.X = centerX1;
center.Y = centerY1;
if (offset != 0.0)
if (offset != 0.0f)
{
vec1.X = centerX1 - prevCenter.X;
vec1.Y = center.Y - prevCenter.Y;
vec2.X = centerX2 - centerX1;
vec2.Y = centerY2 - center.Y;
maths::cross(&vec1, &vec2, &dstVec);
if (dstVec.Z > 0.0 && offset > 0.0 ||
dstVec.Z < 0.0 && offset < 0.0)
if (dstVec.Z > 0.0f && offset > 0.0f ||
dstVec.Z < 0.0f && offset < 0.0f)
{
float radius = offset * 1.001f;
auto circle = new TCircle(collComp, activeFlagPtr, collisionGroup, &center, radius);

View file

@ -82,7 +82,7 @@ void TFlagSpinner::Collision(TBall* ball, vector_type* nextPosition, vector_type
ball->not_again(edge);
SpinDirection = 2 * (PrevCollider != edge) - 1;
if (ball->Speed == 0.0)
if (ball->Speed == 0.0f)
Speed = MinSpeed;
else
Speed = ball->Speed * 20.0f;

View file

@ -97,7 +97,7 @@ int TFlipper::Message(int code, float value)
{
auto v10 = value - FlipperEdge->InputTime;
timerTime = v10 - floor(v10 / TimerTime) * TimerTime;
if (timerTime < 0.0)
if (timerTime < 0.0f)
timerTime = 0.0;
}
else

View file

@ -48,7 +48,7 @@ TFlipperEdge::TFlipperEdge(TCollisionComponent* collComp, char* activeFlag, unsi
AngleMax = acos(maths::DotProduct(&vecDir1, &vecDir2));
maths::cross(&vecDir1, &vecDir2, &crossProd);
if (crossProd.Z < 0.0)
if (crossProd.Z < 0.0f)
AngleMax = -AngleMax;
FlipperFlag = 0;
Angle1 = 0.0;
@ -67,7 +67,7 @@ TFlipperEdge::TFlipperEdge(TCollisionComponent* collComp, char* activeFlag, unsi
B2Src.X = dirY1 * CircleT1Radius + vecT1->X;
B2Src.Y = dirX1 * CircleT1Radius + vecT1->Y;
if (AngleMax < 0.0)
if (AngleMax < 0.0f)
{
maths::vswap(&A1Src, &B1Src);
maths::vswap(&A2Src, &B2Src);
@ -122,7 +122,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
srcRay.MaxDistance = ogRay->MaxDistance;
srcRay.Origin = ogRay->Origin;
auto distance = maths::distance_to_flipper(&srcRay, &dstRay);
if (distance == 0.0)
if (distance == 0.0f)
{
NextBallPosition = dstRay.Origin;
NextBallPosition.X -= srcRay.Direction.X * 1e-05f;
@ -167,14 +167,14 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
srcRay.Origin.X = ogRay->Origin.X - srcRay.Direction.X * 5.0f;
srcRay.Origin.Y = ogRay->Origin.Y - srcRay.Direction.Y * 5.0f;
srcRay.MaxDistance = ogRay->MaxDistance + 10.0f;
if (maths::distance_to_flipper(&srcRay, &dstRay) >= 1e+09)
if (maths::distance_to_flipper(&srcRay, &dstRay) >= 1e+09f)
{
srcRay.Direction.X = RotOrigin.X - ogRay->Origin.X;
srcRay.Direction.Y = RotOrigin.Y - ogRay->Origin.Y;
maths::normalize_2d(&srcRay.Direction);
srcRay.Origin.X = ogRay->Origin.X - srcRay.Direction.X * 5.0f;
srcRay.Origin.Y = ogRay->Origin.Y - srcRay.Direction.Y * 5.0f;
if (maths::distance_to_flipper(&srcRay, &dstRay) >= 1e+09)
if (maths::distance_to_flipper(&srcRay, &dstRay) >= 1e+09f)
{
return 1e+09;
}
@ -221,7 +221,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
srcRay.Origin.X = posX - srcRay.Direction.X * 5.0f;
srcRay.Origin.Y = posY - srcRay.Direction.Y * 5.0f;
srcRay.MaxDistance = ogRay->MaxDistance + 10.0f;
if (maths::distance_to_flipper(&srcRay, &dstRay) >= 1e+09)
if (maths::distance_to_flipper(&srcRay, &dstRay) >= 1e+09f)
{
NextBallPosition.X = posX;
NextBallPosition.Y = posY;
@ -252,7 +252,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
srcRay.MaxDistance = ogRay->MaxDistance + 10.0f;
auto distance = maths::distance_to_flipper(&srcRay, &dstRay);
CollisionDirection = dstRay.Direction;
if (distance >= 1e+09)
if (distance >= 1e+09f)
{
return 1e+09;
}
@ -267,7 +267,7 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
srcRay.Origin = ogRay->Origin;
srcRay.MaxDistance = rayMaxDistance;
auto distance = maths::distance_to_flipper(&srcRay, &dstRay);
if (distance < 1e+09)
if (distance < 1e+09f)
{
NextBallPosition = dstRay.Origin;
NextBallPosition.X -= srcRay.Direction.X * 1e-05f;
@ -276,11 +276,11 @@ float TFlipperEdge::FindCollisionDistance(ray_type* ray)
if (FlipperFlag == 2)
{
linePtr = &lineB.PerpendicularL;
CollisionFlag1 = AngleMax <= 0.0;
CollisionFlag1 = AngleMax <= 0.0f;
}
else
{
CollisionFlag1 = AngleMax > 0.0;
CollisionFlag1 = AngleMax > 0.0f;
linePtr = &lineA.PerpendicularL;
}
CollisionLinePerp = *linePtr;
@ -310,12 +310,12 @@ void TFlipperEdge::EdgeCollision(TBall* ball, float coef)
float dx = NextBallPosition.X - RotOrigin.X;
float dy = NextBallPosition.Y - RotOrigin.Y;
float distance = dy * dy + dx * dx;
if (circlebase.RadiusSq * 1.01 < distance)
if (circlebase.RadiusSq * 1.01f < distance)
{
float v11;
float v20 = sqrt(distance / DistanceDivSq) * (fabs(AngleMax) / AngleMult);
float dot1 = maths::DotProduct(&CollisionLinePerp, &CollisionDirection);
if (dot1 >= 0.0)
if (dot1 >= 0.0f)
v11 = dot1 * v20;
else
v11 = 0.0;
@ -323,7 +323,7 @@ void TFlipperEdge::EdgeCollision(TBall* ball, float coef)
}
}
float threshold = boost <= 0.0 ? 1000000000.0f : -1.0f;
float threshold = boost <= 0.0f ? 1000000000.0f : -1.0f;
maths::basic_collision(
ball,
&NextBallPosition,
@ -339,7 +339,7 @@ void TFlipperEdge::EdgeCollision(TBall* ball, float coef)
float dx = NextBallPosition.X - RotOrigin.X;
float dy = NextBallPosition.Y - RotOrigin.Y;
float distance = dy * dy + dx * dx;
if (circlebase.RadiusSq * 1.01 < distance)
if (circlebase.RadiusSq * 1.01f < distance)
elasticity = (1.0f - sqrt(distance / DistanceDivSq)) * Elasticity;
else
elasticity = Elasticity;
@ -420,10 +420,10 @@ float TFlipperEdge::flipper_angle(float timeNow)
if (!FlipperFlag)
return Angle1;
float angle = (Angle1 - Angle2) / AngleMax * AngleMult;
if (angle < 0.0)
if (angle < 0.0f)
angle = -angle;
if (angle >= 0.0000001)
if (angle >= 0.0000001f)
angle = (timeNow - InputTime) / angle;
else
angle = 1.0;
@ -446,11 +446,11 @@ int TFlipperEdge::is_ball_inside(float x, float y)
dy * dy + dx * dx <= CirclebaseRadiusSq ||
(T1.Y - y) * (T1.Y - y) + (T1.X - x) * (T1.X - x) < CircleT1RadiusSq)
{
float flipperLR = AngleMax < 0.0 ? -1.0f : 1.0f;
float flipperLR = AngleMax < 0.0f ? -1.0f : 1.0f;
if (FlipperFlag == 1)
testPoint = AngleMax < 0.0 ? B1 : B2;
testPoint = AngleMax < 0.0f ? B1 : B2;
else if (FlipperFlag == 2)
testPoint = AngleMax < 0.0 ? A2 : A1;
testPoint = AngleMax < 0.0f ? A2 : A1;
else
testPoint = T1;

View file

@ -28,7 +28,7 @@ THole::THole(TPinballTable* table, int groupIndex) : TCollisionComponent(table,
Circle.Center.X = visual.FloatArr[0];
Circle.Center.Y = visual.FloatArr[1];
Circle.RadiusSq = *loader::query_float_attribute(groupIndex, 0, 306) * visual.FloatArr[2];
if (Circle.RadiusSq == 0.0)
if (Circle.RadiusSq == 0.0f)
Circle.RadiusSq = 0.001f;
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,

View file

@ -33,7 +33,7 @@ TKickout::TKickout(TPinballTable* table, int groupIndex, bool someFlag): TCollis
Circle.Center.X = visual.FloatArr[0];
Circle.Center.Y = visual.FloatArr[1];
Circle.RadiusSq = *loader::query_float_attribute(groupIndex, 0, 306) * visual.FloatArr[2];
if (Circle.RadiusSq == 0.0)
if (Circle.RadiusSq == 0.0f)
Circle.RadiusSq = 0.001f;
auto tCircle = new TCircle(this, &ActiveFlag, visual.CollisionGroup,
reinterpret_cast<vector_type*>(visual.FloatArr), Circle.RadiusSq);
@ -67,7 +67,7 @@ int TKickout::Message(int code, float value)
case 55:
if (KickFlag1)
{
if (value < 0.0)
if (value < 0.0f)
value = TimerTime1;
Timer = timer::set(value, this, TimerExpired);
}

View file

@ -270,7 +270,7 @@ void TLight::schedule_timeout(float time)
if (Timer1)
timer::kill(Timer1);
Timer1 = 0;
if (time > 0.0)
if (time > 0.0f)
Timer1 = timer::set(time, this, TimerExpired);
}

View file

@ -354,7 +354,7 @@ int TLightGroup::Message(int code, float value)
if (NotifyTimer)
timer::kill(NotifyTimer);
NotifyTimer = 0;
if (value > 0.0)
if (value > 0.0f)
NotifyTimer = timer::set(value, this, NotifyTimerExpired);
break;
case 44:
@ -447,7 +447,7 @@ void TLightGroup::reschedule_animation(float time)
return;
}
Timer1Time = time > 0.0 ? time : Timer1TimeDefault;
Timer1Time = time > 0.0f ? time : Timer1TimeDefault;
Timer = timer::set(Timer1Time, this, TimerExpired);
}

View file

@ -67,7 +67,7 @@ void TOneway::Collision(TBall* ball, vector_type* nextPosition, vector_type* dir
Elasticity,
Smoothness,
Threshold,
Boost) > 0.2)
Boost) > 0.2f)
{
if (SoftHitSoundId)
loader::play_sound(SoftHitSoundId);

View file

@ -34,7 +34,7 @@ int TSink::Message(int code, float value)
switch (code)
{
case 56:
if (value < 0.0)
if (value < 0.0f)
value = TimerTime;
Timer = timer::set(value, this, TimerExpired);
break;

View file

@ -219,45 +219,45 @@ void TTableLayer::edges_insert_circle(circle_type* circle, TEdgeSegment* edge, f
ray.Direction.X = 1.0;
ray.Direction.Y = 0.0;
ray.MaxDistance = edge_manager->AdvanceX;
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0)
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0f)
break;
ray.Direction.X = -1.0;
ray.Origin.X = ray.Origin.X + edge_manager->AdvanceX;
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0)
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0f)
break;
ray.Direction.X = 0.0;
ray.Direction.Y = 1.0;
ray.MaxDistance = edge_manager->AdvanceY;
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0)
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0f)
break;
ray.Direction.Y = -1.0;
ray.Origin.Y = ray.Origin.Y + edge_manager->AdvanceY;
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0)
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0f)
break;
ray.Direction.Y = 0.0;
ray.Direction.X = -1.0;
ray.MaxDistance = edge_manager->AdvanceX;
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0)
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0f)
break;
ray.Direction.X = 1.0;
ray.Origin.X = ray.Origin.X - edge_manager->AdvanceX;
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0)
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0f)
break;
ray.Direction.X = 0.0;
ray.Direction.Y = -1.0;
ray.MaxDistance = edge_manager->AdvanceY;
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0)
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0f)
break;
ray.Direction.Y = 1.0;
ray.Origin.Y = ray.Origin.Y - edge_manager->AdvanceY;
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0)
if (maths::ray_intersect_circle(&ray, circle) < 1000000000.0f)
break;
collision = false;

View file

@ -121,7 +121,7 @@ void TTextBox::Display(char* text, float time)
{
if (Timer && Timer != -1)
timer::kill(Timer);
if (time == -1.0)
if (time == -1.0f)
Timer = -1;
else
Timer = timer::set(time, this, TimerExpired);
@ -172,7 +172,7 @@ void TTextBox::Draw()
bool display = false;
while (Message1)
{
if (Message1->Time == -1.0)
if (Message1->Time == -1.0f)
{
if (!Message1->NextMessage)
{

View file

@ -56,14 +56,14 @@ HANDLE WaveMix::ConfigureInit(MIXCONFIG* lpConfig)
if (ShowDebugDialogs)
{
wsprintfA(string_buffer, "This system does not have a valid wave output device.");
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x40u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONINFORMATION);
}
return nullptr;
}
if (GetPrivateProfileIntA("general", "ShowDevices", 0, FileName))
ShowWaveOutDevices();
auto globals = static_cast<GLOBALS*>(LocalAlloc(0x40u, sizeof(GLOBALS)));
auto globals = static_cast<GLOBALS*>(LocalAlloc(LMEM_ZEROINIT, sizeof(GLOBALS)));
Globals = globals;
if (!globals)
return nullptr;
@ -75,7 +75,7 @@ HANDLE WaveMix::ConfigureInit(MIXCONFIG* lpConfig)
globals->DefaultVolume.L = 10;
globals->DefaultVolume.R = 10;
memset(globals->aChannel, 0xFFu, sizeof globals->aChannel);
memmove(&globals->PCM, &gpFormat, 0x10u);
memmove(&globals->PCM, &gpFormat, sizeof(PCMWAVEFORMAT));
if (!ReadConfigSettings(&mixConfig))
{
Globals->wMagic2 = 0;
@ -245,7 +245,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
WAVEFORMATEX pwfx;
HMMIO hMmio = nullptr;
HGLOBAL hResData = nullptr;
HPSTR wavBuffer3 = nullptr;
HPSTR lpData = nullptr;
auto globals = SessionToGlobalDataPtr(hMixSession);
pwfx.wFormatTag = globals->PCM.wf.wFormatTag;
pwfx.nChannels = globals->PCM.wf.nChannels;
@ -258,11 +258,11 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
if (waveOutOpen(&phwo, 0xFFFFFFFF, &pwfx, 0, 0, 1u))
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "The waveform device can't play this format.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "The waveform device can't play this format.", "WavMix32", MB_ICONWARNING);
return nullptr;
}
auto mixWave = static_cast<MIXWAVE*>(GlobalLock(GlobalAlloc(0x2040u, sizeof(MIXWAVE))));
auto mixWave = static_cast<MIXWAVE*>(GlobalLock(GlobalAlloc(GMEM_SHARE | GMEM_ZEROINIT, sizeof(MIXWAVE))));
if (!mixWave)
{
if (ShowDebugDialogs)
@ -270,7 +270,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
nullptr,
"Unable to allocate memory for waveform data. Try making more memory available by closing other applications.",
"WavMix32",
0x40u);
MB_ICONINFORMATION);
return nullptr;
}
@ -286,7 +286,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
else
wsprintfA(string_buffer, "Failed to open 'WAVE' resource %u.", LOWORD(szWaveFilename));
if (ShowDebugDialogs)
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x30u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONWARNING);
break;
}
@ -295,7 +295,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
if (!pmmioinfo.pchBuffer)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Failed to lock 'WAVE' resource", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Failed to lock 'WAVE' resource", "WavMix32", MB_ICONWARNING);
FreeResource(hResData);
hResData = nullptr;
break;
@ -312,7 +312,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
wsprintfA(string_buffer,
"Failed to open resource, mmioOpen error=%u.\nMay need to make sure resource is marked read-write",
pmmioinfo.wErrorRet);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x30u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONWARNING);
}
break;
}
@ -328,7 +328,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
wsprintfA(string_buffer,
"Failed to open memory file, mmioOpen error=%u.\nMay need to make sure memory is read-write",
pmmioinfo.wErrorRet);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x30u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONWARNING);
}
break;
}
@ -341,57 +341,57 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
if (ShowDebugDialogs)
{
wsprintfA(string_buffer, "Failed to open wave file %s.", szWaveFilename);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x30u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONWARNING);
}
break;
}
}
pmmcki.fccType = mmioFOURCC('W', 'A', 'V', 'E');
if (mmioDescend(hMmio, &pmmcki, nullptr, 0x20u))
if (mmioDescend(hMmio, &pmmcki, nullptr, MMIO_FINDRIFF))
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "This is not a WAVE file.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "This is not a WAVE file.", "WavMix32", MB_ICONWARNING);
break;
}
pmmFmt.ckid = mmioFOURCC('f', 'm', 't', ' ');
if (mmioDescend(hMmio, &pmmFmt, &pmmcki, 0x10u))
if (mmioDescend(hMmio, &pmmFmt, &pmmcki, MMIO_FINDCHUNK))
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "WAVE file is corrupted.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "WAVE file is corrupted.", "WavMix32", MB_ICONWARNING);
break;
}
if (mmioRead(hMmio, (HPSTR)mixWave, 16) != 16)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Failed to read format chunk.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Failed to read format chunk.", "WavMix32", MB_ICONWARNING);
break;
}
if (mixWave->pcm.wf.wFormatTag != 1)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "The file is not a PCM file.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "The file is not a PCM file.", "WavMix32", MB_ICONWARNING);
break;
}
mmioAscend(hMmio, &pmmFmt, 0);
pmmFmt.ckid = mmioFOURCC('d', 'a', 't', 'a');
if (mmioDescend(hMmio, &pmmFmt, &pmmcki, 0x10u))
if (mmioDescend(hMmio, &pmmFmt, &pmmcki, MMIO_FINDCHUNK))
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "WAVE file has no data chunk.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "WAVE file has no data chunk.", "WavMix32", MB_ICONWARNING);
break;
}
auto dataSize = pmmFmt.cksize;
if (!pmmFmt.cksize)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "The data chunk has no data.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "The data chunk has no data.", "WavMix32", MB_ICONWARNING);
break;
}
auto lpData = static_cast<HPSTR>(GlobalLock(GlobalAlloc(0x2002u, pmmFmt.cksize)));
lpData = static_cast<HPSTR>(GlobalLock(GlobalAlloc(GMEM_SHARE | GMEM_MOVEABLE, pmmFmt.cksize)));
if (!lpData)
{
if (ShowDebugDialogs)
@ -399,7 +399,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
nullptr,
"Unable to allocate memory for waveform data. Try making more memory available by closing other applications.",
"WavMix32",
0x40u);
MB_ICONINFORMATION);
break;
}
@ -407,14 +407,14 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
if (readCount != static_cast<LONG>(dataSize))
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Failed to read data chunk.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Failed to read data chunk.", "WavMix32", MB_ICONWARNING);
break;
}
lpData = WaveFormatConvert(&Globals->PCM, &mixWave->pcm, lpData, &dataSize);
if (!lpData)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Failed to convert wave format.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Failed to convert wave format.", "WavMix32", MB_ICONWARNING);
break;
}
mmioClose(hMmio, 0);
@ -426,7 +426,7 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
mixWave->wh.dwLoops = 0;
mixWave->wh.dwUser = 0;
mixWave->wMagic = 21554;
memmove(mixWave, &Globals->PCM, 0x10u);
memmove(&mixWave->pcm, &Globals->PCM, sizeof(PCMWAVEFORMAT));
if (HIWORD(szWaveFilename))
{
@ -446,10 +446,10 @@ MIXWAVE* WaveMix::OpenWave(HANDLE hMixSession, LPCSTR szWaveFilename, HINSTANCE
mmioClose(hMmio, 0);
GlobalUnlock(GlobalHandle(mixWave));
GlobalFree(GlobalHandle(mixWave));
if (wavBuffer3)
if (lpData)
{
GlobalUnlock(GlobalHandle(wavBuffer3));
GlobalFree(GlobalHandle(wavBuffer3));
GlobalUnlock(GlobalHandle(lpData));
GlobalFree(GlobalHandle(lpData));
}
if (hResData)
FreeResource(hResData);
@ -586,7 +586,7 @@ int WaveMix::Play(MIXPLAYPARAMS* lpMixPlayParams)
if (!lpMixPlayParams)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "NULL parameters pointer passed to WaveMixPlay!", "WavMix32", 0x30u);
MessageBoxA(nullptr, "NULL parameters pointer passed to WaveMixPlay!", "WavMix32", MB_ICONWARNING);
result = 5;
break;
}
@ -596,7 +596,7 @@ int WaveMix::Play(MIXPLAYPARAMS* lpMixPlayParams)
if (!globals)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Invalid session handle passed to WaveMixPlay", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Invalid session handle passed to WaveMixPlay", "WavMix32", MB_ICONWARNING);
result = 5;
break;
}
@ -604,7 +604,7 @@ int WaveMix::Play(MIXPLAYPARAMS* lpMixPlayParams)
if (!IsValidLPMIXWAVE(lpMixPlayParams->lpMixWave))
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Invalid or NULL wave pointer passed to WaveMixPlay!", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Invalid or NULL wave pointer passed to WaveMixPlay!", "WavMix32", MB_ICONWARNING);
break;
}
@ -615,7 +615,7 @@ int WaveMix::Play(MIXPLAYPARAMS* lpMixPlayParams)
"The LPMIXWAVE 0x%lx is not in the current output format, close the wave and reopen it.",
lpMixPlayParams->lpMixWave);
if (ShowDebugDialogs)
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x30u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONWARNING);
result = 8;
break;
}
@ -623,14 +623,14 @@ int WaveMix::Play(MIXPLAYPARAMS* lpMixPlayParams)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Wave device not allocated, call WaveMixActivate(hMixSession,TRUE)", "WavMix32",
0x30u);
MB_ICONWARNING);
result = 4;
break;
}
if (!globals->iChannels)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "You must open a channel before you can play a wave!", "WavMix32", 0x30u);
MessageBoxA(nullptr, "You must open a channel before you can play a wave!", "WavMix32", MB_ICONWARNING);
result = 5;
break;
}
@ -829,7 +829,7 @@ GLOBALS* WaveMix::SessionToGlobalDataPtr(HANDLE hMixSession)
return globals;
MessageBeep(0xFFFFFFFF);
wsprintfA(string_buffer, "Invalid session handle 0x%04X passed to WaveMix API", hMixSession);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x30u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONWARNING);
return nullptr;
}
@ -915,7 +915,7 @@ void WaveMix::ShowWaveOutDevices()
if (deviceCount)
{
wsprintfA(string_buffer, "%d waveOut Devices have been detected on your system.", deviceCount);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x40u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONINFORMATION);
for (auto uDeviceID = 0u; uDeviceID < deviceCount; ++uDeviceID)
{
if (!waveOutGetDevCapsA(uDeviceID, &pwoc, 0x34u) && RemoveInvalidIniNameCharacters(pwoc.szPname))
@ -928,7 +928,7 @@ void WaveMix::ShowWaveOutDevices()
LOBYTE(pwoc.vDriverVersion));
else
wsprintfA(string_buffer, "waveOutGetDevCaps failed (err %u) for device %d", 1, uDeviceID);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x40u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONINFORMATION);
}
}
}
@ -1000,7 +1000,7 @@ int WaveMix::ReadConfigSettings(MIXCONFIG* lpConfig)
wsprintfA(string_buffer,
"%s is a syncronous (blocking) wave output device. This will not permit audio to play while other applications are running.",
Globals->WaveoutCaps.szPname);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x40u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONINFORMATION);
return 0;
}
if (GetPrivateProfileIntA("not compatible", Globals->szDevicePName, 0, FileName))
@ -1008,7 +1008,7 @@ int WaveMix::ReadConfigSettings(MIXCONFIG* lpConfig)
if (!ShowDebugDialogs)
return 0;
wsprintfA(string_buffer, "%s is not compatible with the realtime wavemixer.", Globals->szDevicePName);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x40u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONINFORMATION);
return 0;
}
@ -1435,7 +1435,7 @@ int WaveMix::ResetRemix(DWORD dwRemixSamplePos, CHANNELNODE* channel)
if (waveOutWrite(Globals->hWaveOut, &xHDR->wh, sizeof(WAVEHDR)))
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Failed to write block to device", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Failed to write block to device", "WavMix32", MB_ICONWARNING);
xHDR->fAvailable = 1;
RemoveFromPlayingQueue(xHDR);
}
@ -1650,7 +1650,7 @@ int WaveMix::MixerPlay(XWAVEHDR* lpXWH, int fWriteBlocks)
if (waveOutWrite(Globals->hWaveOut, &lpXWH->wh, sizeof(WAVEHDR)))
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Failed to write block to device", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Failed to write block to device", "WavMix32", MB_ICONWARNING);
lpXWH->fAvailable = 1;
RemoveFromPlayingQueue(lpXWH);
}
@ -1862,7 +1862,7 @@ int WaveMix::Settings_OnInitDialog(HWND hWnd, WPARAM wParam, MIXCONFIG* lpMixcon
if (getResult)
{
wsprintfA(string_buffer, "waveOutGetDevCaps failed (err %u) for device %d", getResult, uDeviceID);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x40u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONINFORMATION);
}
else
{
@ -2051,7 +2051,7 @@ void WaveMix::ShowCurrentSettings()
Globals->PCM.wf.nSamplesPerSec,
Globals->PCM.wf.nChannels,
Globals->PauseBlocks);
MessageBoxA(nullptr, string_buffer, "WavMix32", 0x40u);
MessageBoxA(nullptr, string_buffer, "WavMix32", MB_ICONINFORMATION);
}
unsigned WaveMix::GetWaveDevice()
@ -2060,14 +2060,14 @@ unsigned WaveMix::GetWaveDevice()
if (Globals->hWaveOut)
return 0;
HWND window = CreateWindowExA(0, "WavMix32", pinball::WindowName, 0x8000000u, 0, 0, 0, 0, nullptr, nullptr, HModule,
HWND window = CreateWindowExA(0, "WavMix32", "", 0x8000000u, 0, 0, 0, 0, nullptr, nullptr, HModule,
nullptr);
GLOBALS* globals = Globals;
Globals->hWndApp = window;
if (!window)
{
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Failed to create callback window.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Failed to create callback window.", "WavMix32", MB_ICONWARNING);
return 1;
}
pwfx.wFormatTag = globals->PCM.wf.wFormatTag;
@ -2128,7 +2128,7 @@ int WaveMix::AllocWaveBlocks(HWAVEOUT hwo, XWAVEHDR** waveBlocks)
nullptr,
"Unable to allocate memory for waveform data. Try making more memory available by closing other applications.",
"WavMix32",
0x30u);
MB_ICONWARNING);
for (int j = i - 1; j >= 0; --j)
{
GlobalUnlock(GlobalHandle(waveBlocks[j]));
@ -2152,7 +2152,7 @@ int WaveMix::AllocWaveBlocks(HWAVEOUT hwo, XWAVEHDR** waveBlocks)
return 1;
}
if (ShowDebugDialogs)
MessageBoxA(nullptr, "Unable to prepare wave header.", "WavMix32", 0x30u);
MessageBoxA(nullptr, "Unable to prepare wave header.", "WavMix32", MB_ICONWARNING);
FreeWaveBlocks(hwo, waveBlocks);
return 0;
}
@ -2207,7 +2207,7 @@ HPSTR WaveMix::BitsPerSampleAlign(HPSTR lpInData, WORD nInBPS, WORD nOutBPS, DWO
DWORD dwNumSamples = *dwDataSize / (nInBPS / 8u);
*dwDataSize = dwNumSamples * (nOutBPS / 8u);
dataBuf = GlobalLock(GlobalAlloc(0x2002u, *dwDataSize));
dataBuf = GlobalLock(GlobalAlloc(GMEM_SHARE | GMEM_MOVEABLE, *dwDataSize));
if (dataBuf)
{
if (nInBPS / 8u <= nOutBPS / 8u)
@ -2232,7 +2232,7 @@ HPSTR WaveMix::BitsPerSampleAlign(HPSTR lpInData, WORD nInBPS, WORD nOutBPS, DWO
nullptr,
"Unable to allocate memory for waveform data. Try making more memory available by closing other applications.",
"WavMix32",
0x40u);
MB_ICONINFORMATION);
}
}
@ -2248,7 +2248,7 @@ HPSTR WaveMix::ChannelAlign(HPSTR lpInData, WORD nInChannels, WORD nOutChannels,
return lpInData;
DWORD dwNumSamples = *dwDataSize / nBytesPerSample / nInChannels;
*dwDataSize = dwNumSamples * nBytesPerSample * nOutChannels;
char* dataBuf = static_cast<char*>(GlobalLock(GlobalAlloc(0x2002u, *dwDataSize)));
char* dataBuf = static_cast<char*>(GlobalLock(GlobalAlloc(GMEM_SHARE | GMEM_MOVEABLE, *dwDataSize)));
if (dataBuf)
{
if (nInChannels < nOutChannels)
@ -2303,7 +2303,7 @@ HPSTR WaveMix::ChannelAlign(HPSTR lpInData, WORD nInChannels, WORD nOutChannels,
nullptr,
"Unable to allocate memory for waveform data. Try making more memory available by closing other applications.",
"WavMix32",
0x40u);
MB_ICONINFORMATION);
dataBuf = nullptr;
}
@ -2334,7 +2334,7 @@ HPSTR WaveMix::SamplesPerSecAlign(HPSTR lpInData, DWORD nInSamplesPerSec, DWORD
}
*dwDataSize = sampleSize * dwNumSamples2;
auto dataBuf = static_cast<char*>(GlobalLock(GlobalAlloc(0x2002u, sampleSize * dwNumSamples2)));
auto dataBuf = static_cast<char*>(GlobalLock(GlobalAlloc(GMEM_SHARE | GMEM_MOVEABLE, sampleSize * dwNumSamples2)));
if (!dataBuf)
{
if (ShowDebugDialogs)
@ -2342,7 +2342,7 @@ HPSTR WaveMix::SamplesPerSecAlign(HPSTR lpInData, DWORD nInSamplesPerSec, DWORD
nullptr,
"Unable to allocate memory for waveform data. Try making more memory available by closing other applications.",
"WavMix32",
0x40u);
MB_ICONINFORMATION);
GlobalUnlock(GlobalHandle(lpInData));
GlobalFree(GlobalHandle(lpInData));
return nullptr;
@ -2503,7 +2503,7 @@ void WaveMix::FreePlayedBlocks()
int WaveMix::HasCurrentOutputFormat(MIXWAVE* lpMixWave)
{
return memcmp(lpMixWave, &Globals->PCM, 0x10u) == 0;
return memcmp(&lpMixWave->pcm, &Globals->PCM, sizeof(PCMWAVEFORMAT)) == 0;
}
CHANNELNODE* WaveMix::GetChannelNode()

View file

@ -323,17 +323,17 @@ void fullscrn::fillRect(int right, int bottom, int left, int top)
if (brush)
{
auto dc = winmain::_GetDC(hWnd);
auto prevBrush = SelectObject(dc, brush);
if (dc)
{
auto prevBrush = SelectObject(dc, brush);
rc.right = left + right + 1;
rc.bottom = top + bottom + 1;
rc.left = left;
rc.top = top;
FillRect(dc, &rc, brush);
SelectObject(dc, prevBrush);
ReleaseDC(hWnd, dc);
}
SelectObject(dc, prevBrush);
DeleteObject(brush);
}
}

View file

@ -42,12 +42,11 @@ void gdrv::get_focus()
BITMAPINFO* gdrv::DibCreate(int16_t bpp, int width, int height)
{
auto sizeBytes = height * (width * bpp / 8 + 3 & 0xFFFFFFFC);
auto buf = GlobalAlloc(GHND, sizeBytes + sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD));
auto dib = static_cast<BITMAPINFO*>(GlobalLock(buf));
auto sizeBytes = height * (width * bpp / 8 + 3 & (~3));
auto dib = memory::allocate<BITMAPINFO>(1, (256 - 1) * sizeof(RGBQUAD) + sizeBytes);
if (!dib)
return nullptr;
dib->bmiHeader.biSizeImage = sizeBytes;
dib->bmiHeader.biWidth = width;
dib->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
@ -247,8 +246,7 @@ int gdrv::destroy_bitmap(gdrv_bitmap8* bmp)
}
else if (bmp->BitmapType == BitmapType::DibBitmap)
{
GlobalUnlock(GlobalHandle(bmp->Dib));
GlobalFree(GlobalHandle(bmp->Dib));
memory::free(bmp->Dib);
}
memset(bmp, 0, sizeof(gdrv_bitmap8));
return 0;
@ -433,7 +431,7 @@ int gdrv::StretchDIBitsScaled(HDC hdc, int xDest, int yDest, int DestWidth, int
{
xSrc -= pad;
xDest -= pad;
SrcWidth += padX2;
SrcWidth += padX2;
DestWidth += padX2;
}
@ -441,7 +439,7 @@ int gdrv::StretchDIBitsScaled(HDC hdc, int xDest, int yDest, int DestWidth, int
{
ySrc -= pad;
yDest -= pad;
SrcHeight += padX2;
SrcHeight += padX2;
DestHeight += padX2;
}

View file

@ -54,12 +54,12 @@ int high_score::read(high_score_struct* table, int* ptrToSmth)
auto tablePtr = &table[position];
_itoa_s(position, Buffer, 10);
lstrcatA(Buffer, ".Name");
options::get_string(optPath, Buffer, buf1, pinball::WindowName, 32);
options::get_string(optPath, Buffer, buf1, "", 32);
buf1[32] = 0;
lstrcpyA(tablePtr->Name, buf1);
_itoa_s(position, Buffer, 10);
lstrcatA(Buffer, ".Score");
options::get_string(optPath, Buffer, buf1, pinball::WindowName, 300);
options::get_string(optPath, Buffer, buf1, "", 300);
tablePtr->Score = atol(buf1);
for (int i = lstrlenA(tablePtr->Name); --i >= 0; scoreSum += tablePtr->Name[i])
{
@ -68,7 +68,7 @@ int high_score::read(high_score_struct* table, int* ptrToSmth)
}
scramble_number_string(scoreSum, buf1);
options::get_string(optPath, "Verification", buf2, pinball::WindowName, 300);
options::get_string(optPath, "Verification", buf2, "", 300);
if (lstrcmpA(buf1, buf2))
clear_table(table);
memory::free(buf1);

View file

@ -469,11 +469,11 @@ int loader::query_visual(int groupIndex, int groupIndexOffset, visualStruct* vis
auto floatArr = reinterpret_cast<float*>(partman::field(loader_table, stateId, datFieldTypes::FloatArray));
if (!floatArr)
return 0;
if (*floatArr != 600.0)
if (*floatArr != 600.0f)
return 0;
visual->FloatArrCount = partman::field_size(loader_table, stateId, datFieldTypes::FloatArray) / 4 / 2 - 2;
auto floatVal = static_cast<int>(floor(floatArr[1]) - 1.0);
auto floatVal = static_cast<int>(floor(floatArr[1]) - 1.0f);
switch (floatVal)
{
case 0:

View file

@ -131,7 +131,7 @@ float maths::ray_intersect_circle(ray_type* ray, circle_type* circle)
// Tca, L dot D, projection of L on D
float Tca = Ly * ray->Direction.Y + Lx * ray->Direction.X;
if (Tca < 0.0) // No intersection if Tca is negative
if (Tca < 0.0f) // No intersection if Tca is negative
return 1000000000.0f;
// L dot L, distance from ray origin to circle center
@ -144,12 +144,12 @@ float maths::ray_intersect_circle(ray_type* ray, circle_type* circle)
// Thc^2 = rad^2 - d = rad^2 - L dot L + Tca dot Tca
float ThcSq = circle->RadiusSq - LMagSq + Tca * Tca;
if (ThcSq < 0.0) // No intersection if Thc is negative
if (ThcSq < 0.0f) // No intersection if Thc is negative
return 1000000000.0f;
// T0 = Tca - Thc, distance from origin to first intersection
float T0 = Tca - sqrt(ThcSq);
if (T0 < 0.0 || T0 > ray->MaxDistance)
if (T0 < 0.0f || T0 > ray->MaxDistance)
return 1000000000.0f;
return T0;
}
@ -158,7 +158,7 @@ float maths::ray_intersect_circle(ray_type* ray, circle_type* circle)
float maths::normalize_2d(vector_type* vec)
{
float mag = sqrt(vec->X * vec->X + vec->Y * vec->Y);
if (0.0 != mag)
if (mag != 0.0f)
{
vec->X = 1.0f / mag * vec->X;
vec->Y = 1.0f / mag * vec->Y;
@ -179,7 +179,7 @@ void maths::line_init(line_type* line, float x0, float y0, float x1, float y1)
line->PerpendicularL.X = line->Direction.Y;
line->PerpendicularL.Y = -line->Direction.X;
line->PreComp1 = -(line->Direction.Y * x0) + line->Direction.X * y0;
if (line->Direction.X >= 0.000000001 || line->Direction.X <= -0.000000001)
if (line->Direction.X >= 0.000000001f || line->Direction.X <= -0.000000001f)
{
v9 = x1;
lineDirection = x0 >= x1;
@ -210,7 +210,7 @@ float maths::ray_intersect_line(ray_type* ray, line_type* line)
bool v6;
float perpDot = line->PerpendicularL.Y * ray->Direction.Y + ray->Direction.X * line->PerpendicularL.X;
if (perpDot < 0.0)
if (perpDot < 0.0f)
{
float result = -((ray->Origin.X * line->PerpendicularL.X + ray->Origin.Y * line->PerpendicularL.Y + line->
PreComp1)
@ -220,7 +220,7 @@ float maths::ray_intersect_line(ray_type* ray, line_type* line)
line->RayIntersect.X = result * ray->Direction.X + ray->Origin.X;
float v4 = result * ray->Direction.Y + ray->Origin.Y;
line->RayIntersect.Y = v4;
if (0.0 == line->Direction.X)
if (line->Direction.X == 0.0f)
{
if (v4 >= line->OriginX)
{
@ -256,7 +256,7 @@ float maths::magnitude(vector_type* vec)
{
float result;
auto magSq = vec->X * vec->X + vec->Y * vec->Y + vec->Z * vec->Z;
if (magSq == 0.0)
if (magSq == 0.0f)
result = 0.0;
else
result = sqrt(magSq);
@ -342,7 +342,7 @@ float maths::distance_to_flipper(ray_type* ray1, ray_type* ray2)
auto distance = 1000000000.0f;
auto distanceType = -1;
auto newDistance = ray_intersect_line(ray1, &TFlipperEdge::lineA);
if (newDistance < 1000000000.0)
if (newDistance < 1000000000.0f)
{
distance = newDistance;
distanceType = 0;
@ -365,7 +365,7 @@ float maths::distance_to_flipper(ray_type* ray1, ray_type* ray2)
distance = newDistance;
distanceType = 1;
}
if (!ray2 || distance >= 1000000000.0)
if (!ray2 || distance >= 1000000000.0f)
return distance;
if (distanceType != -1)

View file

@ -167,7 +167,7 @@ int midi::load_file(midi_struct** midi_res, void* filePtrOrPath, int fileSizeP,
returnCode = 1;
break;
}
midi->Magic = 'ISDM';
midi->Magic = mmioFOURCC('M', 'D', 'S', 'I');
midi->StreamHandle = nullptr;
midi->PreparedBlocksCount = 0;
@ -240,12 +240,12 @@ int midi::read_file(midi_struct* midi, riff_header* filePtr, unsigned fileSize)
returnCode = 3;
break;
}
if (filePtr->Riff != 'FFIR')
if (filePtr->Riff != mmioFOURCC('R', 'I', 'F', 'F'))
{
returnCode = 3;
break;
}
if (filePtr->Mids != 'SDIM')
if (filePtr->Mids != mmioFOURCC('M', 'I', 'D', 'S'))
{
returnCode = 3;
break;
@ -260,7 +260,7 @@ int midi::read_file(midi_struct* midi, riff_header* filePtr, unsigned fileSize)
returnCode = 3;
break;
}
if (filePtr->Fmt != ' tmf')
if (filePtr->Fmt != mmioFOURCC('f', 'm', 't', ' '))
{
returnCode = 3;
break;
@ -288,7 +288,7 @@ int midi::read_file(midi_struct* midi, riff_header* filePtr, unsigned fileSize)
auto dataChunk = reinterpret_cast<riff_data*>(reinterpret_cast<char*>(&filePtr->dwTimeFormat) + filePtr->FmtSize
);
if (dataChunk->Data != 'atad')
if (dataChunk->Data != mmioFOURCC('d','a','t','a'))
{
returnCode = 3;
break;
@ -300,8 +300,8 @@ int midi::read_file(midi_struct* midi, riff_header* filePtr, unsigned fileSize)
}
midi->BlockCount = dataChunk->BlocksPerChunk;
midi->DataPtr1 = static_cast<midihdr_tag*>(GlobalLock(GlobalAlloc(
GMEM_DDESHARE | GMEM_MOVEABLE, dataChunk->BlocksPerChunk * (midi->CbMaxBuffer + sizeof(midihdr_tag)))));
midi->DataPtr1 = reinterpret_cast<midihdr_tag*>(memory::allocate(
dataChunk->BlocksPerChunk * (midi->CbMaxBuffer + sizeof(midihdr_tag))));
if (!midi->DataPtr1)
{
returnCode = 1;
@ -363,8 +363,7 @@ int midi::read_file(midi_struct* midi, riff_header* filePtr, unsigned fileSize)
if (returnCode && midi->DataPtr1)
{
GlobalUnlock(GlobalHandle(midi->DataPtr1));
GlobalFree(GlobalHandle(midi->DataPtr1));
memory::free(midi->DataPtr1);
}
return returnCode;
}
@ -405,16 +404,15 @@ int midi::stop_ft()
int midi::unload_track(midi_struct* midi)
{
if (midi->Magic != 'ISDM')
if (midi->Magic != mmioFOURCC('M', 'D', 'S', 'I'))
return 6;
if (midi->StreamHandle)
stream_close(midi);
if (midi->DataPtr1)
{
GlobalUnlock(GlobalHandle(midi->DataPtr1));
GlobalFree(GlobalHandle(midi->DataPtr1));
memory::free(midi->DataPtr1);
}
midi->Magic = 'atad';
midi->Magic = mmioFOURCC('d','a','t','a');
LocalFree(midi);
return 0;
}
@ -422,7 +420,7 @@ int midi::unload_track(midi_struct* midi)
int midi::stream_open(midi_struct* midi, char flags)
{
auto returnCode = 0;
if (midi->Magic != 'ISDM')
if (midi->Magic != mmioFOURCC('M', 'D', 'S', 'I'))
return 6;
UINT puDeviceID = -1;
@ -473,7 +471,7 @@ int midi::stream_close(midi_struct* midi)
{
int returnCode;
if (midi->Magic != 'ISDM')
if (midi->Magic != mmioFOURCC('M', 'D', 'S', 'I'))
return 6;
if (!midi->StreamHandle)
return 7;

View file

@ -80,12 +80,12 @@ void nudge::_nudge(float xDiff, float yDiff)
ball->Acceleration.Y = ball->Acceleration.Y * ball->Speed;
maths::vector_add(&ball->Acceleration, &accelMod);
ball->Speed = maths::normalize_2d(&ball->Acceleration);
if (0.0 == ball->Acceleration.X)
if (ball->Acceleration.X == 0.0f)
invAccelX = 1000000000.0;
else
invAccelX = 1.0f / ball->Acceleration.X;
ball->InvAcceleration.X = invAccelX;
if (0.0 == ball->Acceleration.Y)
if (ball->Acceleration.Y == 0.0f)
invAccelY = 1000000000.0;
else
invAccelY = 1.0f / ball->Acceleration.Y;
@ -94,6 +94,6 @@ void nudge::_nudge(float xDiff, float yDiff)
}
}
render::shift(static_cast<int>(floor(xDiff + 0.5)), static_cast<int>(floor(0.5 - yDiff)), 0, 0, table->Width,
render::shift(static_cast<int>(floor(xDiff + 0.5f)), static_cast<int>(floor(0.5f - yDiff)), 0, 0, table->Width,
table->Height);
}

View file

@ -120,7 +120,7 @@ void options::init(HMENU menuHandle)
auto tmpBuf = memory::allocate(0x1F4u);
if (tmpBuf)
{
get_string(nullptr, "Shell Exe", tmpBuf, pinball::WindowName, 500);
get_string(nullptr, "Shell Exe", tmpBuf, "", 500);
if (!*tmpBuf)
{
if (MenuHandle)

View file

@ -239,7 +239,7 @@ int pb::frame(int time)
else
{
auto nudgeDec = nudge::nudge_count - timeMul;
if (nudgeDec <= 0.0)
if (nudgeDec <= 0.0f)
nudgeDec = 0.0;
nudge::nudge_count = nudgeDec;
}
@ -248,11 +248,11 @@ int pb::frame(int time)
score::update(MainTable->CurScoreStruct);
if (!MainTable->TiltLockFlag)
{
if (nudge::nudge_count > 0.5)
if (nudge::nudge_count > 0.5f)
{
pinball::InfoTextBox->Display(pinball::get_rc_string(25, 0), 2.0);
}
if (nudge::nudge_count > 1.0)
if (nudge::nudge_count > 1.0f)
MainTable->tilt(time_now);
}
}
@ -288,13 +288,13 @@ void pb::timed_frame(float timeNow, float timeDelta, bool drawBalls)
ball->Acceleration.Y = ball->Speed * ball->Acceleration.Y;
maths::vector_add(&ball->Acceleration, &vec2);
ball->Speed = maths::normalize_2d(&ball->Acceleration);
ball->InvAcceleration.X = ball->Acceleration.X == 0.0 ? 1000000000.0f : 1.0f / ball->Acceleration.X;
ball->InvAcceleration.Y = ball->Acceleration.Y == 0.0 ? 1000000000.0f : 1.0f / ball->Acceleration.Y;
ball->InvAcceleration.X = ball->Acceleration.X == 0.0f ? 1000000000.0f : 1.0f / ball->Acceleration.X;
ball->InvAcceleration.Y = ball->Acceleration.Y == 0.0f ? 1000000000.0f : 1.0f / ball->Acceleration.Y;
}
auto timeDelta2 = timeDelta;
auto timeNow2 = timeNow;
for (auto index = 10; timeDelta2 > 0.000001 && index; --index)
for (auto index = 10; timeDelta2 > 0.000001f && index; --index)
{
auto time = collide(timeNow2, timeDelta2, ball);
timeDelta2 -= time;
@ -632,7 +632,7 @@ float pb::collide(float timeNow, float timeDelta, TBall* ball)
TEdgeSegment* edge = nullptr;
auto distance = TTableLayer::edge_manager->FindCollisionDistance(&ray, ball, &edge);
ball->EdgeCollisionCount = 0;
if (distance >= 1000000000.0)
if (distance >= 1000000000.0f)
{
maxDistance = timeDelta * ball->Speed;
ball->RayMaxDistance = maxDistance;
@ -644,7 +644,7 @@ float pb::collide(float timeNow, float timeDelta, TBall* ball)
else
{
edge->EdgeCollision(ball, distance);
if (ball->Speed > 0.000000001)
if (ball->Speed > 0.000000001f)
return fabs(distance / ball->Speed);
}
}

View file

@ -9,7 +9,6 @@ TTextBox* pinball::InfoTextBox;
TTextBox* pinball::MissTextBox;
char pinball::getRcBuffer[6 * 256];
int pinball::rc_string_slot = 0;
char pinball::WindowName[2]{};
int pinball::LeftShift = -1;
int pinball::RightShift = -1;

View file

@ -13,7 +13,6 @@ public:
static int quickFlag;
static TTextBox* InfoTextBox;
static TTextBox* MissTextBox;
static char WindowName[2];
static int RightShift;
static int LeftShift;

View file

@ -47,7 +47,7 @@ void proj::xform_to_2d(vector_type* vec, int* dst)
vector_type dstVec2{};
matrix_vector_multiply(&matrix, vec, &dstVec2);
if (0.0 == dstVec2.Z)
if (dstVec2.Z == 0.0f)
projCoef = 999999.88f;
else
projCoef = d_ / dstVec2.Z;

View file

@ -253,7 +253,7 @@ void score::update(scoreStruct* score)
{
unsigned char curChar = scoreBuf[index];
curChar -= '0';
gdrv_bitmap8* bmp = score->CharBmp[curChar];
gdrv_bitmap8* bmp = score->CharBmp[curChar % 10];
x -= bmp->Width;
int height = bmp->Height;
int width = bmp->Width;

View file

@ -30,12 +30,12 @@ splash_struct* splash::splash_screen(HINSTANCE hInstance, LPCSTR bmpName1, LPCST
WndClass.hIcon = nullptr;
WndClass.hCursor = LoadCursorA(nullptr, IDC_ARROW);
WndClass.hbrBackground = nullptr;
WndClass.lpszMenuName = pinball::WindowName;
WndClass.lpszMenuName = "";
WndClass.lpszClassName = "3DPB_SPLASH_CLASS";
RegisterClassA(&WndClass);
}
splashStruct->Bitmap = nullptr;
HWND windowHandle = CreateWindowExA(0, "3DPB_SPLASH_CLASS", pinball::WindowName, 0x80000000, -10, -10, 1, 1,
HWND windowHandle = CreateWindowExA(0, "3DPB_SPLASH_CLASS", "", 0x80000000, -10, -10, 1, 1,
nullptr, nullptr, HInstance, nullptr);
splashStruct->WindowHandle = windowHandle;
if (!windowHandle)
@ -284,12 +284,15 @@ LRESULT splash::splash_message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LPARA
BeginPaint(hWnd, &Paint);
EndPaint(hWnd, &Paint);
auto dc = GetDC(hWnd);
if (dc && splashStruct)
if (dc)
{
BitBlt(dc, 0, 0, 10000, 10000, dc, 0, 0, BLACKNESS);
splash_paint(splashStruct, dc);
if (splashStruct)
{
BitBlt(dc, 0, 0, 10000, 10000, dc, 0, 0, BLACKNESS);
splash_paint(splashStruct, dc);
}
ReleaseDC(hWnd, dc);
}
ReleaseDC(hWnd, dc);
break;
}
case WM_ERASEBKGND:

View file

@ -75,10 +75,10 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
for (int i = 0; i < 32700; ++i)
{
sprintf_s(Buffer, "Table%d", i);
options::get_string(nullptr, Buffer, tmpBuf, pinball::WindowName, 500);
options::get_string(nullptr, Buffer, tmpBuf, "", 500);
if (!*tmpBuf)
break;
options::get_string(tmpBuf, "Table Name", tmpBuf2, pinball::WindowName, 500);
options::get_string(tmpBuf, "Table Name", tmpBuf2, "", 500);
if (!lstrcmpA(tmpBuf2, pinball::get_rc_string(169, 0)))
{
setOption = false;
@ -102,7 +102,7 @@ int winmain::WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLi
options::path_uninit();
return 0;
}
options::get_string(regSpaceCadet, "Shell Exe", tmpBuf, pinball::WindowName, 500);
options::get_string(regSpaceCadet, "Shell Exe", tmpBuf, "", 500);
auto execRes = WinExec(tmpBuf, 5u);
memory::free(tmpBuf);
if (execRes >= 32)
@ -578,7 +578,7 @@ LRESULT CALLBACK winmain::message_handler(HWND hWnd, UINT Msg, WPARAM wParam, LP
if (tmpBuf)
{
char cmdLine[0x1F4u];
options::get_string(nullptr, "Shell Exe", tmpBuf, pinball::WindowName, 500);
options::get_string(nullptr, "Shell Exe", tmpBuf, "", 500);
auto iHwnd = reinterpret_cast<size_t>(hwnd_frame);
sprintf_s(
cmdLine,