aboutsummaryrefslogtreecommitdiff
path: root/Source/Game.c
diff options
context:
space:
mode:
authorXavier ASUS <xavi92psx@gmail.com>2018-11-30 01:34:40 +0100
committerXavier ASUS <xavi92psx@gmail.com>2018-11-30 01:34:40 +0100
commit8fcf5bf1f74873f49b792d3e3f661a2e7feda673 (patch)
treed134d1c9d50aefcd00f973d34d14c519b0526c77 /Source/Game.c
parentc33fcca6d44264834baf42de65fe9d19c0f62ff4 (diff)
downloadairport-8fcf5bf1f74873f49b792d3e3f661a2e7feda673.tar.gz
Removed SIO interrupt (it caused VBlank ISR not to be triggered).
Added Gfx wait on LoadMenuEnd(). Otherwise, some levels would not start after loading all required files. Also, added GPU wait on Menu.c before entering the main loop. An invalid index inside sound table was being accessed when creating an arrival flight. This made the game crash only under real hardware. Other minor changes and fixes.
Diffstat (limited to 'Source/Game.c')
-rw-r--r--Source/Game.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/Source/Game.c b/Source/Game.c
index 54c40ce..bcc9593 100644
--- a/Source/Game.c
+++ b/Source/Game.c
@@ -1483,7 +1483,7 @@ static void GameLoadLevel(const char* path)
memset(LevelHeader,0, LEVEL_MAGIC_NUMBER_SIZE + 1);
- memcpy(LevelHeader,ptrBuffer,LEVEL_MAGIC_NUMBER_SIZE);
+ memmove(LevelHeader,ptrBuffer,LEVEL_MAGIC_NUMBER_SIZE);
LevelHeader[LEVEL_MAGIC_NUMBER_SIZE] = '\0';
@@ -1513,7 +1513,7 @@ static void GameLoadLevel(const char* path)
memset(GameLevelTitle,0,LEVEL_TITLE_SIZE);
- memcpy(GameLevelTitle,&ptrBuffer[i],LEVEL_TITLE_SIZE);
+ memmove(GameLevelTitle,&ptrBuffer[i],LEVEL_TITLE_SIZE);
Serial_printf("Game level title: %s\n",GameLevelTitle);
@@ -1565,7 +1565,6 @@ static void GameAircraftState(const uint8_t i)
&&
(FlightData.RemainingTime[i] != 0))
{
- Serial_printf("Aircraft %d should now start...\n", i);
if (spawnMinTimeFlag == false)
{
if ((FlightData.FlightDirection[i] == DEPARTURE)
@@ -1575,23 +1574,30 @@ static void GameAircraftState(const uint8_t i)
uint8_t j;
bool bParkingBusy = false;
+ DEBUG_PRINT_VAR(FlightData.nAircraft);
+
for (j = 0; j < FlightData.nAircraft; j++)
{
- if (AircraftFromFlightDataIndex(j)->State != STATE_IDLE)
- {
- const uint16_t* const targets = AircraftGetTargets(j);
+ TYPE_AIRCRAFT_DATA* ptrAircraft = AircraftFromFlightDataIndex(j);
- if (targets != NULL)
+ if (ptrAircraft != NULL)
+ {
+ if (ptrAircraft->State != STATE_IDLE)
{
- const uint16_t tile = AircraftGetTileFromFlightDataIndex(j);
+ const uint16_t* const targets = AircraftGetTargets(j);
- if (tile == FlightData.Parking[i])
- {
- bParkingBusy = true;
- }
- else if (SystemContains_u16(FlightData.Parking[i], targets, AIRCRAFT_MAX_TARGETS))
+ if (targets != NULL)
{
- bParkingBusy = true;
+ const uint16_t tile = AircraftGetTileFromFlightDataIndex(j);
+
+ if (tile == FlightData.Parking[i])
+ {
+ bParkingBusy = true;
+ }
+ else if (SystemContains_u16(FlightData.Parking[i], targets, AIRCRAFT_MAX_TARGETS))
+ {
+ bParkingBusy = true;
+ }
}
}
}
@@ -1623,7 +1629,7 @@ static void GameAircraftState(const uint8_t i)
}
else if (FlightData.FlightDirection[i] == ARRIVAL)
{
- const uint32_t idx = SystemRand(SOUND_M1_INDEX, ARRAY_SIZE(ApproachSnds));
+ const uint32_t idx = SystemRand(SOUND_M1_INDEX, MAX_RADIO_CHATTER_SOUNDS - 1);
FlightData.State[i] = STATE_APPROACH;
aircraftCreated = true;