aboutsummaryrefslogtreecommitdiff
path: root/Source/Aircraft.c
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2018-01-03 21:17:28 +0100
committerXaviDCR92 <xavi.dcr@gmail.com>2018-01-03 21:17:28 +0100
commit7d14b5036066d9391d52ab73ca4b26c03e3cb6c2 (patch)
treeffb09d916304aa361946cad00858b178071164e2 /Source/Aircraft.c
parentb094335404446183954eb1ccaba33f5f4888eacf (diff)
downloadairport-7d14b5036066d9391d52ab73ca4b26c03e3cb6c2.tar.gz
* Aircraft.c: since "rotate" member != 0 would render ArrowSpr incorrectly, I have created two separate sprites: LeftRightArrowSpr and UpDownArrowSpr. Still, H_FLIP isn't working properly.
* GameGui.c: new function GameGuiCalculateNextAircraftTime(), which calculates remaining time for next aircraft on the list. * GameStructures.h: new parameter NextAircraftTime for TYPE_PLAYER structures. * Game.c: added call to new function GameGuiCalculateNextAircraftTime().
Diffstat (limited to 'Source/Aircraft.c')
-rw-r--r--Source/Aircraft.c69
1 files changed, 51 insertions, 18 deletions
diff --git a/Source/Aircraft.c b/Source/Aircraft.c
index 87685ba..8af8ad8 100644
--- a/Source/Aircraft.c
+++ b/Source/Aircraft.c
@@ -51,15 +51,18 @@ typedef enum t_aircraftSpeeds
static TYPE_AIRCRAFT_DATA AircraftData[GAME_MAX_AIRCRAFT];
static uint8_t AircraftIndex;
static GsSprite AircraftSpr;
-static GsSprite ArrowSpr;
+static GsSprite UpDownArrowSpr;
+static GsSprite LeftRightArrowSpr;
static TYPE_ISOMETRIC_POS AircraftCenterIsoPos;
static TYPE_CARTESIAN_POS AircraftCenterPos;
static char* AircraftLiveryNamesTable[] = {"PHX", NULL};
static AIRCRAFT_LIVERY AircraftLiveryTable[] = {AIRCRAFT_LIVERY_0, AIRCRAFT_LIVERY_UNKNOWN};
-static const char* GameFileList[] = { "cdrom:\\DATA\\SPRITES\\ARROW.TIM;1" };
+static const char* GameFileList[] = { "cdrom:\\DATA\\SPRITES\\UDNARROW.TIM;1",
+ "cdrom:\\DATA\\SPRITES\\LFRARROW.TIM;1" };
-static void* GameFileDest[] = { (GsSprite*)&ArrowSpr };
+static void* GameFileDest[] = { (GsSprite*)&UpDownArrowSpr,
+ (GsSprite*)&LeftRightArrowSpr };
// Used to quickly link FlightData indexes against AircraftData indexes.
static uint8_t AircraftFlightDataIdx_HashTable[GAME_MAX_AIRCRAFT];
@@ -503,38 +506,68 @@ void AircraftRender(TYPE_PLAYER* ptrPlayer, uint8_t aircraftIdx)
if (GfxIsSpriteInsideScreenArea(&AircraftSpr) == false)
{
+ bool showLRArrow = false;
+ bool showUPDNArrow = false;
// When aircraft can't be shown on screen,
// show an arrow indicating its position.
if (AircraftSpr.x < 0)
{
- ArrowSpr.x = 0;
+ LeftRightArrowSpr.x = 0;
+ LeftRightArrowSpr.attribute |= H_FLIP;
+ showLRArrow = true;
}
else if (AircraftSpr.x > X_SCREEN_RESOLUTION)
{
- ArrowSpr.x = X_SCREEN_RESOLUTION - ArrowSpr.w;
- ArrowSpr.mx = ArrowSpr.w >> 1;
- ArrowSpr.my = ArrowSpr.h >> 1;
+ LeftRightArrowSpr.x = X_SCREEN_RESOLUTION - (LeftRightArrowSpr.w << 1);
+ LeftRightArrowSpr.attribute &= ~(H_FLIP);
+ showLRArrow = true;
}
- else
- {
- ArrowSpr.x = AircraftSpr.x;
- }
-
- if (AircraftSpr.y < 0)
+ else if (AircraftSpr.y < 0)
{
- ArrowSpr.y = 0;
+ UpDownArrowSpr.y = 0;
+ UpDownArrowSpr.attribute &= ~(V_FLIP);
+ showUPDNArrow = true;
}
else if (AircraftSpr.y > Y_SCREEN_RESOLUTION)
{
- ArrowSpr.y = Y_SCREEN_RESOLUTION;
+ UpDownArrowSpr.y = Y_SCREEN_RESOLUTION - (UpDownArrowSpr.h);
+ UpDownArrowSpr.attribute |= V_FLIP;
+ showUPDNArrow = true;
}
- else
+
+ if (showLRArrow != false)
{
- ArrowSpr.y = AircraftSpr.y;
+ LeftRightArrowSpr.y = AircraftSpr.y;
+
+ // First, saturate calculated Y values to {0, Y_SCREEN_RESOLUTION - LeftRightArrowSpr.h}.
+ if (LeftRightArrowSpr.y < 0)
+ {
+ LeftRightArrowSpr.y = 0;
+ }
+ else if (LeftRightArrowSpr.y > (Y_SCREEN_RESOLUTION - LeftRightArrowSpr.h) )
+ {
+ LeftRightArrowSpr.y = (Y_SCREEN_RESOLUTION - LeftRightArrowSpr.h);
+ }
+
+ GfxSortSprite(&LeftRightArrowSpr);
}
+ else if (showUPDNArrow != false)
+ {
+ UpDownArrowSpr.x = AircraftSpr.x;
+
+ // First, saturate calculated Y values to {0, Y_SCREEN_RESOLUTION - UpDownArrowSpr.h}.
+ if (UpDownArrowSpr.x < 0)
+ {
+ UpDownArrowSpr.x = 0;
+ }
+ else if (UpDownArrowSpr.x > (X_SCREEN_RESOLUTION - (UpDownArrowSpr.w << 1) ) )
+ {
+ UpDownArrowSpr.x = (UpDownArrowSpr.w << 1);
+ }
- GfxSortSprite(&ArrowSpr);
+ GfxSortSprite(&UpDownArrowSpr);
+ }
}
}