* 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().
This commit is contained in:
parent
b094335404
commit
7d14b50360
BIN
Bin/AIRPORT.bin
BIN
Bin/AIRPORT.bin
Binary file not shown.
|
@ -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;
|
||||
}
|
||||
else
|
||||
{
|
||||
ArrowSpr.y = AircraftSpr.y;
|
||||
UpDownArrowSpr.y = Y_SCREEN_RESOLUTION - (UpDownArrowSpr.h);
|
||||
UpDownArrowSpr.attribute |= V_FLIP;
|
||||
showUPDNArrow = true;
|
||||
}
|
||||
|
||||
GfxSortSprite(&ArrowSpr);
|
||||
if (showLRArrow != false)
|
||||
{
|
||||
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(&UpDownArrowSpr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -220,7 +220,6 @@ static GsSprite GameMouseSpr;
|
|||
static GsSprite GameBuildingSpr;
|
||||
static GsSprite CityBg1Spr;
|
||||
|
||||
|
||||
static uint16_t GameRwy[GAME_MAX_RUNWAYS];
|
||||
static TYPE_FLIGHT_DATA FlightData;
|
||||
static uint16_t GameUsedRwy[GAME_MAX_RUNWAYS];
|
||||
|
@ -303,7 +302,6 @@ bool GameFinishedFlag;
|
|||
* @remarks:
|
||||
*
|
||||
* ***************************************************************************************/
|
||||
|
||||
void Game(TYPE_GAME_CONFIGURATION* pGameCfg)
|
||||
{
|
||||
TwoPlayersActive = pGameCfg->TwoPlayers;
|
||||
|
@ -346,7 +344,6 @@ void Game(TYPE_GAME_CONFIGURATION* pGameCfg)
|
|||
* True if game has to be exitted, false otherwise.
|
||||
*
|
||||
* ***************************************************************************************/
|
||||
|
||||
bool GameExit(void)
|
||||
{
|
||||
//Serial_printf("GameFinishedFlag...\n");
|
||||
|
@ -388,7 +385,6 @@ bool GameExit(void)
|
|||
* @remarks:
|
||||
*
|
||||
* ***************************************************************************************/
|
||||
|
||||
bool GamePause(void)
|
||||
{
|
||||
TYPE_PLAYER* ptrPlayer;
|
||||
|
@ -440,7 +436,6 @@ bool GamePause(void)
|
|||
* Tilesets and buildings are only loaded on first game. Then, only PLT is loaded.
|
||||
*
|
||||
* ***************************************************************************************/
|
||||
|
||||
void GameInit(TYPE_GAME_CONFIGURATION* pGameCfg)
|
||||
{
|
||||
uint8_t i;
|
||||
|
@ -602,7 +597,6 @@ void GameInit(TYPE_GAME_CONFIGURATION* pGameCfg)
|
|||
*
|
||||
*
|
||||
* ***************************************************************************************/
|
||||
|
||||
void GameBuildingsInit(void)
|
||||
{
|
||||
enum
|
||||
|
@ -739,7 +733,6 @@ void GameBuildingsInit(void)
|
|||
* See PSX_PollPad(), defined on psx.h, and Pad module for further information.
|
||||
*
|
||||
* ***************************************************************************************/
|
||||
|
||||
void GameEmergencyMode(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
@ -841,7 +834,6 @@ void GameEmergencyMode(void)
|
|||
* @remarks:
|
||||
*
|
||||
* ***************************************************************************************/
|
||||
|
||||
void GameGetAircraftTilemap(uint8_t i)
|
||||
{
|
||||
uint16_t tileNr;
|
||||
|
@ -886,7 +878,6 @@ void GameGetAircraftTilemap(uint8_t i)
|
|||
* for all CPU-intensive tasks.
|
||||
*
|
||||
* ***************************************************************************************/
|
||||
|
||||
void GameCalculations(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
@ -938,7 +929,6 @@ void GameCalculations(void)
|
|||
* @remarks:
|
||||
*
|
||||
* ***************************************************************************************/
|
||||
|
||||
void GamePlayerHandler(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData)
|
||||
{
|
||||
ptrPlayer->SelectedTile = 0; // Reset selected tile if no states
|
||||
|
@ -955,6 +945,11 @@ void GamePlayerHandler(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
CameraMoveToIsoPos(ptrPlayer, IsoPos);
|
||||
}
|
||||
|
||||
if (System1SecondTick() != false)
|
||||
{
|
||||
GameGuiCalculateNextAircraftTime(ptrPlayer, ptrFlightData);
|
||||
}
|
||||
|
||||
GameStateUnboarding(ptrPlayer, ptrFlightData);
|
||||
GameStateLockTarget(ptrPlayer, ptrFlightData);
|
||||
GameStateSelectRunway(ptrPlayer, ptrFlightData);
|
||||
|
@ -1080,8 +1075,6 @@ void GameGraphics(void)
|
|||
GfxIncreaseGlobalLuminance(1);
|
||||
}
|
||||
|
||||
//~ GsSortCls(0,0,GfxGetGlobalLuminance() >> 1);
|
||||
|
||||
while (GsIsDrawing());
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS ; i++)
|
||||
|
@ -1114,6 +1107,8 @@ void GameGraphics(void)
|
|||
|
||||
GameGuiAircraftList(ptrPlayer, &FlightData);
|
||||
|
||||
GameGuiShowPassengersLeft(ptrPlayer);
|
||||
|
||||
GameDrawMouse(ptrPlayer);
|
||||
|
||||
GameGuiDrawUnboardingSequence(ptrPlayer);
|
||||
|
@ -1709,7 +1704,6 @@ void GameRenderTerrainPrecalculations(TYPE_PLAYER* ptrPlayer)
|
|||
TILE_SIZE,
|
||||
TILE_SIZE_H ) == false)
|
||||
{
|
||||
ptrPlayer->TileData[i].ShowTile = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -4061,18 +4055,12 @@ void GameActiveAircraftList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightD
|
|||
|
||||
if (ptrPlayer->ActiveAircraft > 1)
|
||||
{
|
||||
dprintf("currentFlightDataIdx = %d, lastFlightDataIdx = %d\n",
|
||||
currentFlightDataIdx,
|
||||
lastFlightDataIdx );
|
||||
if (currentFlightDataIdx != lastFlightDataIdx)
|
||||
{
|
||||
for (ptrPlayer->SelectedAircraft = 0; ptrPlayer->SelectedAircraft < FlightData.nAircraft; ptrPlayer->SelectedAircraft++)
|
||||
{
|
||||
if (ptrPlayer->ActiveAircraftList[ptrPlayer->SelectedAircraft] == lastFlightDataIdx)
|
||||
{
|
||||
dprintf("Recalculated ptrPlayer->SelectedAircraft from %d to %d.\n",
|
||||
currentFlightDataIdx,
|
||||
ptrPlayer->SelectedAircraft );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -367,6 +367,46 @@ bool GameGuiPauseDialog(TYPE_PLAYER* ptrPlayer)
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* ******************************************************************************************************
|
||||
*
|
||||
* @name: void GameGuiCalculateNextAircraftTime(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData)
|
||||
*
|
||||
* @author: Xavier Del Campo
|
||||
*
|
||||
* @brief:
|
||||
* Updates ptrPlayer->NextAircraftTime with next aircraft remaining time.
|
||||
*
|
||||
* ******************************************************************************************************/
|
||||
void GameGuiCalculateNextAircraftTime(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData)
|
||||
{
|
||||
uint8_t i;
|
||||
uint16_t minRemainingTime = 0;
|
||||
|
||||
for (i = 0; i < GAME_MAX_AIRCRAFT; i++)
|
||||
{
|
||||
if ( (ptrFlightData->State[i] == STATE_IDLE)
|
||||
&&
|
||||
( (ptrPlayer->FlightDirection & ptrFlightData->FlightDirection[i]) != 0)
|
||||
&&
|
||||
( (ptrFlightData->Hours[i] != 0)
|
||||
||
|
||||
(ptrFlightData->Minutes[i] != 0) ) )
|
||||
{
|
||||
uint16_t seconds = (ptrFlightData->Hours[i] * 60) + (ptrFlightData->Minutes[i]);
|
||||
|
||||
if ( (minRemainingTime == 0)
|
||||
||
|
||||
(seconds < minRemainingTime) )
|
||||
{
|
||||
minRemainingTime = seconds;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ptrPlayer->NextAircraftTime = minRemainingTime;
|
||||
}
|
||||
|
||||
/* **********************************************************************************************
|
||||
*
|
||||
* @name: void GameGuiActiveAircraftPage(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData)
|
||||
|
@ -468,6 +508,14 @@ void GameGuiAircraftList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData
|
|||
GAME_GUI_REMAINING_AIRCRAFT_Y_2PLAYER = AIRCRAFT_DATA_GSGPOLY4_Y2_2PLAYER - 16
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
GAME_GUI_NEXT_AIRCRAFT_TIME_X = GAME_GUI_REMAINING_AIRCRAFT_X,
|
||||
GAME_GUI_NEXT_AIRCRAFT_TIME_Y = GAME_GUI_REMAINING_AIRCRAFT_Y + 8,
|
||||
GAME_GUI_NEXT_AIRCRAFT_TIME_X_2PLAYER = GAME_GUI_REMAINING_AIRCRAFT_X_2PLAYER - 6,
|
||||
GAME_GUI_NEXT_AIRCRAFT_TIME_Y_2PLAYER = GAME_GUI_REMAINING_AIRCRAFT_Y_2PLAYER + 8,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
AIRCRAFT_STOP_X = 128,
|
||||
|
@ -514,6 +562,12 @@ void GameGuiAircraftList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData
|
|||
GAME_GUI_REMAINING_AIRCRAFT_Y_2PLAYER,
|
||||
"Rem. aircraft: %d",
|
||||
ptrFlightData->nRemainingAircraft );
|
||||
|
||||
FontPrintText( &SmallFont,
|
||||
GAME_GUI_NEXT_AIRCRAFT_TIME_X_2PLAYER,
|
||||
GAME_GUI_NEXT_AIRCRAFT_TIME_Y_2PLAYER,
|
||||
"Next aircraft: %d sec",
|
||||
ptrPlayer->NextAircraftTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -522,6 +576,12 @@ void GameGuiAircraftList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData
|
|||
GAME_GUI_REMAINING_AIRCRAFT_Y,
|
||||
"Remaining aircraft: %d",
|
||||
ptrFlightData->nRemainingAircraft );
|
||||
|
||||
FontPrintText( &SmallFont,
|
||||
GAME_GUI_NEXT_AIRCRAFT_TIME_X,
|
||||
GAME_GUI_NEXT_AIRCRAFT_TIME_Y,
|
||||
"Next aircraft: %d sec",
|
||||
ptrPlayer->NextAircraftTime );
|
||||
}
|
||||
|
||||
if (ptrPlayer->ActiveAircraft != 0)
|
||||
|
|
|
@ -38,5 +38,7 @@ void GameGuiAircraftList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData
|
|||
bool GameGuiFinishedDialog(TYPE_PLAYER* ptrPlayer);
|
||||
void GameGuiAircraftCollision(TYPE_PLAYER* ptrPlayer);
|
||||
void GameGuiBubbleShow(void);
|
||||
void GameGuiShowPassengersLeft(TYPE_PLAYER* ptrPlayer);
|
||||
void GameGuiCalculateNextAircraftTime(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData);
|
||||
|
||||
#endif //GAME_GUI_HEADER__
|
||||
|
|
|
@ -81,7 +81,7 @@ typedef struct t_cartpos
|
|||
|
||||
typedef struct t_tileData
|
||||
{
|
||||
bool ShowTile;
|
||||
bool ShowTile;
|
||||
TYPE_CARTESIAN_POS CartPos;
|
||||
unsigned char r;
|
||||
unsigned char g;
|
||||
|
@ -209,6 +209,8 @@ typedef struct
|
|||
TYPE_CAMERA Camera;
|
||||
// Array of tiles which will change their RGB values when displayed under certain player states.
|
||||
uint16_t RwyArray[GAME_MAX_RWY_LENGTH];
|
||||
// Remaining time for next aircraft (if any).
|
||||
uint16_t NextAircraftTime;
|
||||
|
||||
// Pad callbacks.
|
||||
bool (*PadKeyPressed_Callback)(unsigned short);
|
||||
|
|
|
@ -101,7 +101,8 @@ SPRITE_OBJECTS = $(addprefix $(OBJ_SPRITES_PATH)/, PSXDISK.TIM \
|
|||
DEPARR.TIM \
|
||||
PAGEUPDN.TIM \
|
||||
BLDNGS1.TIM \
|
||||
ARROW.TIM \
|
||||
LFRARROW.TIM \
|
||||
UDNARROW.TIM \
|
||||
BCNGW.TIM \
|
||||
CITYBG1.TIM \
|
||||
MENUSTAR.TIM )
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 822 B |
|
@ -1 +0,0 @@
|
|||
16 -org=604,240 -mpink
|
Binary file not shown.
Loading…
Reference in New Issue