Display zeros and cleanup gameloop output

This commit is contained in:
Paul Dino Jones 2022-12-01 21:25:26 +00:00
parent 9325e207be
commit cc3ca995e3
1 changed files with 80 additions and 58 deletions

View File

@ -33,6 +33,8 @@ int showstats(SimData* simdata)
int speed = simdata->velocity;
int digits = 0;
if (speed > 0)
{
while (speed > 0)
{
int mod = speed % 10;
@ -56,6 +58,11 @@ int showstats(SimData* simdata)
fputc(s[digit-1]+'0', stdout);
digit--;
}
}
else
{
fputc('0', stdout);
}
fputc(' ', stdout);
}
if (i==1)
@ -69,6 +76,8 @@ int showstats(SimData* simdata)
int rpms = simdata->rpms;
int digits = 0;
if (rpms > 0)
{
while (rpms > 0)
{
int mod = rpms % 10;
@ -92,6 +101,11 @@ int showstats(SimData* simdata)
fputc(s[digit-1]+'0', stdout);
digit--;
}
}
else
{
fputc('0', stdout);
}
fputc(' ', stdout);
}
if (i==2)
@ -115,6 +129,8 @@ int showstats(SimData* simdata)
int alt = simdata->altitude;
int digits = 0;
if (alt > 0)
{
while (alt > 0)
{
int mod = alt % 10;
@ -138,6 +154,11 @@ int showstats(SimData* simdata)
fputc(s[digit-1]+'0', stdout);
digit--;
}
}
else
{
fputc('0', stdout);
}
fputc(' ', stdout);
}
}
@ -208,7 +229,8 @@ int looper(SimDevice* devices[], int numdevices, Simulator simulator)
}
}
}
fprintf(stdout, "\n");
fflush(stdout);
tcsetattr(0, TCSANOW, &canonicalmode);
free(simdata);