diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2017-05-27 17:10:15 +0200 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2017-05-27 17:10:15 +0200 |
| commit | 5430bd30906ca270bceec5912b94d81f0f854769 (patch) | |
| tree | 527b4b9527cd057e81d86e07b5ee7e3fd806bb49 /Source | |
| parent | 656eec576e46bf80da052710508e93b26ec8bdb5 (diff) | |
| download | airport-5430bd30906ca270bceec5912b94d81f0f854769.tar.gz | |
* Added more aircraft on LEVEL1.PLT.
* Unboarding state now totally implemented.
* (Bugfix): Incorrect aircraft was selected on ShowAircraftData.
* Gfx1HzFlash() and Gfx2HzFlash() were incorrectly implemented, causing multiple ticks on a single cycle.
Diffstat (limited to 'Source')
| -rw-r--r-- | Source/Aircraft.c | 24 | ||||
| -rw-r--r-- | Source/Aircraft.h | 1 | ||||
| -rw-r--r-- | Source/Game.c | 197 | ||||
| -rw-r--r-- | Source/Game.h | 2 | ||||
| -rw-r--r-- | Source/GameGui.c | 2 | ||||
| -rw-r--r-- | Source/GameStructures.h | 3 | ||||
| -rw-r--r-- | Source/Gfx.c | 33 | ||||
| -rw-r--r-- | Source/Pad.c | 40 | ||||
| -rw-r--r-- | Source/PltParser.c | 1 | ||||
| -rw-r--r-- | Source/System.c | 15 |
10 files changed, 200 insertions, 118 deletions
diff --git a/Source/Aircraft.c b/Source/Aircraft.c index 3b3dab8..74a664e 100644 --- a/Source/Aircraft.c +++ b/Source/Aircraft.c @@ -182,14 +182,32 @@ AIRCRAFT_LIVERY AircraftLiveryFromFlightNumber(char * strFlightNumber) return AircraftLiveryTable[liveryIndex];
}
+bool AircraftRemove(uint8_t aircraftIdx)
+{
+ uint8_t i;
+
+ for(i = 0; i < GAME_MAX_AIRCRAFT; i++)
+ {
+ TYPE_AIRCRAFT_DATA* ptrAircraft = &AircraftData[i];
+
+ if(ptrAircraft->FlightDataIdx == aircraftIdx)
+ {
+ memset(ptrAircraft, 0, sizeof(TYPE_AIRCRAFT_DATA));
+ ptrAircraft->State = STATE_IDLE;
+ return true;
+ }
+ }
+
+ return false;
+}
+
void AircraftHandler(void)
{
- TYPE_AIRCRAFT_DATA* ptrAircraft;
uint8_t i;
for(i = 0; i < GAME_MAX_AIRCRAFT; i++)
{
- ptrAircraft = &AircraftData[i];
+ TYPE_AIRCRAFT_DATA* ptrAircraft = &AircraftData[i];
if(ptrAircraft->State == STATE_IDLE)
{
@@ -352,7 +370,7 @@ void AircraftDirection(TYPE_AIRCRAFT_DATA* ptrAircraft) if(ptrAircraft->Target[++ptrAircraft->TargetIdx] == 0)
{
dprintf("All targets reached!\n");
- ptrAircraft->State = GameTargetsReached(ptrAircraft->FlightDataIdx);
+ ptrAircraft->State = GameTargetsReached(ptrAircraft->Target[0], ptrAircraft->FlightDataIdx);
}
}
}
diff --git a/Source/Aircraft.h b/Source/Aircraft.h index 5f80960..76a9471 100644 --- a/Source/Aircraft.h +++ b/Source/Aircraft.h @@ -22,6 +22,7 @@ void AircraftFromFlightDataIndexAddTargets(uint8_t index, uint16_t* targets); void AircraftAddTargets(TYPE_AIRCRAFT_DATA* ptrAircraft, uint16_t* targets);
TYPE_ISOMETRIC_POS AircraftGetIsoPos(uint8_t FlightDataIdx);
uint16_t AircraftGetTileFromFlightDataIndex(uint8_t index);
+bool AircraftRemove(uint8_t aircraftIdx);
bool AircraftAddNew( TYPE_FLIGHT_DATA * ptrFlightData,
uint8_t FlightDataIndex,
uint16_t* targets );
diff --git a/Source/Game.c b/Source/Game.c index 4d30212..292cc44 100644 --- a/Source/Game.c +++ b/Source/Game.c @@ -130,7 +130,7 @@ static void GameSelectAircraftWaypoint(TYPE_PLAYER* ptrPlayer); static void GameGetRunwayArray(void); static void GameGetSelectedRunwayArray(uint16_t rwyHeader); static void GameAssignRunwaytoAircraft(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptrFlightData); -static bool GamePathToTile(TYPE_PLAYER* ptrPlayer); +static bool GamePathToTile(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData); static void GameDrawMouse(TYPE_PLAYER* ptrPlayer); static void GameStateUnboarding(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData); static void GameGenerateUnboardingSequence(TYPE_PLAYER* ptrPlayer); @@ -526,6 +526,9 @@ void GamePlayerHandler(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptrFlightData) // which use this are currently active. ptrPlayer->InvalidPath = false; // Do the same thing for "InvalidPath". + ptrPlayer->FlightDataSelectedAircraft = ptrPlayer->ActiveAircraftList[ptrPlayer->SelectedAircraft]; + + GameStateUnboarding(ptrPlayer, ptrFlightData); GameStateLockTarget(ptrPlayer, ptrFlightData); GameStateSelectRunway(ptrPlayer, ptrFlightData); GameStateSelectTaxiwayRunway(ptrPlayer, ptrFlightData); @@ -535,7 +538,6 @@ void GamePlayerHandler(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptrFlightData) GameGuiActiveAircraftList(ptrPlayer, ptrFlightData); GameGuiActiveAircraftPage(ptrPlayer, ptrFlightData); GameSelectAircraftFromList(ptrPlayer, ptrFlightData); - GameStateUnboarding(ptrPlayer, ptrFlightData); } void GameClock(void) @@ -737,44 +739,47 @@ void GameAircraftState(void) for(i = 0; i < FlightData.nAircraft ; i++) { - if( (FlightData.Hours[i] == 0) - && - (FlightData.Minutes[i] == 0) - && - (FlightData.State[i] == STATE_IDLE) - && - (FlightData.RemainingTime[i] > 0) ) + if(FlightData.Finished[i] == false) { - if(FlightData.FlightDirection[i] == DEPARTURE) + if( (FlightData.Hours[i] == 0) + && + (FlightData.Minutes[i] == 0) + && + (FlightData.State[i] == STATE_IDLE) + && + (FlightData.RemainingTime[i] > 0) ) { - FlightData.State[i] = STATE_PARKED; - - target[0] = FlightData.Parking[i]; - - dprintf("Target assigned = %d", target[0]); - - if(AircraftAddNew(&FlightData, i, target) == false) + if(FlightData.FlightDirection[i] == DEPARTURE) + { + FlightData.State[i] = STATE_PARKED; + + target[0] = FlightData.Parking[i]; + + dprintf("Target assigned = %d", target[0]); + + if(AircraftAddNew(&FlightData, i, target) == false) + { + dprintf("Exceeded maximum aircraft number!\n"); + return; + } + } + else if(FlightData.FlightDirection[i] == ARRIVAL) { - dprintf("Exceeded maximum aircraft number!\n"); - return; + FlightData.State[i] = STATE_APPROACH; } + + // Create notification request for incoming aircraft + FlightData.NotificationRequest[i] = true; } - else if(FlightData.FlightDirection[i] == ARRIVAL) + + if( (FlightData.State[i] != STATE_IDLE) + && + (FlightData.RemainingTime[i] == 0) ) { - FlightData.State[i] = STATE_APPROACH; + // Player(s) lost a flight! + FlightData.State[i] = STATE_IDLE; + GameScore = (GameScore < LOST_FLIGHT_PENALTY)? 0 : (GameScore - LOST_FLIGHT_PENALTY); } - - // Create notification request for incoming aircraft - FlightData.NotificationRequest[i] = true; - } - - if( (FlightData.State[i] != STATE_IDLE) - && - (FlightData.RemainingTime[i] == 0) ) - { - // Player(s) lost a flight! - FlightData.State[i] = STATE_IDLE; - GameScore = (GameScore < LOST_FLIGHT_PENALTY)? 0 : (GameScore - LOST_FLIGHT_PENALTY); } } } @@ -1055,7 +1060,7 @@ void GameStateShowAircraft(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptrFlightD void GameStateLockTarget(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData) { - uint8_t AircraftIdx = ptrPlayer->ActiveAircraftList[ptrPlayer->SelectedAircraft]; + uint8_t AircraftIdx = ptrPlayer->FlightDataSelectedAircraft; if(ptrPlayer->LockTarget == true) { @@ -1063,18 +1068,21 @@ void GameStateLockTarget(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData } if(ptrPlayer->PadKeySinglePress_Callback(PAD_SQUARE) == true) - { - if(ptrPlayer->LockTarget == false) + { + if(ptrPlayer->ShowAircraftData == true) { - if( (ptrFlightData->State[AircraftIdx] != STATE_IDLE) - && - (ptrFlightData->State[AircraftIdx] != STATE_APPROACH) ) + if(ptrPlayer->LockTarget == false) { - ptrPlayer->LockTarget = true; - ptrPlayer->LockedAircraft = AircraftIdx; + if( (ptrFlightData->State[AircraftIdx] != STATE_IDLE) + && + (ptrFlightData->State[AircraftIdx] != STATE_APPROACH) ) + { + ptrPlayer->LockTarget = true; + ptrPlayer->LockedAircraft = AircraftIdx; + } } } - else + else if(ptrPlayer->LockTarget == true) { ptrPlayer->LockTarget = false; ptrPlayer->LockedAircraft = 0; @@ -1108,7 +1116,7 @@ void GameStateSelectTaxiwayRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptr ptrPlayer->SelectedTile = GameGetTileFromIsoPosition(&IsoPos); - if(GamePathToTile(ptrPlayer) == false) + if(GamePathToTile(ptrPlayer, ptrFlightData) == false) { ptrPlayer->InvalidPath = true; } @@ -1147,8 +1155,8 @@ void GameStateSelectTaxiwayRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptr case TILE_RWY_START_2: // Fall through case TILE_RWY_START_2 | TILE_MIRROR_FLAG: - AircraftFromFlightDataIndexAddTargets(ptrPlayer->LockedAircraft, ptrPlayer->Waypoints); - dprintf("Added these targets to aircraft %d:\n", ptrPlayer->LockedAircraft); + AircraftFromFlightDataIndexAddTargets(ptrPlayer->FlightDataSelectedAircraft, ptrPlayer->Waypoints); + dprintf("Added these targets to aircraft %d:\n", ptrPlayer->FlightDataSelectedAircraft); for(i = 0; i < PLAYER_MAX_WAYPOINTS; i++) { @@ -1163,7 +1171,7 @@ void GameStateSelectTaxiwayRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptr ptrPlayer->WaypointIdx = 0; ptrPlayer->LastWaypointIdx = 0; - ptrFlightData->State[ptrPlayer->LockedAircraft] = STATE_TAXIING; + ptrFlightData->State[ptrPlayer->FlightDataSelectedAircraft] = STATE_TAXIING; GameScore += SCORE_REWARD_TAXIING; break; @@ -1189,7 +1197,7 @@ void GameStateSelectTaxiwayParking(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * pt ptrPlayer->SelectedTile = GameGetTileFromIsoPosition(&IsoPos); - if(GamePathToTile(ptrPlayer) == false) + if(GamePathToTile(ptrPlayer, ptrFlightData) == false) { ptrPlayer->InvalidPath = true; } @@ -1231,9 +1239,9 @@ void GameStateSelectTaxiwayParking(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * pt (target_tile == (TILE_PARKING | TILE_MIRROR_FLAG) ) ) { // TODO: Assign path to aircraft - AircraftFromFlightDataIndexAddTargets(ptrPlayer->LockedAircraft, ptrPlayer->Waypoints); + AircraftFromFlightDataIndexAddTargets(ptrPlayer->FlightDataSelectedAircraft, ptrPlayer->Waypoints); - dprintf("Added these targets to aircraft %d:\n", ptrPlayer->LockedAircraft); + dprintf("Added these targets to aircraft %d:\n", ptrPlayer->FlightDataSelectedAircraft); for(i = 0; i < PLAYER_MAX_WAYPOINTS; i++) { @@ -1248,7 +1256,7 @@ void GameStateSelectTaxiwayParking(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * pt ptrPlayer->WaypointIdx = 0; ptrPlayer->LastWaypointIdx = 0; - ptrFlightData->State[ptrPlayer->LockedAircraft] = STATE_TAXIING; + ptrFlightData->State[ptrPlayer->FlightDataSelectedAircraft] = STATE_TAXIING; GameScore += SCORE_REWARD_TAXIING; } } @@ -1294,7 +1302,7 @@ void GameStateSelectRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptrFlightD { GameAssignRunwaytoAircraft(ptrPlayer, ptrFlightData); success = true; - GameUsedRwy[i] = GameRwy[ptrPlayer->SelectedRunway]; + GameUsedRwy[i] = GameRwy[ptrPlayer->SelectedRunway]; break; } } @@ -1358,7 +1366,7 @@ void GameGetRunwayArray(void) void GameSelectAircraftFromList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptrFlightData) { - uint8_t AircraftIdx = ptrPlayer->ActiveAircraftList[ptrPlayer->SelectedAircraft]; + uint8_t AircraftIdx = ptrPlayer->FlightDataSelectedAircraft; FL_STATE aircraftState = ptrFlightData->State[AircraftIdx]; if(ptrPlayer->ShowAircraftData == true) @@ -1490,7 +1498,7 @@ void GameGetSelectedRunwayArray(uint16_t rwyHeader) void GameAssignRunwaytoAircraft(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA * ptrFlightData) { uint16_t assignedRwy = GameRwy[ptrPlayer->SelectedRunway]; - uint8_t aircraftIndex = ptrPlayer->SelectedAircraft; + uint8_t aircraftIndex = ptrPlayer->FlightDataSelectedAircraft; uint16_t rwyExit; uint32_t i; uint16_t targets[AIRCRAFT_MAX_TARGETS]; @@ -1593,14 +1601,23 @@ fix16_t GameGetYFromTile(uint16_t tile) return fix16_from_int(GameGetYFromTile_short(tile)); } -FL_STATE GameTargetsReached(uint8_t index) +FL_STATE GameTargetsReached(uint16_t firstTarget, uint8_t index) { FL_STATE retState = STATE_IDLE; + uint8_t i; switch(FlightData.State[index]) { case STATE_FINAL: FlightData.State[index] = STATE_LANDED; + + for(i = 0; i < GAME_MAX_RUNWAYS; i++) + { + if(GameUsedRwy[i] == firstTarget) + { + GameUsedRwy[i] = 0; + } + } break; case STATE_TAXIING: @@ -1668,7 +1685,7 @@ void GamePlayerAddWaypoint_Ex(TYPE_PLAYER* ptrPlayer, uint16_t tile) ptrPlayer->Waypoints[ptrPlayer->WaypointIdx++] = tile; } -bool GamePathToTile(TYPE_PLAYER* ptrPlayer) +bool GamePathToTile(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData) { // Given an input TYPE_PLAYER structure and a selected tile, // it updates current Waypoints array with all tiles between two points. @@ -1746,9 +1763,13 @@ bool GamePathToTile(TYPE_PLAYER* ptrPlayer) { for(i = 0; i < GAME_MAX_AIRCRAFT; i++) { - if(temp_tile == AircraftGetTileFromFlightDataIndex(i)) + if(ptrFlightData->State[i] != STATE_IDLE) { - return false; // Check pending! + if(temp_tile == AircraftGetTileFromFlightDataIndex(i)) + { + dprintf("i = %d, state = %d\n", i, ptrFlightData->State[i]); + return false; // Check pending! + } } } @@ -1776,9 +1797,13 @@ bool GamePathToTile(TYPE_PLAYER* ptrPlayer) { for(i = 0; i < GAME_MAX_AIRCRAFT; i++) { - if(temp_tile == AircraftGetTileFromFlightDataIndex(i)) + if(ptrFlightData->State[i] != STATE_IDLE) { - return false; // Check pending! + if(temp_tile == AircraftGetTileFromFlightDataIndex(i)) + { + dprintf("i = %d, state = %d\n", i, ptrFlightData->State[i]); + return false; // Check pending! + } } } @@ -1899,7 +1924,7 @@ bool GamePathToTile(TYPE_PLAYER* ptrPlayer) TYPE_ISOMETRIC_POS GameSelectAircraft(TYPE_PLAYER* ptrPlayer) { - uint8_t AircraftIdx = ptrPlayer->ActiveAircraftList[ptrPlayer->SelectedAircraft]; + uint8_t AircraftIdx = ptrPlayer->FlightDataSelectedAircraft; TYPE_ISOMETRIC_POS IsoPos = AircraftGetIsoPos(AircraftIdx); CameraMoveToIsoPos(ptrPlayer, IsoPos); @@ -1947,7 +1972,7 @@ uint32_t GameGetScore(void) } void GameStateUnboarding(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData) -{ +{ if(ptrPlayer->Unboarding == true) { if(ptrPlayer->PadKeySinglePress_Callback(PAD_CIRCLE) == true) @@ -1957,25 +1982,50 @@ void GameStateUnboarding(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData // if he/she decides to leave without finishing } - if(SystemContains_u16(ptrPlayer->PadLastKeySinglePressed_Callback(), ptrPlayer->UnboardingSequence, GAME_MAX_SEQUENCE_KEYS) == true) + ptrPlayer->LockTarget = true; + ptrPlayer->LockedAircraft = ptrPlayer->FlightDataSelectedAircraft; + + if(ptrPlayer->PadLastKeySinglePressed_Callback() == ptrPlayer->UnboardingSequence[ptrPlayer->UnboardingSequenceIdx]) { if(++ptrPlayer->UnboardingSequenceIdx >= UNBOARDING_KEY_SEQUENCE_MEDIUM) { - if(ptrFlightData->Passengers[ptrPlayer->ActiveAircraftList[ptrPlayer->SelectedAircraft]] > UNBOARDING_PASSENGERS_PER_SEQUENCE) + if(ptrFlightData->Passengers[ptrPlayer->FlightDataSelectedAircraft] > UNBOARDING_PASSENGERS_PER_SEQUENCE) { - ptrFlightData->Passengers[ptrPlayer->ActiveAircraftList[ptrPlayer->SelectedAircraft]] -= UNBOARDING_PASSENGERS_PER_SEQUENCE; + // Player has entered correct sequence. Unboard UNBOARDING_PASSENGERS_PER_SEQUENCE passengers. + + ptrFlightData->Passengers[ptrPlayer->FlightDataSelectedAircraft] -= UNBOARDING_PASSENGERS_PER_SEQUENCE; GameScore += SCORE_REWARD_UNLOADING; + + GameGenerateUnboardingSequence(ptrPlayer); } else { - ptrFlightData->Passengers[ptrPlayer->ActiveAircraftList[ptrPlayer->SelectedAircraft]] = 0; - ptrFlightData->State[ptrPlayer->ActiveAircraftList[ptrPlayer->SelectedAircraft]] = STATE_IDLE; + // Flight has finished. Remove aircraft and set finished flag + + ptrFlightData->Passengers[ptrPlayer->FlightDataSelectedAircraft] = 0; + ptrFlightData->State[ptrPlayer->FlightDataSelectedAircraft] = STATE_IDLE; + ptrPlayer->Unboarding = false; + ptrFlightData->Finished[ptrPlayer->FlightDataSelectedAircraft] = true; + + if(AircraftRemove(ptrPlayer->FlightDataSelectedAircraft) == false) + { + dprintf("Something went wrong when removing aircraft!\n"); + } + ptrPlayer->LockTarget = false; + ptrPlayer->LockedAircraft = 0; + GameScore += SCORE_REWARD_FINISH_FLIGHT; } ptrPlayer->UnboardingSequenceIdx = 0; } + + dprintf("ptrPlayer->UnboardingSequenceIdx = %d\n", ptrPlayer->UnboardingSequenceIdx); + } + else if(ptrPlayer->PadLastKeySinglePressed_Callback() != 0) + { + ptrPlayer->UnboardingSequenceIdx = 0; // Player has committed a mistake while entering the sequence. Repeat it! } } } @@ -1983,18 +2033,23 @@ void GameStateUnboarding(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData void GameGenerateUnboardingSequence(TYPE_PLAYER* ptrPlayer) { uint8_t i; - unsigned short keyTable[] = { PAD_CROSS, PAD_SQUARE, PAD_TRIANGLE, PAD_L1, - PAD_L2, PAD_R1, PAD_R2 }; + unsigned short keyTable[] = { PAD_CROSS, PAD_SQUARE, PAD_TRIANGLE }; - memset(ptrPlayer->UnboardingSequence, 0, GAME_MAX_SEQUENCE_KEYS * sizeof(unsigned short) ); + memset(ptrPlayer->UnboardingSequence, 0, sizeof(ptrPlayer->UnboardingSequence) ); ptrPlayer->UnboardingSequenceIdx = 0; + + dprintf("Key sequence generated: "); // Only medium level implemented. TODO: Implement other levels for(i = 0; i < UNBOARDING_KEY_SEQUENCE_MEDIUM; i++) { - uint8_t randNr = SystemRand(0, (sizeof(keyTable) / sizeof(keyTable[0]))); + uint8_t randIdx = SystemRand(0, (sizeof(keyTable) / sizeof(keyTable[0])) - 1); - ptrPlayer->UnboardingSequence[i] = randNr; + ptrPlayer->UnboardingSequence[i] = keyTable[randIdx]; + + dprintf("idx = %d, 0x%04X ", randIdx, ptrPlayer->UnboardingSequence[i]); } + + dprintf("\n"); } diff --git a/Source/Game.h b/Source/Game.h index 6273a56..3a18a47 100644 --- a/Source/Game.h +++ b/Source/Game.h @@ -46,7 +46,7 @@ fix16_t GameGetXFromTile(uint16_t tile); fix16_t GameGetYFromTile(uint16_t tile); short GameGetXFromTile_short(uint16_t tile); short GameGetYFromTile_short(uint16_t tile); -FL_STATE GameTargetsReached(uint8_t index); +FL_STATE GameTargetsReached(uint16_t firstTarget, uint8_t index); uint16_t GameGetTileFromIsoPosition(TYPE_ISOMETRIC_POS * IsoPos); FL_STATE GameGetFlightDataStateFromIdx(uint8_t FlightDataIdx); uint32_t GameGetScore(void); diff --git a/Source/GameGui.c b/Source/GameGui.c index b5fc3f4..98cc14a 100644 --- a/Source/GameGui.c +++ b/Source/GameGui.c @@ -978,7 +978,7 @@ void GameGuiDrawUnboardingSequence(TYPE_PLAYER* ptrPlayer) }
// TODO: Draw above the plane
- GfxDrawButton(64, Y_SCREEN_RESOLUTION - 32, ptrPlayer->UnboardingSequence[i]);
+ GfxDrawButton(128 + (16*i), Y_SCREEN_RESOLUTION - 32, ptrPlayer->UnboardingSequence[i]);
}
}
}
diff --git a/Source/GameStructures.h b/Source/GameStructures.h index 4a66748..9129b87 100644 --- a/Source/GameStructures.h +++ b/Source/GameStructures.h @@ -76,6 +76,7 @@ typedef struct t_flightData uint8_t ActiveAircraft;
FL_STATE State[GAME_MAX_AIRCRAFT];
bool NotificationRequest[GAME_MAX_AIRCRAFT];
+ bool Finished[GAME_MAX_AIRCRAFT];
}TYPE_FLIGHT_DATA;
typedef enum t_livery
@@ -160,6 +161,8 @@ typedef struct uint16_t SelectedRunway;
// Tile pointed to by cursor
uint16_t SelectedTile;
+ // Conversion between selected aircraft from data list and actual flight data index
+ uint8_t FlightDataSelectedAircraft;
// Waypoints added to list when player is tracing a path for an aircraft.
// For example: when determining path from runway to parking.
uint16_t Waypoints[PLAYER_MAX_WAYPOINTS];
diff --git a/Source/Gfx.c b/Source/Gfx.c index d1d753b..1b4612a 100644 --- a/Source/Gfx.c +++ b/Source/Gfx.c @@ -71,6 +71,9 @@ static volatile bool gfx_busy; //Dictates (R,G,B) brigthness to all sprites silently static uint8_t global_lum; +static bool five_hundred_ms_show; +static bool one_second_show; + void GfxSwapBuffers(void) { if(DrawEnv.h == Y_SCREEN_RESOLUTION) @@ -117,7 +120,17 @@ void GfxSetPrimitiveList(void) } void GfxDrawScene_Fast(void) -{ +{ + if(System1SecondTick() == true) + { + one_second_show = one_second_show? false:true; + } + + if(System500msTick() == true) + { + five_hundred_ms_show = five_hundred_ms_show? false:true; + } + GfxSwapBuffers(); FontCyclic(); GsDrawList(); @@ -427,26 +440,12 @@ void GfxSaveDisplayData(GsSprite *spr) bool Gfx1HzFlash(void) { - static bool show = false; - - if(System1SecondTick() == true) - { - show = show? false:true; - } - - return show; + return one_second_show; } bool Gfx2HzFlash(void) { - static bool show = false; - - if(System500msTick() == true) - { - show = show? false:true; - } - - return show; + return five_hundred_ms_show; } bool GfxTPageOffsetFromVRAMPosition(GsSprite * spr, short x, short y) diff --git a/Source/Pad.c b/Source/Pad.c index 5fd313c..00849e1 100644 --- a/Source/Pad.c +++ b/Source/Pad.c @@ -182,27 +182,13 @@ bool PadTwoKeyPressed(unsigned short key) } bool PadOneKeySinglePress(unsigned short key) -{ - bool singlePress = (bool)( !(previous_pad1 & key) && (pad1 & key) ); - - if(singlePress == true) - { - pad1_last_key_single_pressed = key; - } - - return singlePress; +{ + return (bool)( !(previous_pad1 & key) && (pad1 & key) ); } bool PadTwoKeySinglePress(unsigned short key) -{ - bool singlePress = (bool)( !(previous_pad2 & key) && (pad2 & key) ); - - if(singlePress == true) - { - pad2_last_key_single_pressed = key; - } - - return singlePress; +{ + return (bool)( !(previous_pad2 & key) && (pad2 & key) ); } bool PadOneKeyRepeat(unsigned short key, uint8_t time) @@ -284,6 +270,24 @@ bool UpdatePads(void) PadCheatHandler(PAD_ONE); PadCheatHandler(PAD_TWO); + + if(!(previous_pad1 & pad1) ) + { + pad1_last_key_single_pressed = pad1; + } + else + { + pad1_last_key_single_pressed = 0; + } + + if(!(previous_pad2 & pad2) ) + { + pad2_last_key_single_pressed = pad2; + } + else + { + pad2_last_key_single_pressed = 0; + } // Get now-old pad data previous_pad1 = pad1; diff --git a/Source/PltParser.c b/Source/PltParser.c index 0ee9fd8..8b2cabe 100644 --- a/Source/PltParser.c +++ b/Source/PltParser.c @@ -254,4 +254,5 @@ void PltParserResetBuffers(TYPE_FLIGHT_DATA * ptrFlightData) memset(ptrFlightData->State,STATE_IDLE,GAME_MAX_AIRCRAFT); memset(ptrFlightData->NotificationRequest,0,GAME_MAX_AIRCRAFT); memset(ptrFlightData->Parking,0,GAME_MAX_AIRCRAFT); + memset(ptrFlightData->Finished,0,GAME_MAX_AIRCRAFT); } diff --git a/Source/System.c b/Source/System.c index 5ecafbb..5d7f4de 100644 --- a/Source/System.c +++ b/Source/System.c @@ -20,7 +20,7 @@ * Local Prototypes * *************************************/ -static void SystemCheckTimer(bool * timer, uint64_t * last_timer, uint8_t step); +static void SystemCheckTimer(bool* timer, uint64_t* last_timer, uint8_t step); static void SystemSetStackPattern(void); static void SystemEnableVBlankInterrupt(void); static void SystemDisableVBlankInterrupt(void); @@ -238,11 +238,12 @@ bool System500msTick(void) return five_hundred_ms_timer; } -void SystemRunTimers(void) -{ - static uint64_t last_one_second_tick; +static uint64_t last_one_second_tick; static uint64_t last_100_ms_tick; static uint64_t last_500_ms_tick; + +void SystemRunTimers(void) +{ SystemCheckTimer(&one_second_timer, &last_one_second_tick, REFRESH_FREQUENCY); @@ -255,18 +256,18 @@ void SystemRunTimers(void) } -void SystemCheckTimer(bool * timer, uint64_t * last_timer, uint8_t step) +void SystemCheckTimer(bool* timer, uint64_t* last_timer, uint8_t step) { if(*timer == true) { *timer = false; - *last_timer = global_timer; } if(global_timer >= (*last_timer + step) ) { *timer = true; - } + *last_timer = global_timer; + } } bool SystemLoadFileToBuffer(char * fname, uint8_t* buffer, uint32_t szBuffer) |
