Skip to content

Commit

Permalink
Continue to implement SuperLeague
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Apr 2, 2018
1 parent b88b06b commit bca735e
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 18 deletions.
14 changes: 8 additions & 6 deletions Car_Behaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ extern IDirectSoundBuffer8 *CreakSoundBuffer;
extern IDirectSoundBuffer8 *SmashSoundBuffer;
extern IDirectSoundBuffer8 *OffRoadSoundBuffer;

extern bool bSuperLeague;

/* =========== */
/* Static data */
/* =========== */
Expand All @@ -157,8 +159,8 @@ static long accelerate, brake;

static long accelerating = FALSE; // to remember previous control state

static long engine_power = 240; // (240 standard, 320 super)
static long boost_unit_value = 16; // (16 standard, 12 super)
long engine_power = 240; // (240 standard, 320 super)
long boost_unit_value = 16; // (16 standard, 12 super)

static long left_right_value;
static long engine_z_acceleration;
Expand Down Expand Up @@ -371,8 +373,8 @@ void ResetPlayer (void)

accelerating = FALSE;

engine_power = 240; // (240 standard, 320 super)
boost_unit_value = 16; // (16 standard, 12 super)
engine_power = (bSuperLeague)?320:240; // (240 standard, 320 super)
boost_unit_value = (bSuperLeague)?12:16; // (16 standard, 12 super)

// calculated
left_right_value = 0;
Expand Down Expand Up @@ -2068,11 +2070,11 @@ static void CalculateGravityAcceleration (void)
/* Description: Calculate car acceleration caused by collision with other objects */
/* ======================================================================================= */

static long damaged_limit = 10; // Actually track/league dependant (could add to track data)
long damaged_limit = 10; // Actually track/league dependant (could add to track data)

// NOTE: road_cushion_value is 0 for standard league and 1 for super league
// fourteen_frames_elapsed has value of 0 or -1 (set)
static long road_cushion_value = 0, fourteen_frames_elapsed = 0;
long road_cushion_value = 0, fourteen_frames_elapsed = 0;


// following are only global due to use by two functions - could be passed in instead
Expand Down
85 changes: 75 additions & 10 deletions Opponent_Behaviour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ long opponents_current_piece = 0; // use as opponents_road_section
bool player_close_to_opponent = FALSE;
bool opponent_behind_player = FALSE;

extern bool bSuperLeague;
extern unsigned char sections_car_can_be_put_on[]; // both array are used for opponents speed values computation
extern char Piece_Angle_And_Template[MAX_PIECES_PER_TRACK];

// SEB: The opponents_speed_values, that is pre-computed, is not used anymore and Opponents_Speed_Value function is used now
// Values for each piece of each track (Global because MoveDrawBridge() modifies the Draw Bridge values)
// NOTE: These are for the Standard league. Super league values are different
unsigned char opponents_speed_values[NUM_TRACKS][MAX_PIECES_PER_TRACK] =
Expand Down Expand Up @@ -190,14 +195,14 @@ static unsigned char opp_track_speed_values[] = //DAT.1fe2c
// Standard league
0x07,0x07,0x07,0x07,0x07,0x07,0x07,0x07,
0x41,0x3a,0x3e,0x41,0x48,0x51,0x48,0x4f,
//0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // used when creating opponents.speed.values
//0x48,0x41,0x45,0x48,0x4f,0x58,0x4f,0x56, // used when creating opponents.speed.values
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // used when creating opponents.speed.values
0x48,0x41,0x45,0x48,0x4f,0x58,0x4f,0x56, // used when creating opponents.speed.values

// Super league
0x07,0x03,0x03,0x03,0x03,0x03,0x07,0x03,
0x66,0x57,0x57,0x59,0x59,0x69,0x62,0x64
//0x07,0x03,0x03,0x03,0x03,0x01,0x03,0x03, // used when creating opponents.speed.values
//0x61,0x55,0x53,0x56,0x58,0x5b,0x5a,0x62 // used when creating opponents.speed.values
0x66,0x57,0x57,0x59,0x59,0x69,0x62,0x64,
0x07,0x03,0x03,0x03,0x03,0x01,0x03,0x03, // used when creating opponents.speed.values
0x61,0x55,0x53,0x56,0x58,0x5b,0x5a,0x62 // used when creating opponents.speed.values
};

static long opponents_distance_into_section;
Expand Down Expand Up @@ -238,7 +243,7 @@ static long opp_touching_road;
static long opp_y_acceleration[NUM_OPP_WHEEL_POSITIONS];
static long opp_y_speed[NUM_OPP_WHEEL_POSITIONS];

static long opp_engine_power = 236; // (236 standard, 314 super)
long opp_engine_power = 236; // (236 standard, 314 super)
static long opponents_engine_z_acceleration;
static long opponents_max_speed;
static long opponents_z_speed;
Expand Down Expand Up @@ -358,8 +363,8 @@ void OpponentBehaviour (long *x,
// end initialise.opponent.data

// Set opponent_max_speed
long s = (long)rand() & (long)opp_track_speed_values[TrackID];
s += (long)opp_track_speed_values[TrackID+8];
long s = (long)rand() & (long)opp_track_speed_values[TrackID+(bSuperLeague?32:0)];
s += (long)opp_track_speed_values[TrackID+8+(bSuperLeague?32:0)];
opponents_max_speed = s;
//temp opponents_max_speed = 10;

Expand Down Expand Up @@ -1247,6 +1252,66 @@ static void AverageWheelYSpeeds( long wheel1, long wheel2 )
opp_y_speed[wheel2] = average;
}

static long Opponent_Speed_Value( long TrackID, long pos )
{
/*srd111a move.l #road.section.angle.and.piece,a1
move.b (a1,d1.w),d0
andi.b #$f,d0
move.b d0,d2
move.l #sections.car.can.be.put.on,a2
move.b (a2,d2.w),d0
bpl srd112
move.b B.63ce1,d0
subi.b #10,d0
move.b d0,value
move.b B.63ce1,d0
jmp srd113a
srd112 move.b value,d0
addi.b #10,d0
bmi srd113
move.b d0,value
srd113 move.b value,d0
srd113a move.b prompt.chars,d2
beq srd114
subq.b #1,prompt.chars
ori.b #$80,d0
srd114 move.l #opponents.speed.values,a1
move.b d0,(a1,d1.w)
*/
static long oldpos = -1;
static long oldtrack = -1;
static bool oldleague = false;
static long oldspeed = 0;
if(pos==oldpos && oldtrack==TrackID && oldleague==bSuperLeague)
return oldspeed;
oldpos = pos;
oldleague = bSuperLeague;
oldtrack = TrackID;

long b = Piece_Angle_And_Template[pos];
b = sections_car_can_be_put_on[b&0x0f];
long B63ce1 = (long)rand() & (long)opp_track_speed_values[TrackID+16+(bSuperLeague?32:0)];
B63ce1 += (long)opp_track_speed_values[TrackID+24+(bSuperLeague?32:0)];
long /*value,*/ d0;
if (b<0) {
//value = B63ce1-10;
d0 = B63ce1;
} else {
if (B63ce1<(0x7f-10))
d0 = /*value =*/ B63ce1+10;
else
d0 = /*value =*/ B63ce1;
}
oldspeed = d0;
return d0;
}


/* ======================================================================================= */
/* Function: RandomizeOpponentsSteering */
Expand Down Expand Up @@ -1324,7 +1389,7 @@ long value;

ros1:
d2 = opponents_current_piece;
if (opponents_speed_values[TrackID][d2] < 0)
if (/*opponents_speed_values[TrackID][d2]*/Opponent_Speed_Value(TrackID, d2) < 0)
goto ros2;

if (opponent_behind_player)
Expand Down Expand Up @@ -1432,7 +1497,7 @@ long speed_value, speed, opponents_required_z_speed;
if (!opp_touching_road)
return;

speed_value = opponents_speed_values[TrackID][opponents_current_piece];
speed_value = /*opponents_speed_values[TrackID][opponents_current_piece]*/Opponent_Speed_Value(TrackID, opponents_current_piece);
speed = speed_value;
if ((speed & 0x80) == 0)
{
Expand Down
20 changes: 19 additions & 1 deletion StuntCarRacer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ extern long INITIALISE_PLAYER;
extern bool raceFinished, raceWon;
extern long lapNumber[];

// League / Super League variable
extern long damaged_limit;
extern long road_cushion_value;
extern long engine_power;
extern long boost_unit_value;
extern long opp_engine_power;

//-----------------------------------------------------------------------------
// Static variables
Expand Down Expand Up @@ -1195,7 +1201,19 @@ static void HandleTrackPreview( CDXUTTextHelper &txtHelper )
ResetLapData(PLAYER);
gameStartTime = DXUTGetTime();
gameEndTime = 0;
boostReserve = StandardBoost; // SuperBoost for super league
if(bSuperLeague) {
boostReserve = SuperBoost;
road_cushion_value = 1;
engine_power = 320;
boost_unit_value = 12;
opp_engine_power = 314;
} else {
boostReserve = StandardBoost; // SuperBoost for super league
road_cushion_value = 0;
engine_power = 240;
boost_unit_value = 16;
opp_engine_power = 236;
}
boostUnit = 0;
bPlayerPaused = bOpponentPaused = FALSE;
keyPress = '\0';
Expand Down
2 changes: 1 addition & 1 deletion Track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ static char Piece_X_Z_Position[MAX_PIECES_PER_TRACK];/* Little Ramp data, from b
//*
//* Bottom nibble is the near section piece to use.
//
static char Piece_Angle_And_Template[MAX_PIECES_PER_TRACK];/* Little Ramp data, from before it was loaded =
char Piece_Angle_And_Template[MAX_PIECES_PER_TRACK];/* Little Ramp data, from before it was loaded =
{
(char)0xa0,(char)0xa0,(char)0xa0,(char)0xa0,(char)0xa0,(char)0xa0,(char)0xa0,(char)0xa0,
(char)0xa0,(char)0xa0,(char)0x80,(char)0x86,(char)0x57,(char)0xc0,(char)0xe0,(char)0xe0,
Expand Down

0 comments on commit bca735e

Please sign in to comment.