Skip to content

Commit 7491ed4

Browse files
committed
updated depencies and increased communication speed a bit
1 parent f15fc12 commit 7491ed4

File tree

2 files changed

+18
-27
lines changed

2 files changed

+18
-27
lines changed

platforms/config.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ set -e
44

55
SDL_SHA=a8589a84226a6202831a3d49ff4edda4acab9acd
66
SDL_IMAGE_SHA=11154afb7855293159588b245b446a4ef09e574f
7-
PINMAME_SHA=518ebdae4483a654eb7d292469e7d21d25ffacc9
8-
LIBPPUC_SHA=db26ec9233a84f01246562e3c03718f1d649acec
9-
LIBDMDUTIL_SHA=cc1d3f663516458c427acdf4aa07c56192a67be3
7+
PINMAME_SHA=2346ed9951b33e83f3bdd46338a5d9cc4707757c
8+
LIBPPUC_SHA=61651c190235e1d0d00f6e7f1e6c7b95fea61e04
9+
LIBDMDUTIL_SHA=5c916d53f5ff6535a1403f6734218550ca2a7e87
1010

1111

1212
if [ -z "${BUILD_TYPE}" ]; then

src/ppuc.cpp

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "io-boards/Event.h"
2929
#include "libpinmame.h"
3030

31+
#define MAIN_LOOP_SLEEP_US 20 // Main loop sleep time in microseconds
32+
3133
SDL_AudioStream* m_pstream = nullptr;
3234
SDL_AudioSpec audioSpec;
3335

@@ -902,44 +904,33 @@ int main(int argc, char** argv)
902904

903905
if (PinmameRun(opt_rom) == PINMAME_STATUS_OK)
904906
{
905-
// Pinball machines were slower than modern CPUs. There's no need to
906-
// update states too frequently at full speed.
907-
int sleep_us = 1000;
908-
// Poll I/O boards for events (mainly switches) every 50us.
909-
int poll_interval_ms = 50;
910-
int poll_trigger = poll_interval_ms * 1000 / sleep_us;
911907
int index_recv = 0;
912908

913909
ppuc->StartUpdates();
914910

915911
while (running)
916912
{
917-
std::this_thread::sleep_for(std::chrono::microseconds(sleep_us));
913+
std::this_thread::sleep_for(std::chrono::microseconds(MAIN_LOOP_SLEEP_US));
918914

919915
if (!game_state)
920916
{
921917
continue;
922918
}
923919

924-
if (--poll_trigger <= 0)
920+
PPUCSwitchState* switchState;
921+
while ((switchState = ppuc->GetNextSwitchState()) != nullptr)
925922
{
926-
poll_trigger = poll_interval_ms * 1000 / sleep_us;
927-
928-
PPUCSwitchState* switchState;
929-
while ((switchState = ppuc->GetNextSwitchState()) != nullptr)
923+
if (opt_debug || opt_debug_switches)
930924
{
931-
if (opt_debug || opt_debug_switches)
932-
{
933-
printf("Switch updated: #%d, %d\n", switchState->number, switchState->state);
934-
}
925+
printf("Switch updated: #%d, %d\n", switchState->number, switchState->state);
926+
}
935927

936-
// Switches between 200 and 240 are custom switches within the io-boards which should not be sent to
937-
// pinmame. Switches above 240 will become negative values, for example 243 => -3.
938-
if (switchState->number < 200 || switchState->number > 241)
939-
{
940-
int switchNumber = (switchState->number < 241) ? switchState->number : 240 - switchState->number;
941-
PinmameSetSwitch(switchNumber, switchState->state);
942-
}
928+
// Switches between 200 and 240 are custom switches within the io-boards which should not be sent to
929+
// pinmame. Switches above 240 will become negative values, for example 243 => -3.
930+
if (switchState->number < 200 || switchState->number > 241)
931+
{
932+
int switchNumber = (switchState->number < 241) ? switchState->number : 240 - switchState->number;
933+
PinmameSetSwitch(switchNumber, switchState->state);
943934
}
944935
}
945936

@@ -957,7 +948,7 @@ int main(int argc, char** argv)
957948
ppuc->SetLampState(lampNo, lampState);
958949
}
959950

960-
{
951+
{ // Needs to be a separate scope for the lock_guard
961952
// Process any pending render requests
962953
std::lock_guard<std::mutex> lock(renderMutex);
963954
while (!renderQueue.empty())

0 commit comments

Comments
 (0)