mirror of
https://github.com/k4zmu2a/SpaceCadetPinball.git
synced 2024-12-18 10:37:53 +01:00
TLight: cleanup, code from FT, new test commands.
This commit is contained in:
parent
acd1ad34b2
commit
14a8d64b67
5 changed files with 232 additions and 210 deletions
|
@ -10,17 +10,17 @@
|
||||||
|
|
||||||
TLight::TLight(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true)
|
TLight::TLight(TPinballTable* table, int groupIndex) : TPinballComponent(table, groupIndex, true)
|
||||||
{
|
{
|
||||||
Timer1 = 0;
|
TimeoutTimer = 0;
|
||||||
FlasherActive = 0;
|
FlasherOnFlag = false;
|
||||||
Timer2 = 0;
|
UndoOverrideTimer = 0;
|
||||||
Flasher.Timer = 0;
|
FlashTimer = 0;
|
||||||
Reset();
|
Reset();
|
||||||
float* floatArr1 = loader::query_float_attribute(groupIndex, 0, 900);
|
float* floatArr1 = loader::query_float_attribute(groupIndex, 0, 900);
|
||||||
Flasher.TimerDelay[0] = *floatArr1;
|
FlashDelay[0] = *floatArr1;
|
||||||
FlasherDelay[0] = *floatArr1;
|
SourceDelay[0] = *floatArr1;
|
||||||
float* floatArr2 = loader::query_float_attribute(groupIndex, 0, 901);
|
float* floatArr2 = loader::query_float_attribute(groupIndex, 0, 901);
|
||||||
Flasher.TimerDelay[1] = *floatArr2;
|
FlashDelay[1] = *floatArr2;
|
||||||
FlasherDelay[1] = *floatArr2;
|
SourceDelay[1] = *floatArr2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TLight::Message(int code, float value)
|
int TLight::Message(int code, float value)
|
||||||
|
@ -34,183 +34,177 @@ int TLight::Message(int code, float value)
|
||||||
for (auto index = 0; index < PinballTable->PlayerCount; ++index)
|
for (auto index = 0; index < PinballTable->PlayerCount; ++index)
|
||||||
{
|
{
|
||||||
auto playerPtr = &PlayerData[index];
|
auto playerPtr = &PlayerData[index];
|
||||||
playerPtr->FlasherActive = FlasherActive;
|
playerPtr->FlasherOnFlag = FlasherOnFlag;
|
||||||
playerPtr->BmpIndex2 = BmpIndex2;
|
playerPtr->LightOnBmpIndex = LightOnBmpIndex;
|
||||||
playerPtr->BmpIndex1 = BmpIndex1;
|
playerPtr->LightOnFlag = LightOnFlag;
|
||||||
playerPtr->MessageField = MessageField;
|
playerPtr->MessageField = MessageField;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1020:
|
case 1020:
|
||||||
{
|
{
|
||||||
auto playerPtr = &PlayerData[PinballTable->CurrentPlayer];
|
auto playerPtr = &PlayerData[PinballTable->CurrentPlayer];
|
||||||
playerPtr->FlasherActive = FlasherActive;
|
playerPtr->FlasherOnFlag = FlasherOnFlag;
|
||||||
playerPtr->BmpIndex2 = BmpIndex2;
|
playerPtr->LightOnBmpIndex = LightOnBmpIndex;
|
||||||
playerPtr->BmpIndex1 = BmpIndex1;
|
playerPtr->LightOnFlag = LightOnFlag;
|
||||||
playerPtr->MessageField = MessageField;
|
playerPtr->MessageField = MessageField;
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
playerPtr = &PlayerData[static_cast<int>(floor(value))];
|
playerPtr = &PlayerData[static_cast<int>(floor(value))];
|
||||||
FlasherActive = playerPtr->FlasherActive;
|
FlasherOnFlag = playerPtr->FlasherOnFlag;
|
||||||
BmpIndex2 = playerPtr->BmpIndex2;
|
LightOnBmpIndex = playerPtr->LightOnBmpIndex;
|
||||||
BmpIndex1 = playerPtr->BmpIndex1;
|
LightOnFlag = playerPtr->LightOnFlag;
|
||||||
MessageField = playerPtr->MessageField;
|
MessageField = playerPtr->MessageField;
|
||||||
if (BmpIndex2)
|
if (LightOnBmpIndex)
|
||||||
{
|
{
|
||||||
Message(11, static_cast<float>(BmpIndex2));
|
Message(11, static_cast<float>(LightOnBmpIndex));
|
||||||
}
|
}
|
||||||
if (BmpIndex1)
|
if (LightOnFlag)
|
||||||
Message(1, 0.0);
|
Message(1, 0.0);
|
||||||
if (FlasherActive)
|
if (FlasherOnFlag)
|
||||||
Message(4, 0.0);
|
Message(4, 0.0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 0:
|
case 0:
|
||||||
BmpIndex1 = 0;
|
LightOnFlag = false;
|
||||||
if (FlasherActive == 0 && !FlasherFlag1 && !FlasherFlag2)
|
if (!FlasherOnFlag && !ToggledOffFlag && !ToggledOnFlag)
|
||||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[0]);
|
SetSpriteBmp(BmpArr[0]);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
BmpIndex1 = 1;
|
LightOnFlag = true;
|
||||||
if (FlasherActive == 0 && !FlasherFlag1 && !FlasherFlag2)
|
if (!FlasherOnFlag && !ToggledOffFlag && !ToggledOnFlag)
|
||||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[1]);
|
SetSpriteBmp(BmpArr[1]);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
return BmpIndex1;
|
return LightOnFlag;
|
||||||
case 3:
|
case 3:
|
||||||
return FlasherActive;
|
return FlasherOnFlag;
|
||||||
case 4:
|
case 4:
|
||||||
schedule_timeout(0.0);
|
schedule_timeout(0.0);
|
||||||
if (!FlasherActive || !Flasher.Timer)
|
if (!FlasherOnFlag || !FlashTimer)
|
||||||
{
|
{
|
||||||
FlasherActive = 1;
|
FlasherOnFlag = true;
|
||||||
FlasherFlag2 = 0;
|
ToggledOnFlag = false;
|
||||||
FlasherFlag1 = 0;
|
ToggledOffFlag = false;
|
||||||
TurnOffAfterFlashingFg = 0;
|
TurnOffAfterFlashingFg = false;
|
||||||
flasher_start(&Flasher, BmpIndex1);
|
flasher_start(LightOnFlag);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
Flasher.TimerDelay[0] = value * FlasherDelay[0];
|
FlashDelay[0] = value * SourceDelay[0];
|
||||||
Flasher.TimerDelay[1] = value * FlasherDelay[1];
|
FlashDelay[1] = value * SourceDelay[1];
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
Flasher.TimerDelay[0] = FlasherDelay[0];
|
FlashDelay[0] = SourceDelay[0];
|
||||||
Flasher.TimerDelay[1] = FlasherDelay[1];
|
FlashDelay[1] = SourceDelay[1];
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
if (!FlasherActive)
|
if (!FlasherOnFlag)
|
||||||
flasher_start(&Flasher, BmpIndex1);
|
flasher_start(LightOnFlag);
|
||||||
FlasherActive = 1;
|
FlasherOnFlag = true;
|
||||||
FlasherFlag2 = 0;
|
ToggledOnFlag = false;
|
||||||
TurnOffAfterFlashingFg = 0;
|
TurnOffAfterFlashingFg = false;
|
||||||
FlasherFlag1 = 0;
|
ToggledOffFlag = false;
|
||||||
schedule_timeout(value);
|
schedule_timeout(value);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
if (!FlasherFlag1)
|
if (!ToggledOffFlag)
|
||||||
{
|
{
|
||||||
if (FlasherActive)
|
if (FlasherOnFlag)
|
||||||
{
|
{
|
||||||
flasher_stop(&Flasher, 0);
|
flasher_stop(0);
|
||||||
FlasherActive = 0;
|
FlasherOnFlag = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[0]);
|
SetSpriteBmp(BmpArr[0]);
|
||||||
}
|
}
|
||||||
FlasherFlag1 = 1;
|
ToggledOffFlag = true;
|
||||||
FlasherFlag2 = 0;
|
ToggledOnFlag = false;
|
||||||
}
|
}
|
||||||
schedule_timeout(value);
|
schedule_timeout(value);
|
||||||
break;
|
break;
|
||||||
case 9:
|
case 9:
|
||||||
if (!FlasherFlag2)
|
if (!ToggledOnFlag)
|
||||||
{
|
{
|
||||||
if (FlasherActive)
|
if (FlasherOnFlag)
|
||||||
{
|
{
|
||||||
flasher_stop(&Flasher, 1);
|
flasher_stop(1);
|
||||||
FlasherActive = 0;
|
FlasherOnFlag = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[1]);
|
SetSpriteBmp(BmpArr[1]);
|
||||||
}
|
}
|
||||||
FlasherFlag2 = 1;
|
ToggledOnFlag = true;
|
||||||
FlasherFlag1 = 0;
|
ToggledOffFlag = false;
|
||||||
}
|
}
|
||||||
schedule_timeout(value);
|
schedule_timeout(value);
|
||||||
break;
|
break;
|
||||||
case 11:
|
case 11:
|
||||||
bmpIndex = 0;
|
LightOnBmpIndex = Clamp(static_cast<int>(floor(value)), 0, static_cast<int>(ListBitmap->size()) - 1);
|
||||||
BmpIndex2 = static_cast<int>(floor(value));
|
BmpArr[0] = nullptr;
|
||||||
if (BmpIndex2 > static_cast<int>(ListBitmap->size()))
|
BmpArr[1] = ListBitmap->at(LightOnBmpIndex);
|
||||||
BmpIndex2 = ListBitmap->size();
|
if (!FlasherOnFlag)
|
||||||
if (BmpIndex2 < 0)
|
|
||||||
BmpIndex2 = 0;
|
|
||||||
Flasher.BmpArr[0] = nullptr;
|
|
||||||
Flasher.BmpArr[1] = ListBitmap->at(BmpIndex2);
|
|
||||||
if (FlasherActive == 0)
|
|
||||||
{
|
{
|
||||||
if (!FlasherFlag1)
|
if (ToggledOffFlag)
|
||||||
{
|
bmpIndex = 0;
|
||||||
if (FlasherFlag2)
|
else if (ToggledOnFlag)
|
||||||
bmpIndex = 1;
|
bmpIndex = 1;
|
||||||
else
|
else
|
||||||
bmpIndex = BmpIndex1;
|
bmpIndex = LightOnFlag;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bmpIndex = Flasher.BmpIndex;
|
bmpIndex = FlashLightOnFlag;
|
||||||
}
|
}
|
||||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[bmpIndex]);
|
SetSpriteBmp(BmpArr[bmpIndex]);
|
||||||
break;
|
break;
|
||||||
case 12:
|
case 12:
|
||||||
bmpIndex = BmpIndex2 + 1;
|
bmpIndex = LightOnBmpIndex + 1;
|
||||||
if (bmpIndex > static_cast<int>(ListBitmap->size()))
|
if (bmpIndex >= static_cast<int>(ListBitmap->size()))
|
||||||
bmpIndex = ListBitmap->size();
|
bmpIndex = static_cast<int>(ListBitmap->size()) - 1;
|
||||||
Message(11, static_cast<float>(bmpIndex));
|
Message(11, static_cast<float>(bmpIndex));
|
||||||
break;
|
break;
|
||||||
case 13:
|
case 13:
|
||||||
bmpIndex = BmpIndex2 - 1;
|
bmpIndex = LightOnBmpIndex - 1;
|
||||||
if (bmpIndex < 0)
|
if (bmpIndex < 0)
|
||||||
bmpIndex = 0;
|
bmpIndex = 0;
|
||||||
Message(11, static_cast<float>(bmpIndex));
|
Message(11, static_cast<float>(bmpIndex));
|
||||||
break;
|
break;
|
||||||
case 14:
|
case 14:
|
||||||
if (Timer1)
|
if (TimeoutTimer)
|
||||||
timer::kill(Timer1);
|
timer::kill(TimeoutTimer);
|
||||||
Timer1 = 0;
|
TimeoutTimer = 0;
|
||||||
if (FlasherActive != 0)
|
if (FlasherOnFlag)
|
||||||
flasher_stop(&Flasher, -1);
|
flasher_stop(-1);
|
||||||
FlasherActive = 0;
|
FlasherOnFlag = false;
|
||||||
FlasherFlag1 = 0;
|
ToggledOffFlag = false;
|
||||||
FlasherFlag2 = 0;
|
ToggledOnFlag = false;
|
||||||
render::sprite_set_bitmap(RenderSprite, Flasher.BmpArr[BmpIndex1]);
|
SetSpriteBmp(BmpArr[LightOnFlag]);
|
||||||
break;
|
break;
|
||||||
case 15:
|
case 15:
|
||||||
TurnOffAfterFlashingFg = 0;
|
TurnOffAfterFlashingFg = false;
|
||||||
if (Timer2)
|
if (UndoOverrideTimer)
|
||||||
timer::kill(Timer2);
|
timer::kill(UndoOverrideTimer);
|
||||||
Timer2 = 0;
|
UndoOverrideTimer = 0;
|
||||||
Message(1, 0.0);
|
Message(1, 0.0);
|
||||||
Message(7, value);
|
Message(7, value);
|
||||||
break;
|
break;
|
||||||
case 16:
|
case 16:
|
||||||
if (Timer2)
|
if (UndoOverrideTimer)
|
||||||
timer::kill(Timer2);
|
timer::kill(UndoOverrideTimer);
|
||||||
Timer2 = 0;
|
UndoOverrideTimer = 0;
|
||||||
Message(7, value);
|
Message(7, value);
|
||||||
TurnOffAfterFlashingFg = 1;
|
TurnOffAfterFlashingFg = true;
|
||||||
break;
|
break;
|
||||||
case 17:
|
case 17:
|
||||||
Message(static_cast<int>(floor(value)) != 0, 0.0);
|
Message(static_cast<int>(floor(value)) != 0, 0.0);
|
||||||
return BmpIndex1;
|
return LightOnFlag;
|
||||||
case 18:
|
case 18:
|
||||||
Message(17, value);
|
Message(17, value);
|
||||||
Message(14, 0.0);
|
Message(14, 0.0);
|
||||||
return BmpIndex1;
|
return LightOnFlag;
|
||||||
case 19:
|
case 19:
|
||||||
Message(1, 0.0);
|
Message(1, 0.0);
|
||||||
Message(14, 0.0);
|
Message(14, 0.0);
|
||||||
|
@ -220,14 +214,34 @@ int TLight::Message(int code, float value)
|
||||||
Message(14, 0.0);
|
Message(14, 0.0);
|
||||||
break;
|
break;
|
||||||
case 21:
|
case 21:
|
||||||
Message(17, static_cast<float>(BmpIndex1 == 0));
|
Message(17, !LightOnFlag);
|
||||||
return BmpIndex1;
|
return LightOnFlag;
|
||||||
case 22:
|
case 22:
|
||||||
Message(18, static_cast<float>(BmpIndex1 == 0));
|
Message(18, !LightOnFlag);
|
||||||
return BmpIndex1;
|
return LightOnFlag;
|
||||||
case 23:
|
case 23:
|
||||||
MessageField = static_cast<int>(floor(value));
|
MessageField = static_cast<int>(floor(value));
|
||||||
break;
|
break;
|
||||||
|
case -24:
|
||||||
|
case -25:
|
||||||
|
// FT codes in negative to avoid overlap with 3DPB TLightGroup codes
|
||||||
|
render::sprite_set_bitmap(RenderSprite, BmpArr[code == -24]);
|
||||||
|
if (UndoOverrideTimer)
|
||||||
|
timer::kill(UndoOverrideTimer);
|
||||||
|
UndoOverrideTimer = 0;
|
||||||
|
if (value > 0)
|
||||||
|
{
|
||||||
|
TemporaryOverrideFlag = true;
|
||||||
|
UndoOverrideTimer = timer::set(value, this, UndoTmpOverride);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case -26:
|
||||||
|
if (UndoOverrideTimer)
|
||||||
|
timer::kill(UndoOverrideTimer);
|
||||||
|
UndoOverrideTimer = 0;
|
||||||
|
TemporaryOverrideFlag = false;
|
||||||
|
render::sprite_set_bitmap(RenderSprite, PreviousBitmap);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -237,55 +251,53 @@ int TLight::Message(int code, float value)
|
||||||
|
|
||||||
void TLight::Reset()
|
void TLight::Reset()
|
||||||
{
|
{
|
||||||
if (Timer1)
|
if (TimeoutTimer)
|
||||||
timer::kill(Timer1);
|
timer::kill(TimeoutTimer);
|
||||||
if (Timer2)
|
if (UndoOverrideTimer)
|
||||||
timer::kill(Timer2);
|
timer::kill(UndoOverrideTimer);
|
||||||
if (FlasherActive)
|
if (FlasherOnFlag)
|
||||||
flasher_stop(&Flasher, -1);
|
flasher_stop(-1);
|
||||||
Unknown20F = 1.0;
|
TimeoutTimer = 0;
|
||||||
Timer1 = 0;
|
UndoOverrideTimer = 0;
|
||||||
Timer2 = 0;
|
LightOnFlag = false;
|
||||||
BmpIndex1 = 0;
|
LightOnBmpIndex = 0;
|
||||||
BmpIndex2 = 0;
|
ToggledOffFlag = false;
|
||||||
FlasherFlag1 = 0;
|
ToggledOnFlag = false;
|
||||||
FlasherFlag2 = 0;
|
FlasherOnFlag = false;
|
||||||
FlasherActive = 0;
|
TemporaryOverrideFlag = false;
|
||||||
TurnOffAfterFlashingFg = 0;
|
TurnOffAfterFlashingFg = false;
|
||||||
|
PreviousBitmap = nullptr;
|
||||||
render::sprite_set_bitmap(RenderSprite, nullptr);
|
render::sprite_set_bitmap(RenderSprite, nullptr);
|
||||||
Flasher.Sprite = RenderSprite;
|
BmpArr[0] = nullptr;
|
||||||
Flasher.BmpArr[0] = nullptr;
|
|
||||||
if (ListBitmap)
|
if (ListBitmap)
|
||||||
Flasher.BmpArr[1] = ListBitmap->at(0);
|
BmpArr[1] = ListBitmap->at(0);
|
||||||
Flasher.Unknown4 = 0;
|
|
||||||
Flasher.Unknown3 = 0;
|
|
||||||
MessageField = 0;
|
MessageField = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLight::schedule_timeout(float time)
|
void TLight::schedule_timeout(float time)
|
||||||
{
|
{
|
||||||
Flasher.TimerDelay[0] = FlasherDelay[0];
|
FlashDelay[0] = SourceDelay[0];
|
||||||
Flasher.TimerDelay[1] = FlasherDelay[1];
|
FlashDelay[1] = SourceDelay[1];
|
||||||
if (Timer1)
|
if (TimeoutTimer)
|
||||||
timer::kill(Timer1);
|
timer::kill(TimeoutTimer);
|
||||||
Timer1 = 0;
|
TimeoutTimer = 0;
|
||||||
if (time > 0.0f)
|
if (time > 0.0f)
|
||||||
Timer1 = timer::set(time, this, TimerExpired);
|
TimeoutTimer = timer::set(time, this, TimerExpired);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLight::TimerExpired(int timerId, void* caller)
|
void TLight::TimerExpired(int timerId, void* caller)
|
||||||
{
|
{
|
||||||
auto light = static_cast<TLight*>(caller);
|
auto light = static_cast<TLight*>(caller);
|
||||||
if (light->FlasherActive)
|
if (light->FlasherOnFlag)
|
||||||
flasher_stop(&light->Flasher, -1);
|
light->flasher_stop(-1);
|
||||||
render::sprite_set_bitmap(light->RenderSprite, light->Flasher.BmpArr[light->BmpIndex1]);
|
light->SetSpriteBmp(light->BmpArr[light->LightOnFlag]);
|
||||||
light->FlasherFlag1 = 0;
|
light->ToggledOffFlag = false;
|
||||||
light->FlasherFlag2 = 0;
|
light->ToggledOnFlag = false;
|
||||||
light->FlasherActive = 0;
|
light->FlasherOnFlag = false;
|
||||||
light->Timer1 = 0;
|
light->TimeoutTimer = 0;
|
||||||
if (light->TurnOffAfterFlashingFg != 0)
|
if (light->TurnOffAfterFlashingFg)
|
||||||
{
|
{
|
||||||
light->TurnOffAfterFlashingFg = 0;
|
light->TurnOffAfterFlashingFg = false;
|
||||||
light->Message(20, 0.0);
|
light->Message(20, 0.0);
|
||||||
}
|
}
|
||||||
if (light->Control)
|
if (light->Control)
|
||||||
|
@ -293,29 +305,41 @@ void TLight::TimerExpired(int timerId, void* caller)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TLight::flasher_stop(flasher_type* flash, int bmpIndex)
|
void TLight::flasher_stop(int bmpIndex)
|
||||||
{
|
{
|
||||||
if (flash->Timer)
|
if (FlashTimer)
|
||||||
timer::kill(flash->Timer);
|
timer::kill(FlashTimer);
|
||||||
flash->Timer = 0;
|
FlashTimer = 0;
|
||||||
if (bmpIndex >= 0)
|
if (bmpIndex >= 0)
|
||||||
{
|
{
|
||||||
flash->BmpIndex = bmpIndex;
|
FlashLightOnFlag = bmpIndex;
|
||||||
render::sprite_set_bitmap(flash->Sprite, flash->BmpArr[bmpIndex]);
|
SetSpriteBmp(BmpArr[FlashLightOnFlag]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLight::flasher_start(flasher_type* flash, int bmpIndex)
|
void TLight::flasher_start(bool bmpIndex)
|
||||||
{
|
{
|
||||||
flash->BmpIndex = bmpIndex;
|
FlashLightOnFlag = bmpIndex;
|
||||||
flasher_callback(0, flash);
|
flasher_callback(0, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TLight::SetSpriteBmp(gdrv_bitmap8* bmp)
|
||||||
|
{
|
||||||
|
PreviousBitmap = bmp;
|
||||||
|
if (!TemporaryOverrideFlag)
|
||||||
|
render::sprite_set_bitmap(RenderSprite, bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TLight::flasher_callback(int timerId, void* caller)
|
void TLight::flasher_callback(int timerId, void* caller)
|
||||||
{
|
{
|
||||||
auto flash = static_cast<flasher_type*>(caller);
|
auto light = static_cast<TLight*>(caller);
|
||||||
auto index = 1 - flash->BmpIndex;
|
light->FlashLightOnFlag ^= true;
|
||||||
flash->BmpIndex = index;
|
light->SetSpriteBmp(light->BmpArr[light->FlashLightOnFlag]);
|
||||||
render::sprite_set_bitmap(flash->Sprite, flash->BmpArr[index]);
|
light->FlashTimer = timer::set(light->FlashDelay[light->FlashLightOnFlag], light, flasher_callback);
|
||||||
flash->Timer = timer::set(flash->TimerDelay[flash->BmpIndex], flash, flasher_callback);
|
}
|
||||||
|
|
||||||
|
void TLight::UndoTmpOverride(int timerId, void* caller)
|
||||||
|
{
|
||||||
|
auto light = static_cast<TLight*>(caller);
|
||||||
|
light->Message(-26, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,26 +3,12 @@
|
||||||
|
|
||||||
struct gdrv_bitmap8;
|
struct gdrv_bitmap8;
|
||||||
|
|
||||||
struct flasher_type
|
|
||||||
{
|
|
||||||
render_sprite_type_struct* Sprite;
|
|
||||||
gdrv_bitmap8* BmpArr[2];
|
|
||||||
int Unknown3;
|
|
||||||
int Unknown4;
|
|
||||||
float TimerDelay[2];
|
|
||||||
int Timer;
|
|
||||||
int BmpIndex;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct TLight_player_backup
|
struct TLight_player_backup
|
||||||
{
|
{
|
||||||
int MessageField;
|
int MessageField;
|
||||||
int BmpIndex1;
|
bool LightOnFlag;
|
||||||
int FlasherActive;
|
int LightOnBmpIndex;
|
||||||
int Unknown3;
|
bool FlasherOnFlag;
|
||||||
int Unknown4;
|
|
||||||
int BmpIndex2;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -34,22 +20,28 @@ public:
|
||||||
int Message(int code, float value) override;
|
int Message(int code, float value) override;
|
||||||
void Reset();
|
void Reset();
|
||||||
void schedule_timeout(float time);
|
void schedule_timeout(float time);
|
||||||
|
void flasher_stop(int bmpIndex);
|
||||||
|
void flasher_start(bool bmpIndex);
|
||||||
|
void SetSpriteBmp(gdrv_bitmap8* bmp);
|
||||||
|
|
||||||
static void TimerExpired(int timerId, void* caller);
|
static void TimerExpired(int timerId, void* caller);
|
||||||
static void flasher_stop(flasher_type* flash, int bmpIndex);
|
|
||||||
static void flasher_start(struct flasher_type* flash, int bmpIndex);
|
|
||||||
static void flasher_callback(int timerId, void* caller);
|
static void flasher_callback(int timerId, void* caller);
|
||||||
|
static void UndoTmpOverride(int timerId, void* caller);
|
||||||
|
|
||||||
flasher_type Flasher{};
|
gdrv_bitmap8* BmpArr[2];
|
||||||
int BmpIndex1{};
|
float FlashDelay[2];
|
||||||
int FlasherActive;
|
int FlashTimer;
|
||||||
int FlasherFlag1{};
|
bool FlashLightOnFlag;
|
||||||
int FlasherFlag2{};
|
bool LightOnFlag{};
|
||||||
int TurnOffAfterFlashingFg{};
|
bool FlasherOnFlag;
|
||||||
int BmpIndex2{};
|
bool ToggledOffFlag{};
|
||||||
float FlasherDelay[2]{};
|
bool ToggledOnFlag{};
|
||||||
int Timer1;
|
bool TurnOffAfterFlashingFg{};
|
||||||
int Timer2;
|
int LightOnBmpIndex{};
|
||||||
float Unknown20F{};
|
float SourceDelay[2]{};
|
||||||
|
int TimeoutTimer;
|
||||||
|
int UndoOverrideTimer;
|
||||||
|
bool TemporaryOverrideFlag{};
|
||||||
|
gdrv_bitmap8* PreviousBitmap{};
|
||||||
TLight_player_backup PlayerData[4]{};
|
TLight_player_backup PlayerData[4]{};
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,7 +66,7 @@ int TLightGroup::Message(int code, float value)
|
||||||
case 24:
|
case 24:
|
||||||
{
|
{
|
||||||
auto lastLight = List.at(count - 1);
|
auto lastLight = List.at(count - 1);
|
||||||
if (lastLight->FlasherActive || lastLight->FlasherFlag2 || lastLight->FlasherFlag1)
|
if (lastLight->FlasherOnFlag || lastLight->ToggledOnFlag || lastLight->ToggledOffFlag)
|
||||||
break;
|
break;
|
||||||
if (MessageField2)
|
if (MessageField2)
|
||||||
{
|
{
|
||||||
|
@ -75,16 +75,16 @@ int TLightGroup::Message(int code, float value)
|
||||||
AnimationFlag = 1;
|
AnimationFlag = 1;
|
||||||
MessageField2 = code;
|
MessageField2 = code;
|
||||||
auto lightMessageField = lastLight->MessageField;
|
auto lightMessageField = lastLight->MessageField;
|
||||||
auto bmpIndex1 = lastLight->BmpIndex1;
|
auto lightStatusBefore = lastLight->LightOnFlag;
|
||||||
for (auto index = count - 1; index > 0; --index)
|
for (auto index = count - 1; index > 0; --index)
|
||||||
{
|
{
|
||||||
auto lightCur = List.at(index);
|
auto lightCur = List.at(index);
|
||||||
auto lightPrev = List.at(index - 1);
|
auto lightPrev = List.at(index - 1);
|
||||||
lightCur->Message(lightPrev->BmpIndex1 != 0, 0.0);
|
lightCur->Message(lightPrev->LightOnFlag, 0.0);
|
||||||
lightCur->MessageField = lightPrev->MessageField;
|
lightCur->MessageField = lightPrev->MessageField;
|
||||||
}
|
}
|
||||||
auto firstLight = List.at(0);
|
auto firstLight = List.at(0);
|
||||||
firstLight->Message(bmpIndex1 != 0, 0.0);
|
firstLight->Message(lightStatusBefore, 0.0);
|
||||||
firstLight->MessageField = lightMessageField;
|
firstLight->MessageField = lightMessageField;
|
||||||
reschedule_animation(value);
|
reschedule_animation(value);
|
||||||
break;
|
break;
|
||||||
|
@ -92,7 +92,7 @@ int TLightGroup::Message(int code, float value)
|
||||||
case 25:
|
case 25:
|
||||||
{
|
{
|
||||||
auto lastLight = List.at(count - 1);
|
auto lastLight = List.at(count - 1);
|
||||||
if (lastLight->FlasherActive || lastLight->FlasherFlag2 || lastLight->FlasherFlag1)
|
if (lastLight->FlasherOnFlag || lastLight->ToggledOnFlag || lastLight->ToggledOffFlag)
|
||||||
break;
|
break;
|
||||||
if (MessageField2)
|
if (MessageField2)
|
||||||
{
|
{
|
||||||
|
@ -102,15 +102,15 @@ int TLightGroup::Message(int code, float value)
|
||||||
AnimationFlag = 1;
|
AnimationFlag = 1;
|
||||||
MessageField2 = code;
|
MessageField2 = code;
|
||||||
auto lightMessageField = firstLight->MessageField;
|
auto lightMessageField = firstLight->MessageField;
|
||||||
auto bmpIndex1 = firstLight->BmpIndex1;
|
auto lightStatusBefore = firstLight->LightOnFlag;
|
||||||
for (auto index = 0; index < count - 1; index++)
|
for (auto index = 0; index < count - 1; index++)
|
||||||
{
|
{
|
||||||
auto lightCur = List.at(index);
|
auto lightCur = List.at(index);
|
||||||
auto lightNext = List.at(index + 1);
|
auto lightNext = List.at(index + 1);
|
||||||
lightCur->Message(lightNext->BmpIndex1 != 0, 0.0);
|
lightCur->Message(lightNext->LightOnFlag, 0.0);
|
||||||
lightCur->MessageField = lightNext->MessageField;
|
lightCur->MessageField = lightNext->MessageField;
|
||||||
}
|
}
|
||||||
lastLight->Message(bmpIndex1 != 0, 0.0);
|
lastLight->Message(lightStatusBefore, 0.0);
|
||||||
lastLight->MessageField = lightMessageField;
|
lastLight->MessageField = lightMessageField;
|
||||||
reschedule_animation(value);
|
reschedule_animation(value);
|
||||||
break;
|
break;
|
||||||
|
@ -122,12 +122,12 @@ int TLightGroup::Message(int code, float value)
|
||||||
MessageField2 = code;
|
MessageField2 = code;
|
||||||
AnimationFlag = 0;
|
AnimationFlag = 0;
|
||||||
auto lastLight = List.at(count - 1);
|
auto lastLight = List.at(count - 1);
|
||||||
auto flasherFlag2 = lastLight->FlasherFlag2;
|
auto flasherFlag2 = lastLight->ToggledOnFlag;
|
||||||
for (auto i = count - 1; i > 0; --i)
|
for (auto i = count - 1; i > 0; --i)
|
||||||
{
|
{
|
||||||
auto lightCur = List.at(i);
|
auto lightCur = List.at(i);
|
||||||
auto lightPrev = List.at(i - 1);
|
auto lightPrev = List.at(i - 1);
|
||||||
lightCur->Message((lightPrev->FlasherFlag2 != 0) + 8, 0.0);
|
lightCur->Message(lightPrev->ToggledOnFlag + 8, 0.0);
|
||||||
}
|
}
|
||||||
auto firstLight = List.at(0);
|
auto firstLight = List.at(0);
|
||||||
firstLight->Message((flasherFlag2 != 0) + 8, 0);
|
firstLight->Message((flasherFlag2 != 0) + 8, 0);
|
||||||
|
@ -141,12 +141,12 @@ int TLightGroup::Message(int code, float value)
|
||||||
MessageField2 = code;
|
MessageField2 = code;
|
||||||
AnimationFlag = 0;
|
AnimationFlag = 0;
|
||||||
auto firstLight = List.at(0);
|
auto firstLight = List.at(0);
|
||||||
auto flasherFlag2 = firstLight->FlasherFlag2;
|
auto flasherFlag2 = firstLight->ToggledOnFlag;
|
||||||
for (auto i = 0; i < count - 1; i++)
|
for (auto i = 0; i < count - 1; i++)
|
||||||
{
|
{
|
||||||
auto lightCur = List.at(i);
|
auto lightCur = List.at(i);
|
||||||
auto lightNext = List.at(i + 1);
|
auto lightNext = List.at(i + 1);
|
||||||
lightCur->Message((lightNext->FlasherFlag2 != 0) + 8, 0.0);
|
lightCur->Message(lightNext->ToggledOnFlag + 8, 0.0);
|
||||||
}
|
}
|
||||||
auto lastLight = List.at(count - 1);
|
auto lastLight = List.at(count - 1);
|
||||||
lastLight->Message((flasherFlag2 != 0) + 8, 0);
|
lastLight->Message((flasherFlag2 != 0) + 8, 0);
|
||||||
|
@ -189,7 +189,7 @@ int TLightGroup::Message(int code, float value)
|
||||||
auto noBmpInd1Count = 0;
|
auto noBmpInd1Count = 0;
|
||||||
for (auto light : List)
|
for (auto light : List)
|
||||||
{
|
{
|
||||||
if (!light->BmpIndex1)
|
if (!light->LightOnFlag)
|
||||||
++noBmpInd1Count;
|
++noBmpInd1Count;
|
||||||
}
|
}
|
||||||
if (!noBmpInd1Count)
|
if (!noBmpInd1Count)
|
||||||
|
@ -199,7 +199,7 @@ int TLightGroup::Message(int code, float value)
|
||||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||||
{
|
{
|
||||||
auto light = *it;
|
auto light = *it;
|
||||||
if (!light->BmpIndex1 && randModCount-- == 0)
|
if (!light->LightOnFlag && randModCount-- == 0)
|
||||||
{
|
{
|
||||||
light->Message(1, 0.0);
|
light->Message(1, 0.0);
|
||||||
break;
|
break;
|
||||||
|
@ -215,7 +215,7 @@ int TLightGroup::Message(int code, float value)
|
||||||
auto bmpInd1Count = 0;
|
auto bmpInd1Count = 0;
|
||||||
for (auto light : List)
|
for (auto light : List)
|
||||||
{
|
{
|
||||||
if (light->BmpIndex1)
|
if (light->LightOnFlag)
|
||||||
++bmpInd1Count;
|
++bmpInd1Count;
|
||||||
}
|
}
|
||||||
if (!bmpInd1Count)
|
if (!bmpInd1Count)
|
||||||
|
@ -225,7 +225,7 @@ int TLightGroup::Message(int code, float value)
|
||||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||||
{
|
{
|
||||||
auto light = *it;
|
auto light = *it;
|
||||||
if (light->BmpIndex1 && randModCount-- == 0)
|
if (light->LightOnFlag && randModCount-- == 0)
|
||||||
{
|
{
|
||||||
light->Message(0, 0.0);
|
light->Message(0, 0.0);
|
||||||
break;
|
break;
|
||||||
|
@ -296,7 +296,7 @@ int TLightGroup::Message(int code, float value)
|
||||||
auto bmp1Count = 0;
|
auto bmp1Count = 0;
|
||||||
for (auto light : List)
|
for (auto light : List)
|
||||||
{
|
{
|
||||||
if (light->BmpIndex1)
|
if (light->LightOnFlag)
|
||||||
++bmp1Count;
|
++bmp1Count;
|
||||||
}
|
}
|
||||||
return bmp1Count;
|
return bmp1Count;
|
||||||
|
@ -339,7 +339,7 @@ int TLightGroup::Message(int code, float value)
|
||||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||||
{
|
{
|
||||||
auto light = *it;
|
auto light = *it;
|
||||||
if (light->BmpIndex1)
|
if (light->LightOnFlag)
|
||||||
{
|
{
|
||||||
light->Message(0, 0.0);
|
light->Message(0, 0.0);
|
||||||
light->Message(16, value);
|
light->Message(16, value);
|
||||||
|
@ -421,7 +421,7 @@ void TLightGroup::start_animation()
|
||||||
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
for (auto it = List.rbegin(); it != List.rend(); ++it)
|
||||||
{
|
{
|
||||||
auto light = *it;
|
auto light = *it;
|
||||||
if (light->BmpIndex1)
|
if (light->LightOnFlag)
|
||||||
light->Message(9, 0.0);
|
light->Message(9, 0.0);
|
||||||
else
|
else
|
||||||
light->Message(8, 0.0);
|
light->Message(8, 0.0);
|
||||||
|
@ -432,7 +432,7 @@ int TLightGroup::next_light_up()
|
||||||
{
|
{
|
||||||
for (auto index = 0u; index < List.size(); ++index)
|
for (auto index = 0u; index < List.size(); ++index)
|
||||||
{
|
{
|
||||||
if (!List[index]->BmpIndex1)
|
if (!List[index]->LightOnFlag)
|
||||||
return static_cast<int>(index);
|
return static_cast<int>(index);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -442,7 +442,7 @@ int TLightGroup::next_light_down()
|
||||||
{
|
{
|
||||||
for (auto index = static_cast<int>(List.size()) - 1; index >= 0; --index)
|
for (auto index = static_cast<int>(List.size()) - 1; index >= 0; --index)
|
||||||
{
|
{
|
||||||
if (List.at(index)->BmpIndex1)
|
if (List.at(index)->LightOnFlag)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
@ -999,7 +999,7 @@ void control::cheat_bump_rank()
|
||||||
bool control::light_on(component_tag<TLight>* tag)
|
bool control::light_on(component_tag<TLight>* tag)
|
||||||
{
|
{
|
||||||
auto light = tag->Component;
|
auto light = tag->Component;
|
||||||
return light->BmpIndex1 || light->FlasherFlag2 || light->FlasherActive;
|
return light->LightOnFlag || light->ToggledOnFlag || light->FlasherOnFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
int control::SpecialAddScore(int score)
|
int control::SpecialAddScore(int score)
|
||||||
|
@ -1297,9 +1297,9 @@ void control::ReentryLanesRolloverControl(int code, TPinballComponent* caller)
|
||||||
if (roll2 != caller)
|
if (roll2 != caller)
|
||||||
light = lite10;
|
light = lite10;
|
||||||
}
|
}
|
||||||
if (!light->FlasherActive)
|
if (!light->FlasherOnFlag)
|
||||||
{
|
{
|
||||||
if (light->BmpIndex1)
|
if (light->LightOnFlag)
|
||||||
{
|
{
|
||||||
light->Message(20, 0.0);
|
light->Message(20, 0.0);
|
||||||
}
|
}
|
||||||
|
@ -1353,9 +1353,9 @@ void control::LaunchLanesRolloverControl(int code, TPinballComponent* caller)
|
||||||
if (roll111 != caller)
|
if (roll111 != caller)
|
||||||
light = lite169;
|
light = lite169;
|
||||||
}
|
}
|
||||||
if (!light->FlasherActive)
|
if (!light->FlasherOnFlag)
|
||||||
{
|
{
|
||||||
if (light->BmpIndex1)
|
if (light->LightOnFlag)
|
||||||
{
|
{
|
||||||
light->Message(20, 0.0);
|
light->Message(20, 0.0);
|
||||||
}
|
}
|
||||||
|
@ -1865,7 +1865,7 @@ void control::MissionSpotTargetControl(int code, TPinballComponent* caller)
|
||||||
lite->Message(15, 2.0);
|
lite->Message(15, 2.0);
|
||||||
|
|
||||||
TSound* sound;
|
TSound* sound;
|
||||||
if (!light_on(&control_lite198_tag) || lite198->FlasherActive)
|
if (!light_on(&control_lite198_tag) || lite198->FlasherOnFlag)
|
||||||
{
|
{
|
||||||
sound = soundwave52;
|
sound = soundwave52;
|
||||||
}
|
}
|
||||||
|
|
|
@ -513,6 +513,12 @@ void pb::InputDown(GameInput input)
|
||||||
case SDLK_F12:
|
case SDLK_F12:
|
||||||
MainTable->port_draw();
|
MainTable->port_draw();
|
||||||
break;
|
break;
|
||||||
|
case 'i':
|
||||||
|
MainTable->LightGroup->Message(-24, 1.0f);
|
||||||
|
break;
|
||||||
|
case 'j':
|
||||||
|
MainTable->LightGroup->Message(-25, 1.0f);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue