+ Added support for SIO (Serial Input Output).
* On SystemLoadFileToBuffer(), files can be now uploaded to PSX using QPSXSerial.
This commit is contained in:
parent
98d3232ef4
commit
cb1c0345c7
|
@ -111,7 +111,7 @@ bool AircraftAddNew( TYPE_FLIGHT_DATA* ptrFlightData,
|
|||
|
||||
if(AircraftIndex >= GAME_MAX_AIRCRAFT)
|
||||
{
|
||||
dprintf("Exceeded maximum aircraft capacity!\n");
|
||||
Serial_printf("Exceeded maximum aircraft capacity!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ bool AircraftAddNew( TYPE_FLIGHT_DATA* ptrFlightData,
|
|||
|
||||
ptrAircraft->FlightDataIdx = FlightDataIndex;
|
||||
|
||||
dprintf("ptrAircraft->FlightDataIdx = %d, FlightDataIndex = %d\n", ptrAircraft->FlightDataIdx, FlightDataIndex);
|
||||
Serial_printf("ptrAircraft->FlightDataIdx = %d, FlightDataIndex = %d\n", ptrAircraft->FlightDataIdx, FlightDataIndex);
|
||||
|
||||
if(ptrFlightData->FlightDirection[FlightDataIndex] == ARRIVAL)
|
||||
{
|
||||
|
@ -149,8 +149,8 @@ bool AircraftAddNew( TYPE_FLIGHT_DATA* ptrFlightData,
|
|||
|
||||
ptrAircraft->Direction = AIRCRAFT_DIR_NORTH; // Default to north direction
|
||||
|
||||
dprintf("\nAircraft Data:\n");
|
||||
dprintf("\tTargets:");
|
||||
Serial_printf("\nAircraft Data:\n");
|
||||
Serial_printf("\tTargets:");
|
||||
|
||||
for(i = 0; i < AIRCRAFT_MAX_TARGETS; i++)
|
||||
{
|
||||
|
@ -159,12 +159,12 @@ bool AircraftAddNew( TYPE_FLIGHT_DATA* ptrFlightData,
|
|||
break;
|
||||
}
|
||||
|
||||
dprintf(" %d", ptrAircraft->Target[i]);
|
||||
Serial_printf(" %d", ptrAircraft->Target[i]);
|
||||
}
|
||||
|
||||
dprintf("\nLivery: %d\n", ptrAircraft->Livery );
|
||||
Serial_printf("\nLivery: %d\n", ptrAircraft->Livery );
|
||||
|
||||
dprintf("Aircraft position: {%d, %d, %d}\n",
|
||||
Serial_printf("Aircraft position: {%d, %d, %d}\n",
|
||||
fix16_to_int(ptrAircraft->IsoPos.x),
|
||||
fix16_to_int(ptrAircraft->IsoPos.y),
|
||||
fix16_to_int(ptrAircraft->IsoPos.z) );
|
||||
|
@ -204,7 +204,7 @@ bool AircraftRemove(uint8_t aircraftIdx)
|
|||
DEBUG_PRINT_VAR(ptrAircraft->FlightDataIdx);
|
||||
DEBUG_PRINT_VAR(aircraftIdx);
|
||||
ptrAircraft->State = STATE_IDLE;
|
||||
dprintf("Flight %d removed\n", ptrAircraft->FlightDataIdx);
|
||||
Serial_printf("Flight %d removed\n", ptrAircraft->FlightDataIdx);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ void AircraftDirection(TYPE_AIRCRAFT_DATA* ptrAircraft)
|
|||
|
||||
if(ptrAircraft->Target[++ptrAircraft->TargetIdx] == 0)
|
||||
{
|
||||
dprintf("All targets reached!\n");
|
||||
Serial_printf("All targets reached!\n");
|
||||
ptrAircraft->State = GameTargetsReached(ptrAircraft->Target[0], ptrAircraft->FlightDataIdx);
|
||||
memset(ptrAircraft->Target, 0, AIRCRAFT_MAX_TARGETS);
|
||||
}
|
||||
|
@ -500,7 +500,7 @@ void AircraftUpdateSpriteFromData(TYPE_AIRCRAFT_DATA* ptrAircraft)
|
|||
case AIRCRAFT_LIVERY_UNKNOWN:
|
||||
// Fall through
|
||||
default:
|
||||
dprintf("Unknown livery %d!\n", ptrAircraft->Livery);
|
||||
Serial_printf("Unknown livery %d!\n", ptrAircraft->Livery);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ TYPE_ISOMETRIC_POS CameraGetIsoPos(TYPE_PLAYER* ptrPlayer)
|
|||
CartPos.y = (Y_SCREEN_RESOLUTION >> 1) - ptrPlayer->Camera.Y_Offset;
|
||||
}
|
||||
|
||||
/*dprintf("CartPos = {%d, %d}\n", CartPos.x, CartPos.y);*/
|
||||
/*Serial_printf("CartPos = {%d, %d}\n", CartPos.x, CartPos.y);*/
|
||||
|
||||
IsoPos = GfxCartesianToIsometric(&CartPos);
|
||||
|
||||
|
@ -189,7 +189,7 @@ void CameraMoveToIsoPos(TYPE_PLAYER* ptrPlayer, TYPE_ISOMETRIC_POS IsoPos)
|
|||
{
|
||||
TYPE_CARTESIAN_POS CartPos = GfxIsometricToCartesian(&IsoPos);
|
||||
|
||||
/*dprintf("Isometric pos = {%d, %d, %d}, "
|
||||
/*Serial_printf("Isometric pos = {%d, %d, %d}, "
|
||||
"Cartesian pos = {%d, %d}\n",
|
||||
IsoPos.x,
|
||||
IsoPos.y,
|
||||
|
@ -208,7 +208,7 @@ void CameraMoveToIsoPos(TYPE_PLAYER* ptrPlayer, TYPE_ISOMETRIC_POS IsoPos)
|
|||
ptrPlayer->Camera.Y_Offset = (Y_SCREEN_RESOLUTION >> 1) - CartPos.y;
|
||||
}
|
||||
|
||||
/*dprintf("Moving camera to {%d, %d}\n",
|
||||
/*Serial_printf("Moving camera to {%d, %d}\n",
|
||||
ptrPlayer->Camera.X_Offset,
|
||||
ptrPlayer->Camera.Y_Offset );*/
|
||||
}
|
||||
|
|
|
@ -173,8 +173,8 @@ void EndAnimationSquares(void)
|
|||
{
|
||||
randInd = SystemRand(0,maxIndex);
|
||||
|
||||
/*dprintf("randInd = %d\t",randInd);
|
||||
dprintf("sqPos[randInd] = %d\n", sqPos[randInd]);*/
|
||||
/*Serial_printf("randInd = %d\t",randInd);
|
||||
Serial_printf("sqPos[randInd] = %d\n", sqPos[randInd]);*/
|
||||
|
||||
if(sqPos[randInd] == false)
|
||||
{
|
||||
|
|
|
@ -55,7 +55,7 @@ bool FontLoadImage(char* strPath, TYPE_FONT * ptrFont)
|
|||
|
||||
ptrFont->init_ch = FONT_DEFAULT_INIT_CHAR;
|
||||
|
||||
dprintf("Sprite CX = %d, sprite CY = %d\n",ptrFont->spr.cx, ptrFont->spr.cy);
|
||||
Serial_printf("Sprite CX = %d, sprite CY = %d\n",ptrFont->spr.cx, ptrFont->spr.cy);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -175,14 +175,14 @@ void FontPrintText(TYPE_FONT * ptrFont, short x, short y, char* str, ...)
|
|||
ptrFont->spr.g = NORMAL_LUMINANCE;
|
||||
ptrFont->spr.b = NORMAL_LUMINANCE;
|
||||
}
|
||||
/*dprintf("char_w = %d, char_h = %d, char_per_row = %d, init_ch: %c\n",
|
||||
/*Serial_printf("char_w = %d, char_h = %d, char_per_row = %d, init_ch: %c\n",
|
||||
ptrFont->char_w,
|
||||
ptrFont->char_h,
|
||||
ptrFont->char_per_row,
|
||||
ptrFont->init_ch);
|
||||
dprintf("Char: %c, spr.u = %d, spr.v = %d\n",str[i],ptrFont->spr.u, ptrFont->spr.v);
|
||||
dprintf("Sprite CX = %d, sprite CY = %d\n",ptrFont->spr.cx, ptrFont->spr.cy);*/
|
||||
//dprintf("Sprite rgb={%d,%d,%d}\n",ptrFont->spr.r, ptrFont->spr.g, ptrFont->spr.b);
|
||||
Serial_printf("Char: %c, spr.u = %d, spr.v = %d\n",str[i],ptrFont->spr.u, ptrFont->spr.v);
|
||||
Serial_printf("Sprite CX = %d, sprite CY = %d\n",ptrFont->spr.cx, ptrFont->spr.cy);*/
|
||||
//Serial_printf("Sprite rgb={%d,%d,%d}\n",ptrFont->spr.r, ptrFont->spr.g, ptrFont->spr.b);
|
||||
|
||||
GfxSortSprite(&ptrFont->spr);
|
||||
x += ptrFont->char_spacing;
|
||||
|
|
314
Source/Game.c
314
Source/Game.c
|
@ -10,7 +10,6 @@
|
|||
|
||||
#define GAME_MAX_MAP_SIZE 0x400
|
||||
#define GAME_MAX_RUNWAYS 16
|
||||
#define GAME_MAX_RWY_LENGTH 16
|
||||
#define GAME_MAX_AIRCRAFT_PER_TILE 4
|
||||
#define FLIGHT_DATA_INVALID_IDX 0xFF
|
||||
|
||||
|
@ -193,7 +192,6 @@ static GsSprite GameBuildingSpr;
|
|||
|
||||
static uint16_t GameRwy[GAME_MAX_RUNWAYS];
|
||||
static TYPE_FLIGHT_DATA FlightData;
|
||||
static uint16_t GameRwyArray[GAME_MAX_RWY_LENGTH];
|
||||
static uint16_t GameUsedRwy[GAME_MAX_RUNWAYS];
|
||||
static uint16_t GameSelectedTile;
|
||||
static bool firstLevelRender; // Used to avoid reentrance issues on GameRenderLevel()
|
||||
|
@ -304,10 +302,10 @@ bool GamePause(void)
|
|||
// Run player-specific functions for each player
|
||||
if(ptrPlayer->Active == true)
|
||||
{
|
||||
//dprintf("Released callback = 0x%08X\n", ptrPlayer->PadKeySinglePress_Callback);
|
||||
//Serial_printf("Released callback = 0x%08X\n", ptrPlayer->PadKeySinglePress_Callback);
|
||||
if(ptrPlayer->PadKeySinglePress_Callback(PAD_START) == true)
|
||||
{
|
||||
dprintf("Player %d set pause_flag to true!\n",i);
|
||||
Serial_printf("Player %d set pause_flag to true!\n",i);
|
||||
pause_flag = true;
|
||||
break;
|
||||
}
|
||||
|
@ -630,7 +628,7 @@ void GameGetAircraftTilemap(uint8_t i)
|
|||
|
||||
GameAircraftTilemap[tileNr][j] = i;
|
||||
|
||||
//dprintf("GameAircraftTileMap[%d][%d] = %d\n", tileNr, j, GameAircraftTilemap[tileNr][j]);
|
||||
//Serial_printf("GameAircraftTileMap[%d][%d] = %d\n", tileNr, j, GameAircraftTilemap[tileNr][j]);
|
||||
}
|
||||
|
||||
void GameCalculations(void)
|
||||
|
@ -659,72 +657,7 @@ void GameCalculations(void)
|
|||
{
|
||||
GamePlayerHandler(&PlayerData[i], &FlightData);
|
||||
}
|
||||
}
|
||||
|
||||
/*if(PadOneKeyReleased(PAD_CIRCLE) == true)
|
||||
{
|
||||
for(i = 0; i < FlightData.nAircraft ; i++)
|
||||
{
|
||||
dprintf("\n*****************\n");
|
||||
dprintf("\tAIRCRAFT %d\n",i);
|
||||
dprintf("*****************\n");
|
||||
|
||||
if(FlightData.FlightDirection[i] == ARRIVAL)
|
||||
{
|
||||
dprintf("Direction: %s\n","Arrival");
|
||||
}
|
||||
else if(FlightData.FlightDirection[i] == DEPARTURE)
|
||||
{
|
||||
dprintf("Direction: %s\n","Arrival");
|
||||
}
|
||||
|
||||
dprintf("Time: %d:%d\n",FlightData.Hours[i],FlightData.Minutes[i]);
|
||||
|
||||
dprintf("State: ");
|
||||
|
||||
switch(FlightData.State[i])
|
||||
{
|
||||
case STATE_APPROACH:
|
||||
dprintf("Approach");
|
||||
break;
|
||||
|
||||
case STATE_TAXIING:
|
||||
dprintf("Taxiing");
|
||||
break;
|
||||
|
||||
case STATE_FINAL:
|
||||
dprintf("Final");
|
||||
break;
|
||||
|
||||
case STATE_IDLE:
|
||||
dprintf("Idle");
|
||||
break;
|
||||
|
||||
case STATE_PARKED:
|
||||
dprintf("Parked");
|
||||
break;
|
||||
|
||||
case STATE_LANDED:
|
||||
dprintf("Landed");
|
||||
break;
|
||||
|
||||
case STATE_TAKEOFF:
|
||||
dprintf("Takeoff");
|
||||
break;
|
||||
|
||||
case STATE_UNBOARDING:
|
||||
dprintf("Unboarding");
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
dprintf("\n");
|
||||
}
|
||||
|
||||
dprintf("Active aircraft: %d\n",FlightData.ActiveAircraft);
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void GamePlayerHandler(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData)
|
||||
|
@ -943,8 +876,8 @@ void GameRenderBuildingAircraft(TYPE_PLAYER* ptrPlayer)
|
|||
|
||||
/*for(k = 0; k < GAME_MAX_AIRCRAFT_PER_TILE; k++)
|
||||
{
|
||||
dprintf("Aircraft_Y_Data[%d] = %d\n", k, Aircraft_Y_Data[k]);
|
||||
dprintf("AircraftRenderOrder[%d] = %d\n", k, AircraftRenderOrder[k]);
|
||||
Serial_printf("Aircraft_Y_Data[%d] = %d\n", k, Aircraft_Y_Data[k]);
|
||||
Serial_printf("AircraftRenderOrder[%d] = %d\n", k, AircraftRenderOrder[k]);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
@ -1067,11 +1000,11 @@ void GameLoadLevel(void)
|
|||
|
||||
LevelHeader[LEVEL_MAGIC_NUMBER_SIZE] = '\0';
|
||||
|
||||
dprintf("Level header: %s\n",LevelHeader);
|
||||
Serial_printf("Level header: %s\n",LevelHeader);
|
||||
|
||||
if(strncmp(LevelHeader,LEVEL_MAGIC_NUMBER_STRING,LEVEL_MAGIC_NUMBER_SIZE) != 0)
|
||||
{
|
||||
dprintf("Invalid level header! Read \"%s\" instead of \"ATC\"\n",LevelHeader);
|
||||
Serial_printf("Invalid level header! Read \"%s\" instead of \"ATC\"\n",LevelHeader);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1079,13 +1012,13 @@ void GameLoadLevel(void)
|
|||
|
||||
GameLevelColumns = ptrBuffer[i++];
|
||||
|
||||
dprintf("Level size: %d\n",GameLevelColumns);
|
||||
Serial_printf("Level size: %d\n",GameLevelColumns);
|
||||
|
||||
if( (GameLevelColumns < MIN_MAP_COLUMNS)
|
||||
||
|
||||
(GameLevelColumns > MAX_MAP_COLUMNS) )
|
||||
{
|
||||
dprintf("Invalid map size! Value: %d\n",GameLevelColumns);
|
||||
Serial_printf("Invalid map size! Value: %d\n",GameLevelColumns);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1095,7 +1028,7 @@ void GameLoadLevel(void)
|
|||
|
||||
memcpy(GameLevelTitle,&ptrBuffer[i],LEVEL_TITLE_SIZE);
|
||||
|
||||
dprintf("Game level title: %s\n",GameLevelTitle);
|
||||
Serial_printf("Game level title: %s\n",GameLevelTitle);
|
||||
|
||||
i += LEVEL_TITLE_SIZE;
|
||||
|
||||
|
@ -1168,20 +1101,20 @@ void GameAircraftState(uint8_t i)
|
|||
|
||||
target[0] = FlightData.Parking[i];
|
||||
|
||||
dprintf("Target assigned = %d\n", target[0]);
|
||||
Serial_printf("Target assigned = %d\n", target[0]);
|
||||
|
||||
dprintf("2\n");
|
||||
Serial_printf("2\n");
|
||||
|
||||
if(AircraftAddNew(&FlightData, i, target) == false)
|
||||
{
|
||||
dprintf("Exceeded maximum aircraft number!\n");
|
||||
Serial_printf("Exceeded maximum aircraft number!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(FlightData.FlightDirection[i] == ARRIVAL)
|
||||
{
|
||||
dprintf("Flight %d set to STATE_APPROACH.\n", i);
|
||||
Serial_printf("Flight %d set to STATE_APPROACH.\n", i);
|
||||
FlightData.State[i] = STATE_APPROACH;
|
||||
GameAircraftCreatedFlag = true;
|
||||
|
||||
|
@ -1219,15 +1152,15 @@ void GameRenderLevel(TYPE_PLAYER* ptrPlayer)
|
|||
// Prepare runway to be painted in blue if player is on runway selection mode
|
||||
if(ptrPlayer->SelectRunway == true)
|
||||
{
|
||||
GameGetSelectedRunwayArray(GameRwy[ptrPlayer->SelectedRunway], GameRwyArray, sizeof(GameRwyArray));
|
||||
/*dprintf("Runway array:\n");
|
||||
GameGetSelectedRunwayArray(GameRwy[ptrPlayer->SelectedRunway], ptrPlayer->RwyArray, sizeof(ptrPlayer->RwyArray));
|
||||
/*Serial_printf("Runway array:\n");
|
||||
|
||||
for(j = 0; j < GAME_MAX_RWY_LENGTH; j++)
|
||||
{
|
||||
dprintf("%d ",GameRwyArray[j]);
|
||||
Serial_printf("%d ",ptrPlayer->RwyArray[j]);
|
||||
}
|
||||
|
||||
dprintf("\n");*/
|
||||
Serial_printf("\n");*/
|
||||
}
|
||||
|
||||
if(firstLevelRender == true)
|
||||
|
@ -1357,13 +1290,13 @@ void GameRenderLevel(TYPE_PLAYER* ptrPlayer)
|
|||
&&
|
||||
(i != 0)
|
||||
&&
|
||||
(SystemContains_u16(i, GameRwyArray, GAME_MAX_RWY_LENGTH) == true) )
|
||||
(SystemContains_u16(i, ptrPlayer->RwyArray, GAME_MAX_RWY_LENGTH) == true) )
|
||||
{
|
||||
for(j = 0; j < GAME_MAX_RUNWAYS; j++)
|
||||
{
|
||||
if(GameUsedRwy[j] != 0)
|
||||
{
|
||||
if(SystemContains_u16(GameUsedRwy[j], GameRwyArray, GAME_MAX_RWY_LENGTH) == true)
|
||||
if(SystemContains_u16(GameUsedRwy[j], ptrPlayer->RwyArray, GAME_MAX_RWY_LENGTH) == true)
|
||||
{
|
||||
used_rwy = true;
|
||||
break;
|
||||
|
@ -1509,7 +1442,7 @@ void GameRenderLevel(TYPE_PLAYER* ptrPlayer)
|
|||
CurrentTile = aux_id;
|
||||
}
|
||||
|
||||
// dprintf("Tile %d, attribute 0x%X\n",i,ptrTileset->attribute);
|
||||
// Serial_printf("Tile %d, attribute 0x%X\n",i,ptrTileset->attribute);
|
||||
|
||||
GfxSortSprite(ptrTileset);
|
||||
|
||||
|
@ -1567,7 +1500,10 @@ void GameStateLockTarget(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData
|
|||
|
||||
if(ptrPlayer->LockTarget == true)
|
||||
{
|
||||
CameraMoveToIsoPos(ptrPlayer, AircraftGetIsoPos(ptrPlayer->LockedAircraft) );
|
||||
if(ptrPlayer->LockedAircraft != FLIGHT_DATA_INVALID_IDX)
|
||||
{
|
||||
CameraMoveToIsoPos(ptrPlayer, AircraftGetIsoPos(ptrPlayer->LockedAircraft) );
|
||||
}
|
||||
}
|
||||
|
||||
if(ptrPlayer->PadKeySinglePress_Callback(PAD_SQUARE) == true)
|
||||
|
@ -1588,7 +1524,7 @@ void GameStateLockTarget(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData
|
|||
else
|
||||
{
|
||||
ptrPlayer->LockTarget = false;
|
||||
ptrPlayer->LockedAircraft = 0;
|
||||
ptrPlayer->LockedAircraft = FLIGHT_DATA_INVALID_IDX;
|
||||
}
|
||||
}
|
||||
else if(ptrPlayer->PadDirectionKeyPressed_Callback() == true)
|
||||
|
@ -1598,7 +1534,7 @@ void GameStateLockTarget(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData
|
|||
(ptrPlayer->ShowAircraftData == false) )
|
||||
{
|
||||
ptrPlayer->LockTarget = false;
|
||||
ptrPlayer->LockedAircraft = 0;
|
||||
ptrPlayer->LockedAircraft = FLIGHT_DATA_INVALID_IDX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1609,13 +1545,13 @@ void GameStateSelectTaxiwayRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrF
|
|||
uint8_t i;
|
||||
uint16_t target_tile;
|
||||
|
||||
/*dprintf("Camera is pointing to {%d,%d}\n",IsoPos.x, IsoPos.y);*/
|
||||
/*Serial_printf("Camera is pointing to {%d,%d}\n",IsoPos.x, IsoPos.y);*/
|
||||
|
||||
if(ptrPlayer->SelectTaxiwayRunway == true)
|
||||
{
|
||||
// Under this mode, always reset locking target.
|
||||
ptrPlayer->LockTarget = false;
|
||||
ptrPlayer->LockedAircraft = 0;
|
||||
ptrPlayer->LockedAircraft = FLIGHT_DATA_INVALID_IDX;
|
||||
|
||||
ptrPlayer->SelectedTile = GameGetTileFromIsoPosition(&IsoPos);
|
||||
|
||||
|
@ -1659,14 +1595,14 @@ void GameStateSelectTaxiwayRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrF
|
|||
// Fall through
|
||||
case TILE_RWY_HOLDING_POINT_2 | TILE_MIRROR_FLAG:
|
||||
AircraftFromFlightDataIndexAddTargets(ptrPlayer->FlightDataSelectedAircraft, ptrPlayer->Waypoints);
|
||||
dprintf("Added these targets to aircraft %d:\n", ptrPlayer->FlightDataSelectedAircraft);
|
||||
Serial_printf("Added these targets to aircraft %d:\n", ptrPlayer->FlightDataSelectedAircraft);
|
||||
|
||||
for(i = 0; i < PLAYER_MAX_WAYPOINTS; i++)
|
||||
{
|
||||
dprintf("%d ",ptrPlayer->Waypoints[i]);
|
||||
Serial_printf("%d ",ptrPlayer->Waypoints[i]);
|
||||
}
|
||||
|
||||
dprintf("\n");
|
||||
Serial_printf("\n");
|
||||
|
||||
// Clear waypoints array.
|
||||
memset(ptrPlayer->Waypoints, 0, sizeof(uint16_t) * PLAYER_MAX_WAYPOINTS);
|
||||
|
@ -1674,7 +1610,7 @@ void GameStateSelectTaxiwayRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrF
|
|||
// Reset state and auxiliar variables
|
||||
ptrPlayer->WaypointIdx = 0;
|
||||
ptrPlayer->LastWaypointIdx = 0;
|
||||
ptrPlayer->LockedAircraft = 0;
|
||||
ptrPlayer->LockedAircraft = FLIGHT_DATA_INVALID_IDX;
|
||||
ptrPlayer->LockTarget = false;
|
||||
ptrPlayer->SelectTaxiwayRunway = false;
|
||||
|
||||
|
@ -1700,7 +1636,7 @@ void GameStateSelectTaxiwayParking(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptr
|
|||
{
|
||||
// Under this mode, always reset locking target.
|
||||
ptrPlayer->LockTarget = false;
|
||||
ptrPlayer->LockedAircraft = 0;
|
||||
ptrPlayer->LockedAircraft = FLIGHT_DATA_INVALID_IDX;
|
||||
|
||||
ptrPlayer->SelectedTile = GameGetTileFromIsoPosition(&IsoPos);
|
||||
|
||||
|
@ -1734,10 +1670,10 @@ void GameStateSelectTaxiwayParking(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptr
|
|||
|
||||
target_tile = GameLevelBuffer[ptrPlayer->Waypoints[ptrPlayer->LastWaypointIdx]];
|
||||
|
||||
dprintf("ptrPlayer->LastWaypointIdx = %d\n",
|
||||
Serial_printf("ptrPlayer->LastWaypointIdx = %d\n",
|
||||
ptrPlayer->LastWaypointIdx);
|
||||
|
||||
dprintf("target_tile = %d, TILE_PARKING = %d\n",
|
||||
Serial_printf("target_tile = %d, TILE_PARKING = %d\n",
|
||||
target_tile,
|
||||
TILE_PARKING);
|
||||
|
||||
|
@ -1752,14 +1688,14 @@ void GameStateSelectTaxiwayParking(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptr
|
|||
// TODO: Assign path to aircraft
|
||||
AircraftFromFlightDataIndexAddTargets(ptrPlayer->FlightDataSelectedAircraft, ptrPlayer->Waypoints);
|
||||
|
||||
dprintf("Added these targets to aircraft %d:\n", ptrPlayer->FlightDataSelectedAircraft);
|
||||
Serial_printf("Added these targets to aircraft %d:\n", ptrPlayer->FlightDataSelectedAircraft);
|
||||
|
||||
for(i = 0; i < PLAYER_MAX_WAYPOINTS; i++)
|
||||
{
|
||||
dprintf("%d ",ptrPlayer->Waypoints[i]);
|
||||
Serial_printf("%d ",ptrPlayer->Waypoints[i]);
|
||||
}
|
||||
|
||||
dprintf("\n");
|
||||
Serial_printf("\n");
|
||||
|
||||
ptrPlayer->SelectTaxiwayParking = false;
|
||||
// Clear waypoints array.
|
||||
|
@ -1787,7 +1723,7 @@ void GameStateSelectRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightDa
|
|||
{
|
||||
// Under this mode, always reset locking target.
|
||||
ptrPlayer->LockTarget = false;
|
||||
ptrPlayer->LockedAircraft = 0;
|
||||
ptrPlayer->LockedAircraft = FLIGHT_DATA_INVALID_IDX;
|
||||
|
||||
CameraMoveToIsoPos(ptrPlayer, IsoPos);
|
||||
|
||||
|
@ -1802,7 +1738,7 @@ void GameStateSelectRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightDa
|
|||
if(SystemContains_u16(GameRwy[ptrPlayer->SelectedRunway], GameUsedRwy, GAME_MAX_RUNWAYS) == false)
|
||||
{
|
||||
ptrPlayer->SelectRunway = false;
|
||||
dprintf("Player selected runway %d!\n",GameRwy[ptrPlayer->SelectedRunway]);
|
||||
Serial_printf("Player selected runway %d!\n",GameRwy[ptrPlayer->SelectedRunway]);
|
||||
|
||||
success = false;
|
||||
|
||||
|
@ -1819,7 +1755,7 @@ void GameStateSelectRunway(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightDa
|
|||
|
||||
if(success == false)
|
||||
{
|
||||
dprintf("No available runways!\n");
|
||||
Serial_printf("No available runways!\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1865,7 +1801,7 @@ void GameGetRunwayArray(void)
|
|||
}
|
||||
}
|
||||
|
||||
dprintf("GameRwy = ");
|
||||
Serial_printf("GameRwy = ");
|
||||
|
||||
for(i = 0; i < GAME_MAX_RUNWAYS; i++)
|
||||
{
|
||||
|
@ -1874,10 +1810,10 @@ void GameGetRunwayArray(void)
|
|||
break;
|
||||
}
|
||||
|
||||
dprintf("%d ", GameRwy[i]);
|
||||
Serial_printf("%d ", GameRwy[i]);
|
||||
}
|
||||
|
||||
dprintf("\n");
|
||||
Serial_printf("\n");
|
||||
}
|
||||
|
||||
void GameSelectAircraftFromList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData)
|
||||
|
@ -1945,7 +1881,7 @@ void GameSelectAircraftFromList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFli
|
|||
break;
|
||||
|
||||
default:
|
||||
dprintf("Incompatible state %d!\n",aircraftState);
|
||||
Serial_printf("Incompatible state %d!\n",aircraftState);
|
||||
// States remain unchanged
|
||||
ptrPlayer->SelectRunway = false;
|
||||
ptrPlayer->SelectTaxiwayRunway = false;
|
||||
|
@ -1955,8 +1891,8 @@ void GameSelectAircraftFromList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFli
|
|||
}
|
||||
}
|
||||
|
||||
dprintf("aircraftState = %d\n", aircraftState);
|
||||
dprintf("AircraftIdx = %d\n", AircraftIdx);
|
||||
Serial_printf("aircraftState = %d\n", aircraftState);
|
||||
Serial_printf("AircraftIdx = %d\n", AircraftIdx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1965,7 +1901,7 @@ void GameGetSelectedRunwayArray(uint16_t rwyHeader, uint16_t* rwyArray, size_t s
|
|||
{
|
||||
typedef enum t_rwydir
|
||||
{
|
||||
RWY_DIR_EAST = 0,
|
||||
RWY_DIR_EAST = 0,
|
||||
RWY_DIR_WEST,
|
||||
RWY_DIR_NORTH,
|
||||
RWY_DIR_SOUTH,
|
||||
|
@ -1977,7 +1913,7 @@ void GameGetSelectedRunwayArray(uint16_t rwyHeader, uint16_t* rwyArray, size_t s
|
|||
|
||||
if(sz != (GAME_MAX_RWY_LENGTH * sizeof(uint16_t) ))
|
||||
{
|
||||
dprintf("GameGetSelectedRunwayArray: size %d is different"
|
||||
Serial_printf("GameGetSelectedRunwayArray: size %d is different"
|
||||
" than expected (%d bytes). Returning...\n",
|
||||
sz,
|
||||
(GAME_MAX_RWY_LENGTH * sizeof(uint16_t) ) );
|
||||
|
@ -2010,7 +1946,7 @@ void GameGetSelectedRunwayArray(uint16_t rwyHeader, uint16_t* rwyArray, size_t s
|
|||
case TILE_RWY_START_2 | TILE_MIRROR_FLAG:
|
||||
dir = RWY_DIR_NORTH;
|
||||
default:
|
||||
dprintf("Unknown direction for tile %d\n",rwyHeader);
|
||||
Serial_printf("Unknown direction for tile %d\n",rwyHeader);
|
||||
return;
|
||||
break;
|
||||
}
|
||||
|
@ -2032,8 +1968,17 @@ void GameGetSelectedRunwayArray(uint16_t rwyHeader, uint16_t* rwyArray, size_t s
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG_PRINT_VAR(i);
|
||||
|
||||
rwyArray[i++] = last_tile;
|
||||
|
||||
DEBUG_PRINT_VAR(rwyArray[i -1]);
|
||||
|
||||
if(i >= GAME_MAX_RWY_LENGTH)
|
||||
{
|
||||
while(1);
|
||||
}
|
||||
|
||||
switch(dir)
|
||||
{
|
||||
|
@ -2072,25 +2017,27 @@ void GameAssignRunwaytoAircraft(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFli
|
|||
STATE_FINAL
|
||||
}FL_STATE;*/
|
||||
|
||||
dprintf("aircraftIndex = %d\n",aircraftIndex);
|
||||
Serial_printf("aircraftIndex = %d\n",aircraftIndex);
|
||||
|
||||
if(ptrFlightData->State[aircraftIndex] == STATE_APPROACH)
|
||||
{
|
||||
{
|
||||
uint16_t rwyArray[GAME_MAX_RWY_LENGTH];
|
||||
|
||||
ptrFlightData->State[aircraftIndex] = STATE_FINAL;
|
||||
GameScore += SCORE_REWARD_FINAL;
|
||||
|
||||
GameGetSelectedRunwayArray(assignedRwy, GameRwyArray, sizeof(GameRwyArray));
|
||||
GameGetSelectedRunwayArray(assignedRwy, rwyArray, sizeof(rwyArray));
|
||||
|
||||
for(i = 0; i < GAME_MAX_RWY_LENGTH; i++)
|
||||
{
|
||||
rwyTiles[i] = GameLevelBuffer[GameRwyArray[i]];
|
||||
rwyTiles[i] = GameLevelBuffer[rwyArray[i]];
|
||||
}
|
||||
|
||||
i = SystemIndexOf_U8((uint8_t)TILE_RWY_EXIT, rwyTiles, 0, GAME_MAX_RWY_LENGTH);
|
||||
|
||||
if(i == -1)
|
||||
{
|
||||
dprintf("ERROR: Could not find TILE_RWY_EXIT for runway header %d.\n", assignedRwy);
|
||||
Serial_printf("ERROR: Could not find TILE_RWY_EXIT for runway header %d.\n", assignedRwy);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2098,22 +2045,22 @@ void GameAssignRunwaytoAircraft(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFli
|
|||
|
||||
if(i == -1)
|
||||
{
|
||||
dprintf("ERROR: Could not find second TILE_RWY_EXIT for runway header %d.\n", assignedRwy);
|
||||
Serial_printf("ERROR: Could not find second TILE_RWY_EXIT for runway header %d.\n", assignedRwy);
|
||||
return;
|
||||
}
|
||||
|
||||
rwyExit = GameRwyArray[i];
|
||||
rwyExit = rwyArray[i];
|
||||
|
||||
targets[0] = assignedRwy;
|
||||
targets[1] = rwyExit;
|
||||
|
||||
dprintf("1\n");
|
||||
Serial_printf("1\n");
|
||||
|
||||
if( AircraftAddNew(ptrFlightData,
|
||||
aircraftIndex,
|
||||
targets ) == false)
|
||||
{
|
||||
dprintf("Exceeded maximum aircraft number!\n");
|
||||
Serial_printf("Exceeded maximum aircraft number!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2127,14 +2074,14 @@ void GameAssignRunwaytoAircraft(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFli
|
|||
targets[0] = rwyEntryData.rwyEntryTile;
|
||||
targets[1] = targets[0] + rwyEntryData.rwyStep;
|
||||
|
||||
dprintf("Added the following targets = ");
|
||||
Serial_printf("Added the following targets = ");
|
||||
|
||||
for(i = 0; i < (sizeof(targets) / sizeof(targets[0])); i++)
|
||||
{
|
||||
dprintf("%d ", targets[i]);
|
||||
Serial_printf("%d ", targets[i]);
|
||||
}
|
||||
|
||||
dprintf("\n");
|
||||
Serial_printf("\n");
|
||||
|
||||
AircraftAddTargets(AircraftFromFlightDataIndex(aircraftIndex), targets);
|
||||
|
||||
|
@ -2262,7 +2209,7 @@ uint16_t GameGetTileFromIsoPosition(TYPE_ISOMETRIC_POS * IsoPos)
|
|||
tile = IsoPos->x >> TILE_SIZE_BIT_SHIFT;
|
||||
tile += (IsoPos->y >> TILE_SIZE_BIT_SHIFT) * GameLevelColumns;
|
||||
|
||||
/*dprintf("Returning tile %d from position {%d, %d, %d}\n",
|
||||
/*Serial_printf("Returning tile %d from position {%d, %d, %d}\n",
|
||||
tile,
|
||||
IsoPos->x,
|
||||
IsoPos->y,
|
||||
|
@ -2288,11 +2235,11 @@ void GamePlayerAddWaypoint_Ex(TYPE_PLAYER* ptrPlayer, uint16_t tile)
|
|||
|
||||
if(ptrPlayer->WaypointIdx >= PLAYER_MAX_WAYPOINTS)
|
||||
{
|
||||
dprintf("No available waypoints for this player!\n");
|
||||
Serial_printf("No available waypoints for this player!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/*dprintf("Added tile %d to ptrPlayer->Waypoints[%d]\n",
|
||||
/*Serial_printf("Added tile %d to ptrPlayer->Waypoints[%d]\n",
|
||||
tile,
|
||||
ptrPlayer->WaypointIdx);*/
|
||||
|
||||
|
@ -2338,20 +2285,20 @@ bool GamePathToTile(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
y_diff = (uint16_t)abs( (ptrPlayer->SelectedTile / GameLevelColumns) -
|
||||
(ptrPlayer->Waypoints[ptrPlayer->LastWaypointIdx] / GameLevelColumns) );
|
||||
|
||||
/*dprintf("SelectedTile = %d, ptrPlayer->Waypoints[%d] = %d\n",
|
||||
/*Serial_printf("SelectedTile = %d, ptrPlayer->Waypoints[%d] = %d\n",
|
||||
ptrPlayer->SelectedTile,
|
||||
0,
|
||||
ptrPlayer->Waypoints[0] );
|
||||
|
||||
dprintf("X = abs(%d - %d)\n",
|
||||
Serial_printf("X = abs(%d - %d)\n",
|
||||
ptrPlayer->SelectedTile % GameLevelColumns,
|
||||
(ptrPlayer->Waypoints[0] % GameLevelColumns) );
|
||||
|
||||
dprintf("Y = abs(%d - %d)\n",
|
||||
Serial_printf("Y = abs(%d - %d)\n",
|
||||
ptrPlayer->SelectedTile / GameLevelColumns,
|
||||
(ptrPlayer->Waypoints[0] / GameLevelColumns) );
|
||||
|
||||
dprintf("Diff = {%d, %d}\n", x_diff, y_diff);*/
|
||||
Serial_printf("Diff = {%d, %d}\n", x_diff, y_diff);*/
|
||||
|
||||
// At this point, we have to update current waypoints list.
|
||||
// ptrPlayer->Waypoints[ptrPlayer->WaypointIdx - 1] points to the last inserted point,
|
||||
|
@ -2636,7 +2583,7 @@ void GameStateUnboarding(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData
|
|||
ptrPlayer->UnboardingSequenceIdx = 0;
|
||||
}
|
||||
|
||||
dprintf("ptrPlayer->UnboardingSequenceIdx = %d\n", ptrPlayer->UnboardingSequenceIdx);
|
||||
Serial_printf("ptrPlayer->UnboardingSequenceIdx = %d\n", ptrPlayer->UnboardingSequenceIdx);
|
||||
}
|
||||
else if(ptrPlayer->PadLastKeySinglePressed_Callback() != 0)
|
||||
{
|
||||
|
@ -2654,7 +2601,7 @@ void GameGenerateUnboardingSequence(TYPE_PLAYER* ptrPlayer)
|
|||
|
||||
ptrPlayer->UnboardingSequenceIdx = 0;
|
||||
|
||||
dprintf("Key sequence generated: ");
|
||||
Serial_printf("Key sequence generated: ");
|
||||
|
||||
// Only medium level implemented. TODO: Implement other levels
|
||||
for(i = 0; i < UNBOARDING_KEY_SEQUENCE_MEDIUM; i++)
|
||||
|
@ -2663,10 +2610,10 @@ void GameGenerateUnboardingSequence(TYPE_PLAYER* ptrPlayer)
|
|||
|
||||
ptrPlayer->UnboardingSequence[i] = keyTable[randIdx];
|
||||
|
||||
dprintf("idx = %d, 0x%04X ", randIdx, ptrPlayer->UnboardingSequence[i]);
|
||||
Serial_printf("idx = %d, 0x%04X ", randIdx, ptrPlayer->UnboardingSequence[i]);
|
||||
}
|
||||
|
||||
dprintf("\n");
|
||||
Serial_printf("\n");
|
||||
}
|
||||
|
||||
void GameCreateTakeoffWaypoints(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData, uint8_t aircraftIdx)
|
||||
|
@ -2683,22 +2630,22 @@ void GameCreateTakeoffWaypoints(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFli
|
|||
switch(aircraftDir)
|
||||
{
|
||||
case AIRCRAFT_DIR_EAST:
|
||||
dprintf("EAST\n");
|
||||
Serial_printf("EAST\n");
|
||||
rwyStep = 1;
|
||||
break;
|
||||
|
||||
case AIRCRAFT_DIR_WEST:
|
||||
dprintf("WEST\n");
|
||||
Serial_printf("WEST\n");
|
||||
rwyStep = -1;
|
||||
break;
|
||||
|
||||
case AIRCRAFT_DIR_NORTH:
|
||||
dprintf("NORTH\n");
|
||||
Serial_printf("NORTH\n");
|
||||
rwyStep = -GameLevelColumns;
|
||||
break;
|
||||
|
||||
case AIRCRAFT_DIR_SOUTH:
|
||||
dprintf("SOUTH\n");
|
||||
Serial_printf("SOUTH\n");
|
||||
rwyStep = GameLevelColumns;
|
||||
break;
|
||||
|
||||
|
@ -2776,7 +2723,7 @@ void GameGetRunwayEntryTile(uint8_t aircraftIdx, TYPE_RWY_ENTRY_DATA* ptrRwyEntr
|
|||
ptrRwyEntry->rwyEntryTile = 0;
|
||||
ptrRwyEntry->Direction = AIRCRAFT_DIR_NO_DIRECTION;
|
||||
ptrRwyEntry->rwyStep = 0;
|
||||
dprintf("GameCreateTakeoffWaypoints(): could not determine aircraft direction.\n");
|
||||
Serial_printf("GameCreateTakeoffWaypoints(): could not determine aircraft direction.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2801,7 +2748,7 @@ void GameGetRunwayEntryTile(uint8_t aircraftIdx, TYPE_RWY_ENTRY_DATA* ptrRwyEntr
|
|||
}
|
||||
else
|
||||
{
|
||||
dprintf("GameCreateTakeoffWaypoints(): Invalid index for tile.\n");
|
||||
Serial_printf("GameCreateTakeoffWaypoints(): Invalid index for tile.\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2842,70 +2789,75 @@ void GameRemoveFlight(uint8_t idx, bool successful)
|
|||
TYPE_PLAYER* ptrPlayer = &PlayerData[i];
|
||||
uint8_t j;
|
||||
|
||||
if(idx >= FlightData.nAircraft)
|
||||
if(ptrPlayer->Active == false)
|
||||
{
|
||||
dprintf("GameRemoveFlight: index %d exceeds max index %d!\n", idx, FlightData.nAircraft);
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!(FlightData.FlightDirection[idx] & ptrPlayer->FlightDirection))
|
||||
if(idx >= FlightData.nAircraft)
|
||||
{
|
||||
Serial_printf("GameRemoveFlight: index %d exceeds max index %d!\n", idx, FlightData.nAircraft);
|
||||
return;
|
||||
}
|
||||
|
||||
if((FlightData.FlightDirection[idx] & ptrPlayer->FlightDirection) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for(j = 0; j < ptrPlayer->ActiveAircraft; j++)
|
||||
{
|
||||
uint8_t k;
|
||||
if(ptrPlayer->ActiveAircraftList[j] == idx)
|
||||
{
|
||||
if(FlightData.State[idx] != STATE_IDLE)
|
||||
{
|
||||
uint8_t k;
|
||||
|
||||
if(FlightData.State[ptrPlayer->ActiveAircraftList[j]] != STATE_IDLE)
|
||||
{
|
||||
if(ptrPlayer->ActiveAircraftList[j] == idx)
|
||||
{
|
||||
/*if(ptrPlayer == &PlayerData[PLAYER_ONE])
|
||||
{
|
||||
dprintf("Player one\n");
|
||||
}
|
||||
else if(ptrPlayer == &PlayerData[PLAYER_TWO])
|
||||
{
|
||||
dprintf("Player two\n");
|
||||
}*/
|
||||
|
||||
memset(ptrPlayer->UnboardingSequence, 0, GAME_MAX_SEQUENCE_KEYS);
|
||||
ptrPlayer->UnboardingSequenceIdx = 0;
|
||||
|
||||
/*DEBUG_PRINT_VAR(ptrPlayer);
|
||||
DEBUG_PRINT_VAR(&PlayerData[PLAYER_ONE]);
|
||||
DEBUG_PRINT_VAR(&PlayerData[PLAYER_TWO]);*/
|
||||
|
||||
for(k = 0; k < GAME_MAX_RUNWAYS; k++)
|
||||
{
|
||||
uint16_t* targets = AircraftGetTargets(ptrPlayer->ActiveAircraftList[j]);
|
||||
uint16_t* targets = AircraftGetTargets(idx);
|
||||
uint16_t rwyArray[GAME_MAX_RWY_LENGTH] = {0};
|
||||
|
||||
if(SystemContains_u16(GameUsedRwy[k], targets, AIRCRAFT_MAX_TARGETS) == true)
|
||||
{
|
||||
GameUsedRwy[k] = 0;
|
||||
}
|
||||
|
||||
GameGetSelectedRunwayArray(GameUsedRwy[k], rwyArray, sizeof(rwyArray)); // GameRwyArray is filled with runway tiles.
|
||||
|
||||
if(SystemContains_u16( AircraftGetTileFromFlightDataIndex(idx),
|
||||
rwyArray,
|
||||
sizeof(rwyArray) / sizeof(rwyArray[0]) ) == true)
|
||||
else
|
||||
{
|
||||
GameUsedRwy[k] = 0;
|
||||
Serial_printf("1\n");
|
||||
|
||||
// GameRwyArray is filled with runway tiles.
|
||||
GameGetSelectedRunwayArray(GameUsedRwy[k], rwyArray, GAME_MAX_RWY_LENGTH * sizeof(uint16_t) );
|
||||
|
||||
Serial_printf("2\n");
|
||||
|
||||
if(SystemContains_u16( AircraftGetTileFromFlightDataIndex(idx),
|
||||
rwyArray,
|
||||
sizeof(rwyArray) / sizeof(rwyArray[0]) ) == true)
|
||||
{
|
||||
GameUsedRwy[k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(FlightData.State[ptrPlayer->ActiveAircraftList[j]] != STATE_APPROACH)
|
||||
if(FlightData.State[idx] != STATE_APPROACH)
|
||||
{
|
||||
if(AircraftRemove(idx) == false)
|
||||
{
|
||||
dprintf("Something went wrong when removing aircraft!\n");
|
||||
Serial_printf("Something went wrong when removing aircraft!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// STATE_APPROACH is the only state which is not linked to a TYPE_AIRCRAFT_DATA instance.
|
||||
}
|
||||
|
||||
ptrPlayer->LockTarget = false;
|
||||
ptrPlayer->LockedAircraft = 0;
|
||||
ptrPlayer->LockedAircraft = FLIGHT_DATA_INVALID_IDX;
|
||||
|
||||
if(successful == true)
|
||||
{
|
||||
|
@ -2918,12 +2870,12 @@ void GameRemoveFlight(uint8_t idx, bool successful)
|
|||
|
||||
if(ptrPlayer->SelectedAircraft >= j)
|
||||
{
|
||||
ptrPlayer->SelectedAircraft--; // Check pending
|
||||
ptrPlayer->SelectedAircraft--;
|
||||
}
|
||||
|
||||
FlightData.Passengers[ptrPlayer->ActiveAircraftList[j]] = 0;
|
||||
FlightData.State[ptrPlayer->ActiveAircraftList[j]] = STATE_IDLE;
|
||||
FlightData.Finished[ptrPlayer->ActiveAircraftList[j]] = true;
|
||||
FlightData.Passengers[idx] = 0;
|
||||
FlightData.State[idx] = STATE_IDLE;
|
||||
FlightData.Finished[idx] = true;
|
||||
|
||||
spawnMinTimeFlag = true;
|
||||
SystemTimerRestart(GameSpawnMinTime);
|
||||
|
|
|
@ -355,7 +355,7 @@ void GameGuiActiveAircraftPage(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlig
|
|||
{
|
||||
ptrPlayer->FlightDataPage++;
|
||||
ptrPlayer->SelectedAircraft = ptrPlayer->FlightDataPage * GAME_GUI_AIRCRAFT_DATA_MAX_PAGE;
|
||||
dprintf("Selected Aircraft = %d\n",ptrPlayer->SelectedAircraft);
|
||||
Serial_printf("Selected Aircraft = %d\n",ptrPlayer->SelectedAircraft);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ void GameGuiActiveAircraftPage(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlig
|
|||
{
|
||||
ptrPlayer->FlightDataPage--;
|
||||
ptrPlayer->SelectedAircraft = ptrPlayer->FlightDataPage * GAME_GUI_AIRCRAFT_DATA_MAX_PAGE;
|
||||
dprintf("Selected Aircraft = %d\n",ptrPlayer->SelectedAircraft);
|
||||
Serial_printf("Selected Aircraft = %d\n",ptrPlayer->SelectedAircraft);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -488,10 +488,10 @@ void GameGuiAircraftList(TYPE_PLAYER* ptrPlayer, TYPE_FLIGHT_DATA* ptrFlightData
|
|||
|
||||
y_offset = (short)(page_aircraft * AIRCRAFT_DATA_FLIGHT_GSGPOLY4_H);
|
||||
|
||||
/*dprintf("ptrPlayer->ActiveAircraft = %d\n",ptrPlayer->ActiveAircraft);
|
||||
dprintf("ptrPlayer->SelectedAircraft = %d\n",ptrPlayer->SelectedAircraft);
|
||||
dprintf("ptrPlayer->FlightDataPage = %d\n",ptrPlayer->FlightDataPage);
|
||||
dprintf("y_offset = %d\n",y_offset);*/
|
||||
/*Serial_printf("ptrPlayer->ActiveAircraft = %d\n",ptrPlayer->ActiveAircraft);
|
||||
Serial_printf("ptrPlayer->SelectedAircraft = %d\n",ptrPlayer->SelectedAircraft);
|
||||
Serial_printf("ptrPlayer->FlightDataPage = %d\n",ptrPlayer->FlightDataPage);
|
||||
Serial_printf("y_offset = %d\n",y_offset);*/
|
||||
|
||||
if(GameTwoPlayersActive() == true)
|
||||
{
|
||||
|
@ -605,7 +605,7 @@ void GameGuiBubbleShow(void)
|
|||
|
||||
if(GameGuiBubbleTimer == NULL)
|
||||
{
|
||||
dprintf("Started GameGuiBubbleTimer...\n");
|
||||
Serial_printf("Started GameGuiBubbleTimer...\n");
|
||||
GameGuiBubbleTimer = SystemCreateTimer(50, false, &GameGuiBubbleStop);
|
||||
}
|
||||
else
|
||||
|
@ -629,7 +629,7 @@ void GameGuiBubble(TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
{
|
||||
if(GameGuiBubbleVibrationTimer == NULL)
|
||||
{
|
||||
dprintf("Started GameGuiBubbleVibrationTimer...\n");
|
||||
Serial_printf("Started GameGuiBubbleVibrationTimer...\n");
|
||||
GameGuiBubbleVibrationTimer = SystemCreateTimer(20, false, &GameGuiBubbleStopVibration);
|
||||
}
|
||||
else
|
||||
|
@ -984,12 +984,12 @@ void GameGuiAircraftCollision(TYPE_PLAYER* ptrPlayer)
|
|||
|
||||
void GameGuiBubbleStop(void)
|
||||
{
|
||||
dprintf("GameGuiBubbleStop\n");
|
||||
Serial_printf("GameGuiBubbleStop\n");
|
||||
GameGuiBubbleShowFlag = false;
|
||||
}
|
||||
|
||||
void GameGuiBubbleStopVibration(void)
|
||||
{
|
||||
dprintf("GameGuiBubbleStopVibration\n");
|
||||
Serial_printf("GameGuiBubbleStopVibration\n");
|
||||
GameGuiBubbleVibrationFlag = false;
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#define GAME_MAX_AIRCRAFT 32
|
||||
#define GAME_MAX_CHARACTERS 8
|
||||
#define GAME_MAX_PARKING 32
|
||||
#define GAME_MAX_RWY_LENGTH 16
|
||||
#define CHEAT_ARRAY_SIZE 16
|
||||
#define AIRCRAFT_MAX_TARGETS 32
|
||||
#define PLAYER_MAX_WAYPOINTS AIRCRAFT_MAX_TARGETS
|
||||
|
@ -196,6 +197,7 @@ typedef struct
|
|||
bool (*PadDirectionKeyPressed_Callback)(void);
|
||||
unsigned short (*PadLastKeySinglePressed_Callback)(void);
|
||||
TYPE_CAMERA Camera;
|
||||
uint16_t RwyArray[GAME_MAX_RWY_LENGTH];
|
||||
}TYPE_PLAYER;
|
||||
|
||||
typedef enum t_fontflags
|
||||
|
|
24
Source/Gfx.c
24
Source/Gfx.c
|
@ -85,16 +85,19 @@ GsSprite PSXButtons;
|
|||
* Local Variables
|
||||
* *************************************/
|
||||
|
||||
//Drawing environment
|
||||
// Drawing environment
|
||||
static GsDrawEnv DrawEnv;
|
||||
//Display environment
|
||||
// Display environment
|
||||
static GsDispEnv DispEnv;
|
||||
//Primitive list (it contains all the graphical data for the GPU)
|
||||
// Primitive list (it contains all the graphical data for the GPU)
|
||||
static unsigned int prim_list[PRIMITIVE_LIST_SIZE];
|
||||
//Tells other modules whether data is being loaded to GPU
|
||||
// Tells other modules whether data is being loaded to GPU
|
||||
static volatile bool gfx_busy;
|
||||
//Dictates (R,G,B) brigthness to all sprites silently
|
||||
// Dictates (R,G,B) brigthness to all sprites silently
|
||||
static uint8_t global_lum;
|
||||
// When true, it draws a rectangle on top of all primitives with
|
||||
// information for development purposes.
|
||||
static bool GfxDevMenuEnableFlag;
|
||||
|
||||
static bool five_hundred_ms_show;
|
||||
static bool one_second_show;
|
||||
|
@ -106,7 +109,7 @@ void GfxSwapBuffers(void)
|
|||
|
||||
if(GsListPos() >= PRIMITIVE_LIST_SIZE)
|
||||
{
|
||||
dprintf("Linked list iterator overflow!\n");
|
||||
Serial_printf("Linked list iterator overflow!\n");
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
@ -120,7 +123,7 @@ void GfxSwapBuffers(void)
|
|||
&&
|
||||
(DispEnv.y != 0) ) )
|
||||
{
|
||||
dprintf("What the hell is happening?\n");
|
||||
Serial_printf("What the hell is happening?\n");
|
||||
DEBUG_PRINT_VAR(DispEnv.x);
|
||||
DEBUG_PRINT_VAR(DispEnv.y);
|
||||
DEBUG_PRINT_VAR(DrawEnv.x);
|
||||
|
@ -148,6 +151,11 @@ void GfxSwapBuffers(void)
|
|||
}
|
||||
}
|
||||
|
||||
void GfxDevMenuEnable(void)
|
||||
{
|
||||
GfxDevMenuEnableFlag = true;
|
||||
}
|
||||
|
||||
|
||||
void GfxInitDrawEnv(void)
|
||||
{
|
||||
|
@ -582,7 +590,7 @@ bool GfxTPageOffsetFromVRAMPosition(GsSprite * spr, short x, short y)
|
|||
|
||||
spr->v = (y % GFX_TPAGE_HEIGHT);
|
||||
|
||||
//dprintf("Sprite:\n\tTPAGE: %d\n\tU=%d\n\tV=%d\n",spr->tpage,spr->u, spr->v);
|
||||
//Serial_printf("Sprite:\n\tTPAGE: %d\n\tU=%d\n\tV=%d\n",spr->tpage,spr->u, spr->v);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -112,6 +112,8 @@ bool Gfx2HzFlash(void);
|
|||
|
||||
void GfxDrawScene_NoSwap(void);
|
||||
|
||||
void GfxDevMenuEnable(void);
|
||||
|
||||
/* *************************************
|
||||
* Global variables
|
||||
* *************************************/
|
||||
|
|
|
@ -7,17 +7,26 @@
|
|||
|
||||
#include <psx.h>
|
||||
#include <stdio.h>
|
||||
#include <psxsio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <types.h>
|
||||
#include <fixmath.h>
|
||||
#include "Serial.h"
|
||||
|
||||
/* *************************************
|
||||
* Defines
|
||||
* *************************************/
|
||||
|
||||
#ifdef SERIAL_INTERFACE
|
||||
#else // SERIAL_INTERFACE
|
||||
|
||||
#define Serial_printf dprintf
|
||||
|
||||
#endif // SERIAL_INTERFACE
|
||||
|
||||
#define REFRESH_FREQUENCY 50 //50 Hz PAL / 60 Hz NTSC
|
||||
#define DEBUG_PRINT_VAR(var) dprintf(#var " = %d\n", var);
|
||||
#define DEBUG_PRINT_VAR(var) Serial_printf(#var " = %d\n", var);
|
||||
|
||||
#ifndef bool
|
||||
typedef enum
|
||||
|
|
|
@ -243,7 +243,7 @@ void LoadMenuEnd(void)
|
|||
load_menu_running = false;
|
||||
|
||||
while(LoadMenuISRHasEnded() == false);
|
||||
dprintf("Set default VBlank handler.\n");
|
||||
Serial_printf("Set default VBlank handler.\n");
|
||||
SetVBlankHandler(&ISR_SystemDefaultVBlank);
|
||||
|
||||
GfxSetGlobalLuminance(NORMAL_LUMINANCE);
|
||||
|
@ -252,6 +252,9 @@ void LoadMenuEnd(void)
|
|||
void ISR_LoadMenuVBlank(void)
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
Serial_printf("SystemIsBusy() = %d\n", SystemIsBusy() );
|
||||
Serial_printf("GfxIsGPUBusy() = %d\n", GfxIsGPUBusy() );
|
||||
|
||||
if( (SystemIsBusy() == true) || (GfxIsGPUBusy() == true) )
|
||||
{
|
||||
|
@ -390,15 +393,12 @@ void ISR_LoadMenuVBlank(void)
|
|||
LoadMenuPlaneSpr.w = PLANE_SIZE;
|
||||
LoadMenuPlaneSpr.h = PLANE_SIZE;
|
||||
|
||||
//LoadMenuPlaneSpr.u = PLANE_U;
|
||||
//LoadMenuPlaneSpr.v = PLANE_V;
|
||||
|
||||
GsSortSprite(&LoadMenuPlaneSpr);
|
||||
|
||||
FontSetFlags(&SmallFont, FONT_BLEND_EFFECT);
|
||||
|
||||
FontPrintText( &SmallFont,
|
||||
LOADING_BAR_X - 8,
|
||||
LOADING_BAR_X,
|
||||
LOADING_BAR_Y + LOADING_BAR_HEIGHT + 8,
|
||||
strCurrentFile );
|
||||
|
||||
|
@ -443,7 +443,7 @@ void LoadMenuLoadFileList( char* fileList[], void * dest[],
|
|||
|
||||
if(szFileList != szDestList)
|
||||
{
|
||||
dprintf("File list size different from dest list size! %d vs %d\n",
|
||||
Serial_printf("File list size different from dest list size! %d vs %d\n",
|
||||
szFileList, szDestList);
|
||||
return;
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ void LoadMenuLoadFileList( char* fileList[], void * dest[],
|
|||
|
||||
LoadMenuBarRect.w = fileLoadedCount* x_increment;
|
||||
|
||||
//dprintf("Files %d / %d loaded. New plane X = %d.\n",fileLoadedCount,szFileList,LoadMenuPlaneSpr.x);
|
||||
//Serial_printf("Files %d / %d loaded. New plane X = %d.\n",fileLoadedCount,szFileList,LoadMenuPlaneSpr.x);
|
||||
|
||||
// Backup original file path
|
||||
strncpy(aux_file_name,fileList[fileLoadedCount],100);
|
||||
|
@ -474,7 +474,7 @@ void LoadMenuLoadFileList( char* fileList[], void * dest[],
|
|||
strtok(fileList[fileLoadedCount],".;");
|
||||
extension = strtok(NULL,".;");
|
||||
|
||||
dprintf("File extension: .%s\n",extension);
|
||||
Serial_printf("File extension: .%s\n",extension);
|
||||
//Restore original file path in order to load file
|
||||
strncpy(fileList[fileLoadedCount],aux_file_name,100);
|
||||
|
||||
|
@ -482,45 +482,45 @@ void LoadMenuLoadFileList( char* fileList[], void * dest[],
|
|||
{
|
||||
if(GfxSpriteFromFile(fileList[fileLoadedCount], dest[fileLoadedCount]) == false)
|
||||
{
|
||||
dprintf("Could not load image file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
Serial_printf("Could not load image file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
}
|
||||
}
|
||||
else if(strncmp(extension,"CLT",3) == 0)
|
||||
{
|
||||
if(dest[fileLoadedCount] != NULL)
|
||||
{
|
||||
dprintf("WARNING: File %s linked to non-NULL destination pointer!\n", dest[fileLoadedCount]);
|
||||
Serial_printf("WARNING: File %s linked to non-NULL destination pointer!\n", dest[fileLoadedCount]);
|
||||
}
|
||||
|
||||
if(GfxCLUTFromFile(fileList[fileLoadedCount]) == false)
|
||||
{
|
||||
dprintf("Could not load CLUT file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
Serial_printf("Could not load CLUT file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
}
|
||||
}
|
||||
else if(strncmp(extension,"VAG",3) == 0)
|
||||
{
|
||||
if(SfxUploadSound(fileList[fileLoadedCount], dest[fileLoadedCount]) == false)
|
||||
{
|
||||
dprintf("Could not load sound file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
Serial_printf("Could not load sound file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
}
|
||||
}
|
||||
else if(strncmp(extension,"FNT",3) == 0)
|
||||
{
|
||||
if(FontLoadImage(fileList[fileLoadedCount], dest[fileLoadedCount]) == false)
|
||||
{
|
||||
dprintf("Could not load font file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
Serial_printf("Could not load font file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
}
|
||||
}
|
||||
else if(strncmp(extension,"PLT",3) == 0)
|
||||
{
|
||||
if(PltParserLoadFile(fileList[fileLoadedCount], dest[fileLoadedCount]) == false)
|
||||
{
|
||||
dprintf("Could not load pilots file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
Serial_printf("Could not load pilots file \"%s\"!\n",fileList[fileLoadedCount]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dprintf("LoadMenu does not recognize following extension: %s\n",extension);
|
||||
Serial_printf("LoadMenu does not recognize following extension: %s\n",extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ DEFINE= -DFIXMATH_FAST_SIN -D_PAL_MODE_
|
|||
DEFINE += -DPSXSDK_DEBUG
|
||||
DEFINE += -DNO_CDDA
|
||||
DEFINE += -DNO_INTRO
|
||||
DEFINE += -DSERIAL_INTERFACE
|
||||
LIBS= -lfixmath
|
||||
CC_FLAGS = -Wall -Werror -c -Os -Wfatal-errors
|
||||
LINKER = psx-gcc
|
||||
|
@ -39,7 +40,7 @@ build: clean objects levels $(PROJECT).elf $(PROJECT).exe
|
|||
objects: $(addprefix $(OBJ_DIR)/,main.o System.o Menu.o Gfx.o Pad.o MainMenuBtnAni.o \
|
||||
LoadMenu.o GameGui.o Sfx.o Camera.o EndAnimation.o \
|
||||
PSXSDKIntro.o PltParser.o Game.o Font.o MemCard.o \
|
||||
Aircraft.o)
|
||||
Aircraft.o Serial.o)
|
||||
|
||||
music_objects: $(addprefix ../Music/, TRACK01.bin TRACK02.bin TRACK03.bin)
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ bool MemCardGetBlockInfo( TYPE_BLOCK_DATA * ptrBlockData,
|
|||
ptrBlockData->Slot = slot;
|
||||
ptrBlockData->Block = blockNumber;
|
||||
|
||||
dprintf("MemCardGetBlockStateFileName...\n");
|
||||
Serial_printf("MemCardGetBlockStateFileName...\n");
|
||||
|
||||
if(MemCardGetBlockStateFileName(ptrBlockData) == false)
|
||||
{
|
||||
|
@ -316,14 +316,14 @@ bool MemCardGetBlockInfo( TYPE_BLOCK_DATA * ptrBlockData,
|
|||
return true;
|
||||
}
|
||||
|
||||
dprintf("MemCardGetInitialFrameInfo...\n");
|
||||
Serial_printf("MemCardGetInitialFrameInfo...\n");
|
||||
|
||||
if(MemCardGetInitialFrameInfo(ptrBlockData) == false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dprintf("MemCardGetIconFrameInfo...\n");
|
||||
Serial_printf("MemCardGetIconFrameInfo...\n");
|
||||
|
||||
if(MemCardGetIconFrameInfo(ptrBlockData) == false)
|
||||
{
|
||||
|
@ -333,7 +333,7 @@ bool MemCardGetBlockInfo( TYPE_BLOCK_DATA * ptrBlockData,
|
|||
// We will not get any block data information, we are only interested
|
||||
// in basic info.
|
||||
|
||||
dprintf("MemCardUploadToGPU...\n");
|
||||
Serial_printf("MemCardUploadToGPU...\n");
|
||||
|
||||
if(MemCardUploadToGPU(ptrBlockData) == false)
|
||||
{
|
||||
|
@ -359,7 +359,7 @@ bool MemCardGetBlockStateFileName(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
}
|
||||
|
||||
// 00h-03h Block Allocation State
|
||||
dprintf("Block %d, slot %d, allocation state: 0x%02X.\n",
|
||||
Serial_printf("Block %d, slot %d, allocation state: 0x%02X.\n",
|
||||
ptrBlockData->Block,
|
||||
ptrBlockData->Slot,
|
||||
DataBuffer[0] );
|
||||
|
@ -408,7 +408,7 @@ bool MemCardGetBlockStateFileName(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
|
||||
memcpy(ptrBlockData->FileName, &DataBuffer[0x0A], MEMCARD_FILENAME_SIZE);
|
||||
|
||||
dprintf("File name: %s\n", ptrBlockData->FileName);
|
||||
Serial_printf("File name: %s\n", ptrBlockData->FileName);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -445,12 +445,12 @@ bool MemCardGetInitialFrameInfo(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
return false;
|
||||
}
|
||||
|
||||
dprintf("Magic number: '%c' '%c'\n",DataBuffer[0], DataBuffer[1]);
|
||||
Serial_printf("Magic number: '%c' '%c'\n",DataBuffer[0], DataBuffer[1]);
|
||||
|
||||
if(DataBuffer[0] != 'S' || DataBuffer[1] != 'C')
|
||||
{
|
||||
// Invalid magic number.
|
||||
dprintf("Invalid magic number extracted from slot %d, block %d.\n",
|
||||
Serial_printf("Invalid magic number extracted from slot %d, block %d.\n",
|
||||
ptrBlockData->Slot,
|
||||
ptrBlockData->Block);
|
||||
|
||||
|
@ -483,7 +483,7 @@ bool MemCardGetInitialFrameInfo(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
return false;
|
||||
}
|
||||
|
||||
dprintf("Number of icons: %d\n", ptrBlockData->IconNumber);
|
||||
Serial_printf("Number of icons: %d\n", ptrBlockData->IconNumber);
|
||||
|
||||
// 60h-7Fh Icon 16 Color Palette Data (each entry is 16bit CLUT)
|
||||
|
||||
|
@ -515,7 +515,7 @@ bool MemCardGetIconFrameInfo(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
|
||||
if(ptrReferenceBlock == NULL)
|
||||
{
|
||||
dprintf("No reference memory card block found yet!\n");
|
||||
Serial_printf("No reference memory card block found yet!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -539,14 +539,14 @@ bool MemCardGetIconFrameInfo(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
// Icon Frame(s) (Block 1..15, Frame 1..3) (in first block of file only)
|
||||
for(i = ICON_FRAME_1; i <= ptrBlockData->IconNumber; i++)
|
||||
{
|
||||
dprintf("\tIcon %d out of %d\n",i, ptrBlockData->IconNumber);
|
||||
Serial_printf("\tIcon %d out of %d\n",i, ptrBlockData->IconNumber);
|
||||
buffer_contents = 0;
|
||||
sector = initial_sector + i;
|
||||
memset(DataBuffer, 0, MEMCARD_SECTOR_SIZE * sizeof(uint8_t) );
|
||||
|
||||
if(MemCardReadSector(ptrBlockData, sector) == false)
|
||||
{
|
||||
dprintf("Could not read memory sector!\n");
|
||||
Serial_printf("Could not read memory sector!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -560,7 +560,7 @@ bool MemCardGetIconFrameInfo(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
if(buffer_contents == 0)
|
||||
{
|
||||
// Icon buffer is empty!
|
||||
dprintf("Invalid icon buffer for slot %d, block %d.\n",
|
||||
Serial_printf("Invalid icon buffer for slot %d, block %d.\n",
|
||||
ptrBlockData->Slot,
|
||||
ptrBlockData->Block);
|
||||
|
||||
|
@ -574,7 +574,7 @@ bool MemCardGetIconFrameInfo(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
return true;
|
||||
}
|
||||
|
||||
dprintf("Unknown error from MemCardGetIconFrameInfo()!\n");
|
||||
Serial_printf("Unknown error from MemCardGetIconFrameInfo()!\n");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -591,7 +591,7 @@ bool MemCardUploadToGPU(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
||
|
||||
(ptrBlockData->IconNumber > MEMCARD_NUMBER_OF_ICONS) )
|
||||
{
|
||||
dprintf("Invalid number of icons.\n");
|
||||
Serial_printf("Invalid number of icons.\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -608,7 +608,7 @@ bool MemCardUploadToGPU(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
gs.clut_w = MEMCARD_BLOCK_CLUT_W;
|
||||
gs.clut_h = MEMCARD_BLOCK_CLUT_H;
|
||||
|
||||
dprintf("Gs Clut = {%d,%d,%d,%d}\n",
|
||||
Serial_printf("Gs Clut = {%d,%d,%d,%d}\n",
|
||||
gs.clut_x,
|
||||
gs.clut_y,
|
||||
gs.clut_w,
|
||||
|
@ -637,7 +637,7 @@ bool MemCardUploadToGPU(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
ptrBlockData->IconTPoly.attribute = COLORMODE(COLORMODE_4BPP);
|
||||
ptrBlockData->IconTPoly.tpage = (gs.x / 64) + ((gs.y/256)*16);
|
||||
|
||||
dprintf("\tTPAGE = %d\n", ptrBlockData->IconTPoly.tpage);
|
||||
Serial_printf("\tTPAGE = %d\n", ptrBlockData->IconTPoly.tpage);
|
||||
|
||||
x_block_offset = MEMCARD_BLOCK_IMAGE_W * (ptrBlockData->Block - 1);
|
||||
x_block_offset *= MEMCARD_BLOCK_MAX_ICONS;
|
||||
|
@ -647,7 +647,7 @@ bool MemCardUploadToGPU(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
ptrBlockData->IconTPoly.u[2] = ptrBlockData->IconTPoly.u[0];
|
||||
ptrBlockData->IconTPoly.u[3] = ptrBlockData->IconTPoly.u[1];
|
||||
|
||||
dprintf("\tu = {%d, %d, %d, %d}\n",
|
||||
Serial_printf("\tu = {%d, %d, %d, %d}\n",
|
||||
ptrBlockData->IconTPoly.u[0],
|
||||
ptrBlockData->IconTPoly.u[1],
|
||||
ptrBlockData->IconTPoly.u[2],
|
||||
|
@ -658,7 +658,7 @@ bool MemCardUploadToGPU(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
ptrBlockData->IconTPoly.v[2] = (gs.y % 256) + (gs.h);
|
||||
ptrBlockData->IconTPoly.v[3] = ptrBlockData->IconTPoly.v[2];
|
||||
|
||||
dprintf("\tu = {%d, %d, %d, %d}\n",
|
||||
Serial_printf("\tu = {%d, %d, %d, %d}\n",
|
||||
ptrBlockData->IconTPoly.v[0],
|
||||
ptrBlockData->IconTPoly.v[1],
|
||||
ptrBlockData->IconTPoly.v[2],
|
||||
|
@ -671,7 +671,7 @@ bool MemCardUploadToGPU(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
ptrBlockData->IconTPoly.cx = gs.clut_x;
|
||||
ptrBlockData->IconTPoly.cy = gs.clut_y;
|
||||
|
||||
dprintf("\tclut = {%d, %d}\n",
|
||||
Serial_printf("\tclut = {%d, %d}\n",
|
||||
ptrBlockData->IconTPoly.cx,
|
||||
ptrBlockData->IconTPoly.cy);
|
||||
}
|
||||
|
@ -693,7 +693,7 @@ bool MemCardReadSector(TYPE_BLOCK_DATA * ptrBlockData, int sector)
|
|||
{
|
||||
MemCardErrors.ErrorByte = 'S';
|
||||
|
||||
dprintf("Incorrect slot %d! Block %d?\n",
|
||||
Serial_printf("Incorrect slot %d! Block %d?\n",
|
||||
ptrBlockData->Slot,
|
||||
ptrBlockData->Block);
|
||||
|
||||
|
@ -704,7 +704,7 @@ bool MemCardReadSector(TYPE_BLOCK_DATA * ptrBlockData, int sector)
|
|||
{
|
||||
MemCardErrors.ErrorByte = 'T';
|
||||
|
||||
dprintf("Invalid memory card sector %d. Only values between"
|
||||
Serial_printf("Invalid memory card sector %d. Only values between"
|
||||
" 0 and %d are allowed!\n", sector, MEMCARD_MAXIMUM_SECTOR);
|
||||
return false;
|
||||
}
|
||||
|
@ -725,7 +725,7 @@ bool MemCardReadSector(TYPE_BLOCK_DATA * ptrBlockData, int sector)
|
|||
return false;
|
||||
|
||||
case MEMCARD_INVALID_CHECKSUM:
|
||||
dprintf("Invalid checksum for memory card sector %d"
|
||||
Serial_printf("Invalid checksum for memory card sector %d"
|
||||
" from block %d, slot %d",
|
||||
sector,
|
||||
ptrBlockData->Block,
|
||||
|
@ -733,7 +733,7 @@ bool MemCardReadSector(TYPE_BLOCK_DATA * ptrBlockData, int sector)
|
|||
return false;
|
||||
|
||||
case MEMCARD_BAD_SECTOR:
|
||||
dprintf("Invalid memory card sector %d. Only values between"
|
||||
Serial_printf("Invalid memory card sector %d. Only values between"
|
||||
" 0 and 511 are allowed!\n", sector);
|
||||
return false;
|
||||
|
||||
|
@ -875,39 +875,39 @@ void MemCardDrawIcon(TYPE_BLOCK_DATA * ptrBlockData, short x, short y)
|
|||
{
|
||||
first_access = false;
|
||||
|
||||
dprintf("Icon index: %d\n",IconIndex);
|
||||
Serial_printf("Icon index: %d\n",IconIndex);
|
||||
|
||||
dprintf("\tU = {%d,%d,%d,%d}\n",
|
||||
Serial_printf("\tU = {%d,%d,%d,%d}\n",
|
||||
ptrBlockData->IconTPoly.u[0],
|
||||
ptrBlockData->IconTPoly.u[1],
|
||||
ptrBlockData->IconTPoly.u[2],
|
||||
ptrBlockData->IconTPoly.u[3]);
|
||||
|
||||
|
||||
dprintf("\tV = {%d,%d,%d,%d}\n",
|
||||
Serial_printf("\tV = {%d,%d,%d,%d}\n",
|
||||
ptrBlockData->IconTPoly.v[0],
|
||||
ptrBlockData->IconTPoly.v[1],
|
||||
ptrBlockData->IconTPoly.v[2],
|
||||
ptrBlockData->IconTPoly.v[3]);
|
||||
|
||||
dprintf("\tBlock number: %d\n",ptrBlockData->Block);
|
||||
Serial_printf("\tBlock number: %d\n",ptrBlockData->Block);
|
||||
|
||||
dprintf("\tBlock count: %d\n",ptrBlockData->BlockCount);
|
||||
Serial_printf("\tBlock count: %d\n",ptrBlockData->BlockCount);
|
||||
|
||||
dprintf("\tX = {%d,%d,%d,%d}\n",
|
||||
Serial_printf("\tX = {%d,%d,%d,%d}\n",
|
||||
ptrBlockData->IconTPoly.x[0],
|
||||
ptrBlockData->IconTPoly.x[1],
|
||||
ptrBlockData->IconTPoly.x[2],
|
||||
ptrBlockData->IconTPoly.x[3]);
|
||||
|
||||
dprintf("\tY = {%d,%d,%d,%d}\n",
|
||||
Serial_printf("\tY = {%d,%d,%d,%d}\n",
|
||||
ptrBlockData->IconTPoly.y[0],
|
||||
ptrBlockData->IconTPoly.y[1],
|
||||
ptrBlockData->IconTPoly.y[2],
|
||||
ptrBlockData->IconTPoly.y[3]);
|
||||
|
||||
dprintf("\tTPAGE = %d\n", ptrBlockData->IconTPoly.tpage);
|
||||
dprintf("\tCLUT = {%d, %d}\n",
|
||||
Serial_printf("\tTPAGE = %d\n", ptrBlockData->IconTPoly.tpage);
|
||||
Serial_printf("\tCLUT = {%d, %d}\n",
|
||||
ptrBlockData->IconTPoly.cx,
|
||||
ptrBlockData->IconTPoly.cy);
|
||||
}
|
||||
|
@ -1142,23 +1142,23 @@ bool MemCardSaveData(TYPE_BLOCK_DATA * ptrBlockData)
|
|||
if(strncmp((char*)ptrBlockData->FileName, MEMCARD_GAME_FILENAME, MEMCARD_FILENAME_SIZE) != 0)
|
||||
{
|
||||
// Only our own blocks can be overwritten. NEVER overwrite other game blocks!
|
||||
dprintf("I cannot erase blocks from other games!\n");
|
||||
Serial_printf("I cannot erase blocks from other games!\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(ptrBlockData->BlockCount != FIRST_OR_ONLY_BLOCK)
|
||||
{
|
||||
dprintf("Please select first block of block array.\n");
|
||||
Serial_printf("Please select first block of block array.\n");
|
||||
return false;
|
||||
}
|
||||
else if(ptrBlockData->Data == NULL)
|
||||
{
|
||||
dprintf("No data on current block!\n");
|
||||
Serial_printf("No data on current block!\n");
|
||||
return false;
|
||||
}
|
||||
else if(ptrBlockData->Block == DIRECTORY_BLOCK)
|
||||
{
|
||||
dprintf("Invalid block selected!\n");
|
||||
Serial_printf("Invalid block selected!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,6 +114,8 @@ static SsVag BellSnd;
|
|||
static SsVag AcceptSnd;
|
||||
static TYPE_CHEAT TestCheat;
|
||||
static TYPE_CHEAT StackCheckCheat;
|
||||
static TYPE_CHEAT DevMenuCheat;
|
||||
static TYPE_CHEAT SerialCheat;
|
||||
|
||||
static char* MainMenuFiles[] = { "cdrom:\\DATA\\SPRITES\\MAINMENU.TIM;1" ,
|
||||
"cdrom:\\DATA\\SOUNDS\\BELL.VAG;1" ,
|
||||
|
@ -171,7 +173,7 @@ void PlayMenu(void)
|
|||
|
||||
void OptionsMenu(void)
|
||||
{
|
||||
dprintf("OptionsMenu(void)!\n");
|
||||
Serial_printf("OptionsMenu(void)!\n");
|
||||
}
|
||||
|
||||
void OnePlayerMenu(void)
|
||||
|
@ -230,7 +232,8 @@ void MainMenuInit(void)
|
|||
{ PAD_CIRCLE, PAD_CIRCLE, PAD_CROSS, PAD_TRIANGLE,
|
||||
PAD_TRIANGLE, PAD_TRIANGLE, 0 , 0 ,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0 } , sizeof(unsigned short) * CHEAT_ARRAY_SIZE);
|
||||
0, 0, 0, 0 } ,
|
||||
sizeof(unsigned short) * CHEAT_ARRAY_SIZE);
|
||||
|
||||
PadAddCheat(&TestCheat);
|
||||
|
||||
|
@ -242,10 +245,37 @@ void MainMenuInit(void)
|
|||
{ PAD_TRIANGLE, PAD_TRIANGLE, PAD_CROSS, PAD_TRIANGLE,
|
||||
PAD_L1, PAD_R1, 0 , 0 ,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0 } , sizeof(unsigned short) * CHEAT_ARRAY_SIZE);
|
||||
0, 0, 0, 0 } ,
|
||||
sizeof(unsigned short) * CHEAT_ARRAY_SIZE);
|
||||
|
||||
PadAddCheat(&StackCheckCheat);
|
||||
|
||||
DevMenuCheat.Callback = &GfxDevMenuEnable;
|
||||
memset(DevMenuCheat.Combination, 0 , CHEAT_ARRAY_SIZE);
|
||||
|
||||
memcpy( DevMenuCheat.Combination,
|
||||
(unsigned short[CHEAT_ARRAY_SIZE])
|
||||
{ PAD_SQUARE, PAD_SQUARE, PAD_CROSS, PAD_CROSS,
|
||||
PAD_CIRCLE, PAD_CIRCLE, PAD_TRIANGLE , PAD_TRIANGLE ,
|
||||
PAD_L1, PAD_L1, PAD_R1, PAD_R1,
|
||||
PAD_L2, PAD_L2, PAD_R2, PAD_R2 } ,
|
||||
sizeof(unsigned short) * CHEAT_ARRAY_SIZE);
|
||||
|
||||
PadAddCheat(&DevMenuCheat);
|
||||
|
||||
SerialCheat.Callback = (void*)0x801A0000;
|
||||
memset(SerialCheat.Combination, 0 , CHEAT_ARRAY_SIZE);
|
||||
|
||||
memcpy( SerialCheat.Combination,
|
||||
(unsigned short[CHEAT_ARRAY_SIZE])
|
||||
{ PAD_SQUARE, PAD_SQUARE, PAD_SQUARE, PAD_SQUARE,
|
||||
PAD_CIRCLE, PAD_CIRCLE, PAD_CIRCLE , PAD_CIRCLE ,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0 } ,
|
||||
sizeof(unsigned short) * CHEAT_ARRAY_SIZE);
|
||||
|
||||
PadAddCheat(&SerialCheat);
|
||||
|
||||
LoadMenuEnd();
|
||||
}
|
||||
|
||||
|
@ -508,7 +538,7 @@ void MenuTestCheat(void)
|
|||
{
|
||||
if(MemCardShowMap() == false)
|
||||
{
|
||||
dprintf("MemCardShowMap() failed!\n");
|
||||
Serial_printf("MemCardShowMap() failed!\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "EndAnimation.h"
|
||||
#include "PSXSDKIntro.h"
|
||||
#include "MemCard.h"
|
||||
#include "Serial.h"
|
||||
|
||||
/* *************************************
|
||||
* Defines
|
||||
|
|
|
@ -426,7 +426,7 @@ void PadCheatHandler(uint8_t n_pad)
|
|||
break;
|
||||
|
||||
default:
|
||||
dprintf("Invalid pad called for PadCheatHandler()!\n");
|
||||
Serial_printf("Invalid pad called for PadCheatHandler()!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -495,7 +495,7 @@ bool PadAddCheat(TYPE_CHEAT * cheat)
|
|||
|
||||
if(idx >= PAD_MAX_CHEATS)
|
||||
{
|
||||
dprintf("Maximum number of cheats exceeded!\n");
|
||||
Serial_printf("Maximum number of cheats exceeded!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ bool PltParserLoadFile(char* strPath, TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
|
||||
if(SystemLoadFile(strPath) == false)
|
||||
{
|
||||
dprintf("Error loading file %s!\n",strPath);
|
||||
Serial_printf("Error loading file %s!\n",strPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ bool PltParserLoadFile(char* strPath, TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
}
|
||||
|
||||
GameSetTime((uint8_t)atoi(strHour),(uint8_t)atoi(strMinutes) );
|
||||
dprintf("Game time set to %.2d:%.2d.\n",(uint8_t)atoi(strHour),(uint8_t)atoi(strMinutes) );
|
||||
Serial_printf("Game time set to %.2d:%.2d.\n",(uint8_t)atoi(strHour),(uint8_t)atoi(strMinutes) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ bool PltParserLoadFile(char* strPath, TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
|
||||
i = 0;
|
||||
|
||||
dprintf("New line read: %s\n",buffer);
|
||||
Serial_printf("New line read: %s\n",buffer);
|
||||
|
||||
while(lineBufferPtr != NULL)
|
||||
{
|
||||
|
@ -151,28 +151,28 @@ bool PltParserLoadFile(char* strPath, TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
if(strncmp(lineBufferPtr,"DEPARTURE",strlen("DEPARTURE") ) == 0)
|
||||
{
|
||||
ptrFlightData->FlightDirection[aircraftIndex] = DEPARTURE;
|
||||
dprintf("Aircraft %d set to DEPARTURE.\n",aircraftIndex);
|
||||
Serial_printf("Aircraft %d set to DEPARTURE.\n",aircraftIndex);
|
||||
}
|
||||
else if(strncmp(lineBufferPtr,"ARRIVAL",strlen("ARRIVAL") ) == 0)
|
||||
{
|
||||
ptrFlightData->FlightDirection[aircraftIndex] = ARRIVAL;
|
||||
dprintf("Aircraft %d set to ARRIVAL.\n",aircraftIndex);
|
||||
Serial_printf("Aircraft %d set to ARRIVAL.\n",aircraftIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
dprintf("Flight direction is not correct!\n");
|
||||
Serial_printf("Flight direction is not correct!\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case FLIGHT_NUMBER_INDEX:
|
||||
strncpy(ptrFlightData->strFlightNumber[aircraftIndex],lineBufferPtr,GAME_MAX_CHARACTERS);
|
||||
ptrFlightData->strFlightNumber[aircraftIndex][GAME_MAX_CHARACTERS - 1] = '\0';
|
||||
dprintf("Aircraft %d flight number set to %s.\n",aircraftIndex,ptrFlightData->strFlightNumber[aircraftIndex]);
|
||||
Serial_printf("Aircraft %d flight number set to %s.\n",aircraftIndex,ptrFlightData->strFlightNumber[aircraftIndex]);
|
||||
break;
|
||||
|
||||
case PASSENGERS_INDEX:
|
||||
ptrFlightData->Passengers[aircraftIndex] = atoi(lineBufferPtr);
|
||||
dprintf("Aircraft %d passengers set to %d.\n",aircraftIndex,ptrFlightData->Passengers[aircraftIndex]);
|
||||
Serial_printf("Aircraft %d passengers set to %d.\n",aircraftIndex,ptrFlightData->Passengers[aircraftIndex]);
|
||||
break;
|
||||
|
||||
case PARKING_INDEX:
|
||||
|
@ -184,13 +184,13 @@ bool PltParserLoadFile(char* strPath, TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
{
|
||||
ptrFlightData->Parking[aircraftIndex] = 0;
|
||||
}
|
||||
dprintf("Aircraft %d parking set to %d.\n",aircraftIndex,ptrFlightData->Parking[aircraftIndex]);
|
||||
Serial_printf("Aircraft %d parking set to %d.\n",aircraftIndex,ptrFlightData->Parking[aircraftIndex]);
|
||||
break;
|
||||
|
||||
case HOURS_MINUTES_INDEX:
|
||||
if( strlen(lineBufferPtr) != strlen("HH:MM") )
|
||||
{
|
||||
dprintf("Hour minute format is not correct!\n");
|
||||
Serial_printf("Hour minute format is not correct!\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -204,14 +204,14 @@ bool PltParserLoadFile(char* strPath, TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
ptrFlightData->Hours[aircraftIndex] = (uint8_t)atoi(strHour);
|
||||
ptrFlightData->Minutes[aircraftIndex] = (uint8_t)atoi(strMinutes);
|
||||
|
||||
dprintf("Aircraft %d time set to %.2d:%.2d.\n", aircraftIndex,
|
||||
Serial_printf("Aircraft %d time set to %.2d:%.2d.\n", aircraftIndex,
|
||||
ptrFlightData->Hours[aircraftIndex],
|
||||
ptrFlightData->Minutes[aircraftIndex] );
|
||||
break;
|
||||
|
||||
case REMAINING_TIME_INDEX:
|
||||
ptrFlightData->RemainingTime[aircraftIndex] = (uint8_t)atoi(lineBufferPtr);
|
||||
dprintf("ptrFlightData->RemainingTime[%d] = %d\n", aircraftIndex, ptrFlightData->RemainingTime[aircraftIndex]);
|
||||
Serial_printf("ptrFlightData->RemainingTime[%d] = %d\n", aircraftIndex, ptrFlightData->RemainingTime[aircraftIndex]);
|
||||
break;
|
||||
|
||||
|
||||
|
@ -233,7 +233,7 @@ bool PltParserLoadFile(char* strPath, TYPE_FLIGHT_DATA* ptrFlightData)
|
|||
ptrFlightData->nAircraft = aircraftIndex; //Set total number of aircraft used
|
||||
ptrFlightData->ActiveAircraft = 0;
|
||||
|
||||
dprintf("Number of aircraft parsed: %d\n",ptrFlightData->nAircraft);
|
||||
Serial_printf("Number of aircraft parsed: %d\n",ptrFlightData->nAircraft);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -321,7 +321,7 @@ uint8_t* PltParserGenerateFile(TYPE_PLT_CONFIG* ptrPltConfig)
|
|||
break;
|
||||
|
||||
default:
|
||||
dprintf("PltParserGenerateFile(): Undefined level!\n");
|
||||
Serial_printf("PltParserGenerateFile(): Undefined level!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -341,7 +341,7 @@ uint8_t* PltParserGenerateFile(TYPE_PLT_CONFIG* ptrPltConfig)
|
|||
PltBuffer[i] = auxBuffer[i];
|
||||
}
|
||||
|
||||
dprintf("%s\n", PltBuffer);
|
||||
Serial_printf("%s\n", PltBuffer);
|
||||
DEBUG_PRINT_VAR(ptrPltConfig->Level);
|
||||
DEBUG_PRINT_VAR(nAircraft);
|
||||
DEBUG_PRINT_VAR(minAircraftTime);
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/* *************************************
|
||||
* Includes
|
||||
* *************************************/
|
||||
|
||||
#include "Serial.h"
|
||||
|
||||
/* *************************************
|
||||
* Defines
|
||||
* *************************************/
|
||||
|
||||
#define SERIAL_BAUDRATE 115200
|
||||
#define SERIAL_TX_RX_TIMEOUT 20000
|
||||
#define SERIAL_RX_FIFO_EMPTY 0
|
||||
#define SERIAL_TX_NOT_READY 0
|
||||
#define SERIAL_PRINTF_INTERNAL_BUFFER_SIZE 256
|
||||
|
||||
/* **************************************
|
||||
* Structs and enums *
|
||||
* *************************************/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SERIAL_STATE_INIT = 0,
|
||||
SERIAL_STATE_STANDBY,
|
||||
SERIAL_STATE_WRITING_INITIAL
|
||||
}SERIAL_STATE;
|
||||
|
||||
/* *************************************
|
||||
* Local Variables
|
||||
* *************************************/
|
||||
|
||||
static volatile SERIAL_STATE SerialState;
|
||||
|
||||
/* *************************************
|
||||
* Local Prototypes
|
||||
* *************************************/
|
||||
|
||||
void SerialInit(void)
|
||||
{
|
||||
SIOStart(115200);
|
||||
}
|
||||
|
||||
bool SerialRead(uint8_t* ptrArray, size_t nBytes)
|
||||
{
|
||||
if(nBytes == 0)
|
||||
{
|
||||
dprintf("SerialRead: invalid size %d\n", nBytes);
|
||||
return false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
//uint16_t timeout = SERIAL_TX_RX_TIMEOUT;
|
||||
|
||||
while( (SIOCheckInBuffer() == SERIAL_RX_FIFO_EMPTY)); // Wait for RX FIFO not empty
|
||||
|
||||
*(ptrArray++) = SIOReadByte();
|
||||
}while(--nBytes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SerialWrite(void* ptrArray, size_t nBytes)
|
||||
{
|
||||
|
||||
if(nBytes == 0)
|
||||
{
|
||||
dprintf("SerialWrite: invalid size %d\n", nBytes);
|
||||
return false;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
//uint16_t timeout = SERIAL_TX_RX_TIMEOUT;
|
||||
|
||||
while( (SIOCheckOutBuffer() == SERIAL_TX_NOT_READY)); // Wait for TX FIFO empty.
|
||||
|
||||
SIOSendByte(*(uint8_t*)ptrArray++);
|
||||
|
||||
}while(--nBytes);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef SERIAL_INTERFACE
|
||||
void Serial_printf(const char* str, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int result;
|
||||
static char internal_buffer[SERIAL_PRINTF_INTERNAL_BUFFER_SIZE];
|
||||
|
||||
va_start(ap, str);
|
||||
|
||||
result = vsnprintf( internal_buffer,
|
||||
SERIAL_PRINTF_INTERNAL_BUFFER_SIZE,
|
||||
str,
|
||||
ap );
|
||||
|
||||
SerialWrite(internal_buffer, result);
|
||||
}
|
||||
#endif // SERIAL_INTERFACE
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef __SERIAL_HEADER__
|
||||
#define __SERIAL_HEADER__
|
||||
|
||||
/* *************************************
|
||||
* Includes
|
||||
* *************************************/
|
||||
|
||||
#include "Global_Inc.h"
|
||||
#include "System.h"
|
||||
#include "Gfx.h"
|
||||
#include "Font.h"
|
||||
|
||||
/* *************************************
|
||||
* Defines
|
||||
* *************************************/
|
||||
|
||||
#define SERIAL_DATA_PACKET_SIZE 8
|
||||
#define ACK_BYTE_STRING "b"
|
||||
|
||||
/* *************************************
|
||||
* Global prototypes
|
||||
* *************************************/
|
||||
|
||||
void SerialInit(void);
|
||||
bool SerialRead(uint8_t* ptrArray, size_t nBytes);
|
||||
bool SerialWrite(void* ptrArray, size_t nBytes);
|
||||
|
||||
#ifdef SERIAL_INTERFACE
|
||||
void Serial_printf(const char* str, ...);
|
||||
#endif // SERIAL_INTERFACE
|
||||
|
||||
#endif // __SERIAL_HEADER__
|
|
@ -51,7 +51,7 @@ bool SfxUploadSound(char* file_path, SsVag * vag)
|
|||
}
|
||||
else
|
||||
{
|
||||
dprintf("Maximum number of SPU voices exceeded!\n");
|
||||
Serial_printf("Maximum number of SPU voices exceeded!\n");
|
||||
return false; //Maximum voices exceeded
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ void SfxPlayTrack(MUSIC_TRACKS track)
|
|||
SsCdVol(0x7FFF - SfxCddaVolumeReduction,0x7FFF - SfxCddaVolumeReduction);
|
||||
SsEnableCd();
|
||||
CdPlayTrack(track);
|
||||
dprintf("Track number %d playing...\n",track);
|
||||
Serial_printf("Track number %d playing...\n",track);
|
||||
#endif // NO_CDDA
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@
|
|||
|
||||
static void SystemCheckTimer(bool* timer, uint64_t* last_timer, uint8_t step);
|
||||
static void SystemSetStackPattern(void);
|
||||
static void SystemEnableVBlankInterrupt(void);
|
||||
static void SystemDisableVBlankInterrupt(void);
|
||||
|
||||
/* *************************************
|
||||
* Local Variables
|
||||
|
@ -129,7 +127,7 @@ void SystemSetRandSeed(void)
|
|||
//Set random seed using global timer as reference
|
||||
srand((unsigned int)global_timer);
|
||||
|
||||
dprintf("Seed used: %d\n",(unsigned int)global_timer);
|
||||
Serial_printf("Seed used: %d\n",(unsigned int)global_timer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -359,29 +357,67 @@ void SystemCheckTimer(bool* timer, uint64_t* last_timer, uint8_t step)
|
|||
|
||||
bool SystemLoadFileToBuffer(char* fname, uint8_t* buffer, uint32_t szBuffer)
|
||||
{
|
||||
FILE *f;
|
||||
int32_t size;
|
||||
#ifdef SERIAL_INTERFACE
|
||||
uint8_t fileSizeBuffer[sizeof(uint32_t)] = {0};
|
||||
uint32_t i;
|
||||
#else
|
||||
FILE *f;
|
||||
#endif // SERIAL_INTERFACE
|
||||
int32_t size = 0;
|
||||
|
||||
// Wait for possible previous operation from the GPU before entering this section.
|
||||
while( (SystemIsBusy() == true) || (GfxIsGPUBusy() == true) );
|
||||
|
||||
if(fname == NULL)
|
||||
{
|
||||
dprintf("SystemLoadFile: NULL fname!\n");
|
||||
Serial_printf("SystemLoadFile: NULL fname!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
memset(buffer,0,szBuffer);
|
||||
|
||||
system_busy = true;
|
||||
|
||||
SystemDisableVBlankInterrupt();
|
||||
|
||||
f = fopen(fname, "r");
|
||||
|
||||
#ifdef SERIAL_INTERFACE
|
||||
Serial_printf("%s", fname);
|
||||
|
||||
SerialRead(fileSizeBuffer, sizeof(uint32_t) );
|
||||
|
||||
for(i = 0; i < sizeof(uint32_t); i++)
|
||||
{
|
||||
size |= fileSizeBuffer[i] << (i << 3); // (i << 3) == (i * 8)
|
||||
}
|
||||
|
||||
SerialWrite(ACK_BYTE_STRING, 1);
|
||||
|
||||
for(i = 0; i < size; i += SERIAL_DATA_PACKET_SIZE)
|
||||
{
|
||||
uint32_t bytes_to_read;
|
||||
|
||||
// Read actual EXE data into proper RAM address.
|
||||
|
||||
if( (i + SERIAL_DATA_PACKET_SIZE) >= size)
|
||||
{
|
||||
bytes_to_read = size - i;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytes_to_read = SERIAL_DATA_PACKET_SIZE;
|
||||
}
|
||||
|
||||
SerialRead(file_buffer + i, bytes_to_read);
|
||||
|
||||
SerialWrite(ACK_BYTE_STRING, sizeof(uint8_t)); // Write ACK
|
||||
}
|
||||
#else
|
||||
|
||||
SystemDisableVBlankInterrupt();
|
||||
|
||||
f = fopen(fname, "r");
|
||||
|
||||
if(f == NULL)
|
||||
{
|
||||
dprintf("SystemLoadFile: file could not be found!\n");
|
||||
Serial_printf("SystemLoadFile: file could not be found!\n");
|
||||
//File couldn't be found
|
||||
return false;
|
||||
}
|
||||
|
@ -392,7 +428,7 @@ bool SystemLoadFileToBuffer(char* fname, uint8_t* buffer, uint32_t szBuffer)
|
|||
|
||||
if(size > szBuffer)
|
||||
{
|
||||
dprintf("SystemLoadFile: Exceeds file buffer size (%d bytes)\n",size);
|
||||
Serial_printf("SystemLoadFile: Exceeds file buffer size (%d bytes)\n",size);
|
||||
//Bigger than 128 kB (buffer's max size)
|
||||
return false;
|
||||
}
|
||||
|
@ -402,12 +438,14 @@ bool SystemLoadFileToBuffer(char* fname, uint8_t* buffer, uint32_t szBuffer)
|
|||
fread(buffer, sizeof(char), size, f);
|
||||
|
||||
fclose(f);
|
||||
|
||||
SystemEnableVBlankInterrupt();
|
||||
|
||||
SystemEnableVBlankInterrupt();
|
||||
|
||||
#endif // SERIAL_INTERFACE
|
||||
|
||||
system_busy = false;
|
||||
|
||||
dprintf("File \"%s\" loaded successfully!\n",fname);
|
||||
Serial_printf("File \"%s\" loaded successfully!\n",fname);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -622,7 +660,7 @@ TYPE_TIMER* SystemCreateTimer(uint32_t t, bool rf, void (*timer_callback)(void)
|
|||
|
||||
if(t == 0)
|
||||
{
|
||||
dprintf("Cannot create timer with time == 0!\n");
|
||||
Serial_printf("Cannot create timer with time == 0!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -642,7 +680,7 @@ TYPE_TIMER* SystemCreateTimer(uint32_t t, bool rf, void (*timer_callback)(void)
|
|||
|
||||
if(success == false)
|
||||
{
|
||||
dprintf("Could not find any free timer!\n");
|
||||
Serial_printf("Could not find any free timer!\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -770,9 +808,9 @@ void SystemPrintStackPointerAddress(void)
|
|||
|
||||
stackPercent = fix16_smul(stackPercent, fix16_from_int((int)100));
|
||||
|
||||
dprintf("stackPercent: %d\n", stackPercent);
|
||||
Serial_printf("stackPercent: %d\n", stackPercent);
|
||||
|
||||
dprintf("Stack begin pointer: 0x%08X\n"
|
||||
Serial_printf("Stack begin pointer: 0x%08X\n"
|
||||
"Stack pointer address: 0x%08X\n"
|
||||
"Used %d%% of stack size.\n"
|
||||
"\tUsed bytes: %d\n",
|
||||
|
@ -794,7 +832,7 @@ void SystemCheckStack(void)
|
|||
|
||||
if(data != END_STACK_PATTERN)
|
||||
{
|
||||
dprintf("Stack overflow?\n");
|
||||
Serial_printf("Stack overflow?\n");
|
||||
|
||||
while(1);
|
||||
}
|
||||
|
@ -815,11 +853,11 @@ int32_t SystemIndexOfStringArray(char* str, char** array)
|
|||
|
||||
for(i = 0; array[i] != NULL; i++)
|
||||
{
|
||||
dprintf("String to find: %s\nEntry: %s\n", str, array[i]);
|
||||
Serial_printf("String to find: %s\nEntry: %s\n", str, array[i]);
|
||||
|
||||
if(strcmp(str, array[i]) == 0)
|
||||
{
|
||||
dprintf("Match! Returning index %d...\n", i);
|
||||
Serial_printf("Match! Returning index %d...\n", i);
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ void SystemTimerRemove(TYPE_TIMER* timer);
|
|||
// Compares two arrays of unsigned short type.
|
||||
bool SystemArrayCompare(unsigned short* arr1, unsigned short* arr2, size_t sz);
|
||||
|
||||
// Prints stack pointer address using dprintf()
|
||||
// Prints stack pointer address using Serial_printf()
|
||||
void SystemPrintStackPointerAddress(void);
|
||||
|
||||
// Checks if a 32-bit pattern set at the end of the stack has been
|
||||
|
@ -128,6 +128,10 @@ void SystemCyclicHandler(void);
|
|||
|
||||
void SystemClearBuffer(void);
|
||||
|
||||
void SystemEnableVBlankInterrupt();
|
||||
|
||||
void SystemDisableVBlankInterrupt();
|
||||
|
||||
/* **************************************
|
||||
* Global Variables *
|
||||
* **************************************/
|
||||
|
|
|
@ -16,12 +16,10 @@
|
|||
|
||||
int main(void)
|
||||
{
|
||||
|
||||
//System initialization
|
||||
SystemInit();
|
||||
|
||||
MainMenu();
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue