If you appreciate the work done within the wiki, please consider supporting The Cutting Room Floor on Patreon. Thanks for all your support!

ESPN Extreme Games

From The Cutting Room Floor
Jump to navigation Jump to search

Title Screen

ESPN Extreme Games

Also known as: ESPN Street Games (JP), 1Xtreme (US "Greatest Hits" release)
Developer: Sony Interactive Studios America
Publisher: Sony Computer Entertainment
Platform: PlayStation
Released in JP: May 24, 1996
Released in US: September 9, 1995
Released in EU: December 15, 1995


SourceIcon.png This game has uncompiled source code.
RegionIcon.png This game has regional differences.
Carts.png This game has revisional differences.


ESPN Extreme Games is the first in the trilogy of the Xtreme games for PlayStation.

Regional Differences

The game has multiple naming variations regionally, with both originally bearing the ESPN brand.

US/Europe Japan
Espn extreme games title.png Espn street games title.png

Revisional Differences

The US version was re-released under the Greatest Hits collection as 1Xtreme, which the series would use from there on out.

Original Rerelease
Espn extreme games title.png 1xtreme title.png

Alongside the title change, all references to ESPN and its properties were removed, such as the deletion of all of the video segments found in the SUZY0-SUZY6 folders.

Source Code

In all variations of the game, there are two instances of uncompiled source code, both being found in the BLK folder. Both segments of code begin at 0x0 in the following files:

COMBO.BLK

/*
���������������������������������������������������������������������������������������������ͻ
�  Module:     "MAIN.C"                                                                       �
�                                                                                             �
�  Purpose:    Initialization and main game loop for Extreme Front End                        �
���������������������������������������������������������������������������������������������ͼ*/
#define TEST 1
#define FRONTEND_ONLY 1
/*
���������������������������������������������������������������������������������������������Ŀ
�  Includes                                                                                   �
�                                                                                             �*/
#include <sys/types.h>
#include <sys/file.h>
#include <libetc.h>
#include <libgte.h>
#include <libgpu.h>
#include <libsn.h>
#include <libcd.h>
#include <libsnd.h>

#include <r3000.h>
#include <asm.h>
#include <kernel.h>

#include "globals.h"
#include "cd.h"
#include "display.h"
#include "objects.h"
#include "tv.h"
#include "equip.h"
#include "standing.h"
#include "font.h"
#include "course.h"
#include "book.h"
#include "intro.h"
#include "sound.h"
#include "cursor.h"
#include "ramcard.h"
#include "pad.h"
/*                                                                                            �
�                                                                                             �
�  End of Includes                                                                            �
�����������������������������������������������������������������������������������������������*/

/*
���������������������������������������������������������������������������������������������Ŀ
�  Global Variables                                                                           �
�                                                                                             �
�                                                                                             �*/
FRONT_END* front_end = (FRONT_END*)FRONT_END_ADDRESS;
EXTREME_SCORES* extreme_scores = (EXTREME_SCORES*)HIGH_SCORES_ADDRESS;
signed long kerouac = 0;
signed long launch_race = 0;
signed long launch_suzy = 0;
/*                                                                                            �
�                                                                                             �
�  End of Global Variables                                                                    �
�����������������������������������������������������������������������������������������������*/



OBJECT* icon_p1;

signed long display_icons;
unsigned long total_time;

#define ICON1_VX 704
#define ICON1_VY 64
#define ICON1_VW 42
#define ICON1_VH 24
#define ICON1_SX 14
#define ICON1_SY 200
#define ICON1_CX 320
#define ICON1_CY 241


#define ICON2_VX 704
#define ICON2_VY 96
#define ICON2_VW 42
#define ICON2_VH 24
#define ICON2_SX 14+2+ICON1_VW
#define ICON2_SY 200
#define ICON2_CX 320
#define ICON2_CY 242


signed long icon_p1Normal(OBJECT* object)
{
   if(!display_icons)
   {
      object->data_a = 0;
      object->data_b = 0;
      return(0);
   }

   if(!object->data_a)
   {
      switch(front_end->player1.vehicle)
      {
	 case MOUNTAIN_BIKE:
	    Unpack(ICONMB1_RLE_A,(unsigned long)unpack_buffer);
	    break;
	 case STREET_LUGE:
	    Unpack(ICONSL1_RLE_A,(unsigned long)unpack_buffer);
	    break;
	 case SKATE_BOARD:
	    Unpack(ICONSB1_RLE_A,(unsigned long)unpack_buffer);
	    break;
	 case INLINE_SKATES:
	    Unpack(ICONRB1_RLE_A,(unsigned long)unpack_buffer);
	    break;
	 default:
	    Unpack(ICONMB1_RLE_A,(unsigned long)unpack_buffer);
	    break;
      }
      LoadTIM8((unsigned long)unpack_buffer,ICON1_VX,ICON1_VY,ICON1_CX,ICON1_CY);
      object->data_a = 1;
   }
   DisplayBitmap8(ICON1_SX,ICON1_SY,ICON1_VX,ICON1_VY,ICON1_VW,ICON1_VH,ICON1_CX,ICON1_CY,1,0);

   if(front_end->num_players==1)
   {
      if(!object->data_b)
      {
    switch(front_end->player2.vehicle)
	 {
	    case MOUNTAIN_BIKE:
	       Unpack(ICONMB2_RLE_A,(unsigned long)unpack_buffer);
	       break;
	    case STREET_LUGE:
	       Unpack(ICONSL2_RLE_A,(unsigned long)unpack_buffer);
	       break;
	    case SKATE_BOARD:
	       Unpack(ICONSB2_RLE_A,(unsigned long)unpack_buffer);
	       break;
	    case INLINE_SKATES:
	       Unpack(ICONRB2_RLE_A,(unsigned long)unpack_buffer);
	       break;
	    default:
	       Unpack(ICONMB2_RLE_A,(unsigned long)unpack_buffer);
	       break;
	 }
	 LoadTIM8((unsigned long)unpack_buffer,ICON2_VX,ICON2_VY,ICON2_CX,ICON2_CY);
	 object->data_b = 1;
      }
      DisplayBitmap8(ICON2_SX,ICON2_SY,ICON2_VX,ICON2_VY,ICON2_VW,ICON2_VH,ICON2_CX,ICON2_CY,1,0);
   }

   return(0);
}



void InitIcons()
{
   display_icons = 1;
   icon_p1 = AddObject();
   icon_p1->routine = icon_p1Normal;
}


/*void screen_shot(short x, short y)
{
	static char filename[]="ss000.tim";
	RECT	rect;
	char	*screen_bufferp=(unsigned char *)0x801e9000-0x25800;
	int		fhandle;
	unsigned long	timHeader[] = {
						0x00000010,
						0x00000002,
						0x00009600,
						0x00000000,
						0x00f00140};

	rect.x = x;
	rect.y = y;
	rect.w = 320;
	rect.h = 240;

	DrawSync(0);
	StoreImage(&rect,(unsigned long *)screen_bufferp);
	DrawSync(0);
	PCinit();
	fhandle = PCopen(filename,0x0002,0);
	if ( fhandle == -1 )
	{
		fhandle = PCcreat(filename, 0x0002);
	}
	if (fhandle != -1)
	{
		PCwrite(fhandle, (char *)timHeader, 20);
		PCwrite(fhandle, screen_bufferp, 320*240*2);
		PCclose(fhandle);
	}
	free(screen_bufferp);

	if(filename[4]++=='9')
	{
		filename[4]='0';
		if(filename[3]++=='9')
		{
			filename[3]='0';
			filename[2]++;
		}
	}
} */


/*
���������������������������������������������������������������������������������������������Ŀ
�  Function:      main                                                                        �
�                                                                                             �
�  Purpose:       Game's main function, dork.                                                 �
�                                                                                             �*/
main()
{
   unsigned long i;
	char param[8];
   RECT rect = {0,0,320,240};






   ResetCallback();
/*   ResetGraph(1);*/

	#if FRONTEND_ONLY
   	extreme_scores->high_scores[SAN_FRANCISCO] = 70000;
	extreme_scores->high_scores[ROME] = 2000;
	extreme_scores->high_scores[SOUTH_AMERICA] = 3000;
	extreme_scores->high_scores[UTAH] = 4000;
	extreme_scores->high_scores[LAKE_TAHOE] = 5000;

	strncpy(extreme_scores->high_initials[SAN_FRANCISCO],"AAA",3);
	strncpy(extreme_scores->high_initials[ROME],"BBB",3);
	strncpy(extreme_scores->high_initials[SOUTH_AMERICA],"CCC",3);
	strncpy(extreme_scores->high_initials[UTAH],"DDD",3);
	strncpy(extreme_scores->high_initials[LAKE_TAHOE],"EEE",3);

	front_end->course = SAN_FRANCISCO;
	front_end->num_players = ONE_PLAYER;
	front_end->difficulty = EXTREME;
	front_end->season_mode = NEW_SEASON;


	front_end->race = 0;
	front_end->video = 0;
	front_end->sound_volume = 0x1FFF;

	front_end->music_volume = 0x1FFF;
	front_end->course_difficulty = EXTREME;
	front_end->use_ram_card = 1;

	front_end->use_mountain_bike = 1;
	front_end->use_street_luge = 1;
	front_end->use_skate_board = 1;
	front_end->use_inline_skates = 1;

	front_end->money_player = ONE_PLAYER;

	front_end->flag = FEF_RACEDONE;

	front_end->player1.race_result = 0x00555555;
	front_end->player1.inline_skates = 1;
	front_end->player1.skate_board = 1;
	front_end->player1.mountain_bike = 1;
	front_end->player1.street_luge = 1;
	front_end->player1.top_speed = 90;
	front_end->player1.acceleration = 5;
	front_end->player1.handling = 5;
	front_end->player1.score = 80000;
	front_end->player1.strength_rating = 5;
	front_end->player1.endurance_rating = 5;

	front_end->player1.street_luge_rating = 5;
   front_end->player1.vehicle = MOUNTAIN_BIKE;
   front_end->player1.character_index = 0;

   front_end->player1.cash = 305;
   front_end->player1.gate_points = 40;
   front_end->player1.seed = 2;

	strncpy(front_end->player1.initials,"DBB",3);
	front_end->player1.place = 1;

	front_end->player2.race_result = 0;
	front_end->player2.inline_skates = 1;
	front_end->player2.skate_board = 1;
	front_end->player2.mountain_bike = 1;
	front_end->player2.street_luge = 1;
	front_end->player2.top_speed = 90;
	front_end->player2.acceleration = 5;
	front_end->player2.handling = 5;
	front_end->player2.score = 80000;
	front_end->player2.strength_rating = 5;
	front_end->player2.endurance_rating = 5;

	front_end->player2.street_luge_rating = 5;
   front_end->player2.vehicle = MOUNTAIN_BIKE;
   front_end->player2.character_index = 2;

   front_end->player2.cash = 310;
   front_end->player2.gate_points = 40;
   front_end->player2.seed = 2;


	strncpy(front_end->player2.initials,"JAM",3);
   front_end->player2.place = 2;

   #endif






   if(front_end->flag==FEF_MONEYDONE || front_end->flag==FEF_SUZYDONE || front_end->flag==FEF_RACEDONE)
	{
		if(front_end->season_mode==EXIBITION)
		{
			front_end->race = 0;
		}
		else
		{
			/*-----------------08-01-95 02:14pm-----------------
			 Don't set bits again if from suzy.
			--------------------------------------------------*/
			if(front_end->flag==FEF_RACEDONE)
			{
				if(front_end->player1.place<3) WriteBits((unsigned char*)&front_end->player1.race_result,front_end->race/4,(front_end->race*2)%8,2,front_end->player1.place+1);
				else WriteBits((unsigned char*)&front_end->player1.race_result,front_end->race/4,(front_end->race*2)%8,2,0);

				if(front_end->num_players==TWO_PLAYER)
				{
					if(front_end->player2.place<3) WriteBits((unsigned char*)&front_end->player2.race_result,front_end->race/4,(front_end->race*2)%8,2,front_end->player2.place+1);
					else WriteBits((unsigned char*)&front_end->player2.race_result,front_end->race/4,(front_end->race*2)%8,2,0);
				}
			}

			front_end->race++;
		}

		front_end->new_high_score = 0;

		/*-----------------06-26-95 10:09am-----------------
	 	Check high score.
		--------------------------------------------------*/
		if(front_end->player1.place != FAILED_TO_FINISH && front_end->player1.score > extreme_scores->high_scores[front_end->course])
		{
			front_end->new_high_score = 1;
			front_end->new_high_player = ONE_PLAYER;
			front_end->new_high_course = front_end->course;
			if(front_end->season_mode!=EXIBITION)
			{
				extreme_scores->high_initials[front_end->new_high_course][0] = front_end->player1.initials[0];
				extreme_scores->high_initials[front_end->new_high_course][1] = front_end->player1.initials[1];
				extreme_scores->high_initials[front_end->new_high_course][2] = front_end->player1.initials[2];
			}
			extreme_scores->high_scores[front_end->new_high_course] = front_end->player1.score;
		}

		if(front_end->player2.place != FAILED_TO_FINISH &&front_end->num_players==TWO_PLAYER && front_end->player2.score > extreme_scores->high_scores[front_end->course])
		{
			front_end->new_high_score = 1;
			front_end->new_high_player = TWO_PLAYER;
			front_end->new_high_course = front_end->course;
			if(front_end->season_mode!=EXIBITION)
			{
				extreme_scores->high_initials[front_end->new_high_course][0] = front_end->player2.initials[0];
				extreme_scores->high_initials[front_end->new_high_course][1] = front_end->player2.initials[1];
				extreme_scores->high_initials[front_end->new_high_course][2] = front_end->player2.initials[2];
			}
			extreme_scores->high_scores[front_end->new_high_course] = front_end->player2.score;
		}

		if(front_end->season_mode!=EXIBITION)
		{
			SetupFrontEnd();
		}
	}


   /*-----------------9/28/95 4:43:M-------------------
    Better transition from letter to letter etc.
   --------------------------------------------------*/
   if(front_end->flag==FEF_RACEDONE) InitDisplayMark();
   else InitDisplay();



   #if TEST
   ResetCallback();
   ResetGraph(1);
   CdInit();
   #else
   CdReset(2);
   #endif

   init_pad();


   #if RAM_CARD_WORKS
	InitRAMCard();
	#endif







	param[0] = 0;
	CdControlB(CdlSetmode,param,0);
   InitDataBlocks();

   total_time = 0;


   LoadAndWait(&COMBO_BLK,RAM_START_ADDRESS,0);
   InitSound((VabHdr*)GARAGE_VAB_A,0);
   Unpack(COMBOBIT_RLE_A,(unsigned long)unpack_buffer);
	initTexture((TEX_STRUC*)unpack_buffer,768,256);
   Unpack(COMBOCLT_RLE_A,(unsigned long)unpack_buffer);
   initTexture((TEX_STRUC*)unpack_buffer,0,480);

   LoadAndWait(&MAIN_BLK,RAM_START_ADDRESS,0);
   ReadDataBlock(&PLAYERS_BLK,MAIN_BLK.base+MAIN_BLK.file.size);

   Unpack(MAIN_RLE_A,(unsigned long)unpack_buffer);
   SetBackground((unsigned long)unpack_buffer,128,128,128);
	MoveImage(&rect,0,240);
   MoveImage(&rect,320,0);
	DrawSync(0);



   /*-----------------9/28/95 4:43:M-------------------
    Better transition from letter to letter etc.
   --------------------------------------------------*/
   if(front_end->flag==FEF_RACEDONE) InitDisplay();


	if(front_end->flag == FEF_INTRODONE)
	{
		#if RAM_CARD_WORKS
		if(RAMCardPresent(RAM_CARD_CHANNEL))
		{
			if(RAMCardFormatted(RAM_CARD_CHANNEL))
			{
            if(RAMCardFileExists("BISIPS-60004",RAM_CARD_CHANNEL))
				{
               ReadRAMCardFile("BISIPS-60004",RAM_CARD_CHANNEL,
											(unsigned char*)extreme_scores,sizeof(EXTREME_SCORES));
				}
			}
		}
		#endif

		front_end->flag = FEF_FRONTEND;
 		StartFrontEnd();
	}
	else
	{
		SetBackground((unsigned long)unpack_buffer,255,255,255);
		MoveImage(&rect,320,256);
		InitObjectSystem();
		InitFont(FONT1_FNT_A,FONT1_CLT_A);
		InitCursor();
		InitStartTV();
		InitStanding();
		InitCourse();
		InitMainDoor();
		intro_status = INTRO_GO_MAIN;
		cursor_lock = 1;
		display_icons = 0;
	}


   while(1)
	{
      total_time++;
      TopDisplay();

		if(intro_status==INTRO_GO_MAIN)
		{
	 		ObjectSystem();
		}
		else
		{
			DoIntro();
			if(intro_status==INTRO_CLOSE_DOORS || intro_status==INTRO_RESTART) ObjectSystem();
			if(intro_status==INTRO_GO_MAIN)
			{
				InitObjectSystem();
	    		InitFont(FONT1_FNT_A,FONT1_CLT_A);
	    		InitCursor();
				InitTV();
	    		InitStanding();
	    		InitCourse();
	    		InitMainDoor();
	    		InitIcons();
			}
		}

		BottomDisplay();


      #if POLLHOST
      pollhost();
      #endif
	}


}
/*                                                                                            �
�                                                                                             �
�  End of main                                                                                �
�����������������������������������������������������������������������������������������������*/

LOADING.BLK

#include <sys/types.h>
#include <sys/file.h>
#include <libetc.h>
#include <libgte.h>
#include <libgpu.h>
#include <libsn.h>
#include <libcd.h>

#include <kernel.h>
#include <libsnd.h>

#include "globals.h"
#include "cd.h"
#include "display.h"
#include "intro.h"
#include "objects.h"
#include "course.h"
#include "sound.h"
#include "font.h"
#include "tv.h"
#include "ramcard.h"

#define NUM_POSITIONS 5

#define LEFT_DOOR_VX 320
#define LEFT_DOOR_VY 256
#define RIGHT_DOOR_VX 480
#define RIGHT_DOOR_VY 256
#define DOOR_VW 160
#define DOOR_VH 240

#define DOOR_SPEED 4

#define PLAYERS_VY (44+12)
#define SEASON_VY PLAYERS_VY+25
#define DIFFICULTY_VY SEASON_VY+25
#define SOUND_VY DIFFICULTY_VY+25
#define MUSIC_VY SOUND_VY+25
#define VIDEO_VY MUSIC_VY+25

#define PLAYERS_CHOICES 2
#define SEASON_CHOICES 3
#define DIFFICULTY_CHOICES 4
#define MUSIC_CHOICES 2
#define SOUND_CHOICES 2
#define VIDEO_CHOICES 2

#define SLIDER_MIN_X (640+85+15)
#define SLIDER_MAX_X (640+85+131)
#define SOUND_SLIDER_Y (SOUND_VY+14)
#define MUSIC_SLIDER_Y (MUSIC_VY+14)
#define SLIDER_MOVE 512


#define PASSWORD_LENGTH 9

unsigned short positions[6] = {PLAYERS_VY,SEASON_VY,DIFFICULTY_VY,SOUND_VY,MUSIC_VY,VIDEO_VY};

unsigned num_choices[6] = {PLAYERS_CHOICES,SEASON_CHOICES,DIFFICULTY_CHOICES,SOUND_CHOICES,MUSIC_CHOICES,VIDEO_CHOICES};

unsigned long players_rle;
unsigned long season_rle;
unsigned long difficulty_rle;
unsigned long music_rle;
unsigned long sound_rle;
unsigned long video_rle;

unsigned long* current_choices[6];

int players_loaded;
int season_loaded;
int difficulty_loaded;
int music_loaded;
int sound_loaded;
int video_loaded;

signed long intro_status;
signed long door_closure;
signed long doors_loaded;
signed long position_index;
unsigned char saving_season=0;


unsigned long players_white[PLAYERS_CHOICES];
unsigned long players_yellow[PLAYERS_CHOICES];
unsigned long season_white[SEASON_CHOICES];
unsigned long season_yellow[SEASON_CHOICES];
unsigned long difficulty_white[DIFFICULTY_CHOICES];
unsigned long difficulty_yellow[DIFFICULTY_CHOICES];
unsigned long sound_white[SOUND_CHOICES];
unsigned long sound_yellow[SOUND_CHOICES];
unsigned long music_white[MUSIC_CHOICES];
unsigned long music_yellow[MUSIC_CHOICES];
unsigned long video_white[VIDEO_CHOICES];
unsigned long video_yellow[VIDEO_CHOICES];

unsigned long* whites[6];
unsigned long* yellows[6];
int* load_booleans[6];

#define REPLACE_WAIT 90
static signed long replace_wait;


static RECT clear = {640,0,320,240};


unsigned char course_order[12] = {UTAH,SAN_FRANCISCO,SOUTH_AMERICA,LAKE_TAHOE,ROME,
											UTAH,SAN_FRANCISCO,SOUTH_AMERICA,LAKE_TAHOE,ROME,
											UTAH,SAN_FRANCISCO};
#define NUM_LOGOS 4
#define MAX_LOGO_FRAMES 10


static unsigned long logo_rles[NUM_LOGOS][MAX_LOGO_FRAMES];
static unsigned long num_logo_frames[NUM_LOGOS];
static unsigned long logo_frame[NUM_LOGOS];
static unsigned long logo_count[NUM_LOGOS];
static unsigned long logo_time[NUM_LOGOS];

static unsigned long logo_states[NUM_LOGOS][MAX_LOGO_FRAMES] =
{
	{0,1,2,3,4,4,3,2,1,0},
	{0,1,2,3,4,0,1,2,3,4},
	{0,0,0,0,0,0,0,0,0,0},
	{0,0,0,0,0,0,0,0,0,0}
};


static void InitLogos()
{
	unsigned long i;

	for(i=0;i<NUM_LOGOS;i++)
	{
		logo_frame[i] = 0;
		logo_count[i] = 0;
	}


	logo_rles[0][0] = ESPN_A_RLE_A;
	logo_rles[0][1] = ESPN_B_RLE_A;
	logo_rles[0][2] = ESPN_C_RLE_A;
	logo_rles[0][3] = ESPN_D_RLE_A;
	logo_rles[0][4] = ESPN_E_RLE_A;
	num_logo_frames[0] = 10;

	logo_rles[1][0] = ESPN2_A_RLE_A;
	logo_rles[1][1] = ESPN2_B_RLE_A;
	logo_rles[1][2] = ESPN2_C_RLE_A;
	logo_rles[1][3] = ESPN2_D_RLE_A;
	logo_rles[1][4] = ESPN2_E_RLE_A;
	num_logo_frames[1] = 5;

	logo_rles[2][0] = DEW_RLE_A;
	num_logo_frames[2] = 1;

	logo_rles[3][0] = STATIC_RLE_A;
	num_logo_frames[3] = 1;

}

static void AnimateLogos()
{
	unsigned long i;
	unsigned long vxs[NUM_LOGOS] = {320,320+42,320+42+42,320+42+42+48};
	unsigned long vys[NUM_LOGOS] = {0,0,0,0};
	unsigned long vws[NUM_LOGOS] = {42,42,48,56};
	unsigned long vhs[NUM_LOGOS] = {12,38,32,39};
	unsigned long cxs[NUM_LOGOS] = {320,320,320,320};
	unsigned long cys[NUM_LOGOS] = {241,242,243,244};
	unsigned long sxs[NUM_LOGOS] = {8,312-42,5,312-57};
	unsigned long sys[NUM_LOGOS] = {24,16-4,206-12,188-2};


	/*-----------------06-14-95 10:40am-----------------
	 Compensate for long draw time when getting pass.
	--------------------------------------------------*/
	if(intro_status==INTRO_CONTINUE_SEASON)
	{
		if(front_end->num_players==TWO_PLAYER)
		{
			logo_time[0] = 2;
			logo_time[1] = 2;
			logo_time[2] = 2;
			logo_time[3] = 2;
		}
		else
		{
			logo_time[0] = 2;
			logo_time[1] = 2;
			logo_time[2] = 2;
			logo_time[3] = 2;
		}
	}
	else
	{
		logo_time[0] = 3;
		logo_time[1] = 3;
		logo_time[2] = 3;
		logo_time[3] = 3;
	}


	for(i=0;i<2/*NUM_LOGOS*/;i++)
	{
		if(!logo_count[i])
		{
			Unpack(logo_rles[i][logo_states[i][logo_frame[i]]],(unsigned long)unpack_buffer);
			LoadTIM8((unsigned long)unpack_buffer,vxs[i],vys[i],cxs[i],cys[i]);
			logo_frame[i]++;
			if(logo_frame[i]==num_logo_frames[i]) logo_frame[i] = 0;
			logo_count[i] = logo_time[i];
		}
		logo_count[i] -= 1;

		DisplayBitmap8(sxs[i],sys[i],vxs[i],vys[i],vws[i],vhs[i],cxs[i],cys[i],0,0);
	}
}


void SetupFrontEnd()
{
	if(front_end->season_mode!=EXIBITION)
	{
		front_end->course = course_order[front_end->race];
	}

	front_end->course_difficulty = front_end->race/4;
  	front_end->course_difficulty += front_end->difficulty;
  	if(front_end->course_difficulty > EXTREME) front_end->course_difficulty=EXTREME;

   TransferCharacterData(&front_end->player1);
	TransferVehicleData(&front_end->player1);
   if(front_end->num_players==TWO_PLAYER)
	{
		TransferCharacterData(&front_end->player2);
		TransferVehicleData(&front_end->player2);
	}
}

signed long yes_or_no;

#define USE_VW 150
#define USE_VH 84
#define USE_VX (640+(160-USE_VW/2))
#define USE_VY (120-USE_VH/2)

#define SAVE_VW USE_VW
#define SAVE_VH USE_VH
#define SAVE_VX (640+(160-SAVE_VW/2))
#define SAVE_VY (120-SAVE_VH/2)

#define YES_VW 30
#define YES_VH 17
#define YES_VX (USE_VX+57)
#define YES_VY (USE_VY+38)

#define NO_VW 30
#define NO_VH 17
#define NO_VX (USE_VX+58)
#define NO_VY (USE_VY+57)


static void InitUseMemCard()
{
	#if RAM_CARD_WORKS
	InitFont(FONT2_FNT_A,FONT2_CLT_A);
	SetFontColor(5);

	ClearImage(&clear,0,0,0);

	Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

	Unpack(USECARD_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,USE_VX,USE_VY);

	Unpack(Y_YES_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

	Unpack(W_NO_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

	yes_or_no = 1;

	#endif
}


static void InitFormatCard()
{
	#if RAM_CARD_WORKS

	intro_status=INTRO_FORMAT;

	InitFont(FONT2_FNT_A,FONT2_CLT_A);
	SetFontColor(5);

	ClearImage(&clear,0,0,0);

	Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

	Unpack(FORMAT_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,USE_VX,USE_VY);

	Unpack(Y_YES_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

	Unpack(W_NO_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

	yes_or_no = 1;

	#endif
}

static void InitVerify()
{
	#if RAM_CARD_WORKS
	intro_status = INTRO_VERIFY;


	InitFont(FONT2_FNT_A,FONT2_CLT_A);
	SetFontColor(5);

	ClearImage(&clear,0,0,0);

	Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

	Unpack(VERIFY_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,USE_VX,USE_VY);

	Unpack(Y_YES_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

	Unpack(W_NO_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

	yes_or_no = 1;

	#endif
}



#define START_SELECT 40
unsigned long start_select;


static void StartSelect()
{
   start_select++;
   if(start_select==START_SELECT)
   {
      Unpack(SELECT_RLE_A,(unsigned long)unpack_buffer);
      LoadTIM((unsigned long)unpack_buffer,640,202);
   }
   else if(start_select==START_SELECT*2)
   {
      Unpack(START_RLE_A,(unsigned long)unpack_buffer);
      LoadTIM((unsigned long)unpack_buffer,640,202);
      start_select = 0;
   }
}





/*static void UseMemCard()
{
	StartSelect();

	if(bothtap & PADLdown && yes_or_no)
	{
		yes_or_no = 0;
		Unpack(W_YES_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

		Unpack(Y_NO_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

		PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
	}
	if(bothtap & PADLup && !yes_or_no)
	{
		yes_or_no = 1;
		Unpack(Y_YES_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

		Unpack(W_NO_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

		PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
	}
}

static void FormatCard()
{
	StartSelect();

	if(bothtap & PADLdown && yes_or_no)
	{
		yes_or_no = 0;
		Unpack(W_YES_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

		Unpack(Y_NO_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

		PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
	}
	if(bothtap & PADLup && !yes_or_no)
	{
		yes_or_no = 1;
		Unpack(Y_YES_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

		Unpack(W_NO_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

		PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
	}
} */


static void InitSaveMemCard()
{
	#if RAM_CARD_WORKS
	ClearImage(&clear,0,0,0);

	Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

	Unpack(SAVECARD_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,SAVE_VX,SAVE_VY);

	Unpack(Y_YES_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

	Unpack(W_NO_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

	yes_or_no = 1;
	#endif
}


static void YesOrNo()
{
	if(bothtap & PADLdown && yes_or_no)
	{
		yes_or_no = 0;
		Unpack(W_YES_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

		Unpack(Y_NO_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

		PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
	}
	if(bothtap & PADLup && !yes_or_no)
	{
		yes_or_no = 1;
		Unpack(Y_YES_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,YES_VX,YES_VY);

		Unpack(W_NO_RLE_A,(unsigned long)unpack_buffer);
		LoadTIM((unsigned long)unpack_buffer,NO_VX,NO_VY);

		PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
	}
}

static void InitSaveSeason()
{
	InitSaveMemCard();
	intro_status=INTRO_SAVE_SEASON;
}




unsigned long ReadBits(unsigned char* byte_pointer,long byte,long bit,long bit_size)
{
   unsigned long value,peepster;

   value = 0;
   peepster = 0;
   while(bit_size)
   {
      if(byte_pointer[byte] & (1<<bit)) value |= (1<<peepster);
      bit_size--;
      peepster++;
      bit++;
      if(bit==8)
      {
         bit = 0;
         byte++;
      }
   }

   return(value);
}


unsigned long WriteBits(unsigned char* byte_pointer,long byte,long bit,long bit_size,unsigned long value)
{
   unsigned long peepster;

   peepster = 0;
   while(bit_size)
   {
      if(value & (1<<peepster)) byte_pointer[byte] |= (1<<bit);
      else byte_pointer[byte] &= ~(1<<bit);
      bit_size--;
      peepster++;
      bit++;
      if(bit==8)
      {
         bit = 0;
         byte++;
      }
   }

   return(value);
}


void CodePassword(FRONT_END* front,PLAYER* player,unsigned char* pass)
{
   unsigned char i,check_sum;

   check_sum = 0;
   check_sum += WriteBits(pass,BB_CHARACTER,player->character_index);
   check_sum += WriteBits(pass,BB_CASH,player->cash/5);
   check_sum += WriteBits(pass,BB_GATE_POINTS,player->gate_points);
   check_sum += WriteBits(pass,BB_RACE_INDEX,front->race);
   check_sum += WriteBits(pass,BB_DIFFICULTY,front->difficulty);
   check_sum += WriteBits(pass,BB_RACE_RESULT,player->race_result);
   check_sum += WriteBits(pass,BB_MOUNTAIN_BIKE,player->mountain_bike);
   check_sum += WriteBits(pass,BB_SKATE_BOARD,player->skate_board);
   check_sum += WriteBits(pass,BB_INLINE_SKATES,player->inline_skates);
   check_sum += WriteBits(pass,BB_STREET_LUGE,player->street_luge);
   check_sum += WriteBits(pass,BB_SEED,player->seed);


   check_sum += 15;
   check_sum %= 32;

   WriteBits(pass,BB_CHECK_SUM,check_sum);
}

signed long DecodePassword(FRONT_END* front,PLAYER* player,unsigned char* pass)
{
   unsigned char check_sum;
   int character_index,cash,gate_points,race_result,mountain_bike,skate_board;
   int inline_skates,street_luge,seed,race,difficulty;


   check_sum = 0;

   check_sum += character_index = ReadBits(pass,BB_CHARACTER);
   check_sum += cash = ReadBits(pass,BB_CASH);
   check_sum += gate_points = ReadBits(pass,BB_GATE_POINTS);
   check_sum += race = ReadBits(pass,BB_RACE_INDEX);
   check_sum += difficulty = ReadBits(pass,BB_DIFFICULTY);
   check_sum += race_result = ReadBits(pass,BB_RACE_RESULT);
   check_sum += mountain_bike = ReadBits(pass,BB_MOUNTAIN_BIKE);
   check_sum += skate_board = ReadBits(pass,BB_SKATE_BOARD);
   check_sum += inline_skates = ReadBits(pass,BB_INLINE_SKATES);
   check_sum += street_luge = ReadBits(pass,BB_STREET_LUGE);
   check_sum += seed = ReadBits(pass,BB_SEED);
	cash*=5;

   if((check_sum+15)%32!=ReadBits(pass,BB_CHECK_SUM)) return(0);

   /*Make sure everything is valid*/
	if((mountain_bike>3)||
	   (skate_board>3)||
	   (inline_skates>4)||
	   (street_luge>3)||
	   (race>11))
		return(0);

	player->character_index =character_index;
	player->cash =cash;
	player->gate_points =gate_points;
	player->race_result =race_result;
	player->mountain_bike =mountain_bike;
	player->skate_board =skate_board;
	player->inline_skates =inline_skates;
	player->street_luge =street_luge;
	player->seed =seed;
	front->race =race;
	front->difficulty =difficulty;

   return(1);
}

signed long CompatiblePasswords(unsigned char* pass1,unsigned char* pass2)
{
   if(ReadBits(pass1,BB_RACE_INDEX) != ReadBits(pass2,BB_RACE_INDEX)) return(0);
   if(ReadBits(pass1,BB_DIFFICULTY) != ReadBits(pass2,BB_DIFFICULTY)) return(0);
   if(ReadBits(pass1,BB_SEED) != ReadBits(pass2,BB_SEED)) return(0);
   return(1);
}




#define PASSBACK_W 98
#define PASSBACK_H 180
#define PASS_TOP (105-PASSBACK_H/2)
#define PASS_TMARGIN 30
#define PASS_LMARGIN 30
#define PASS_LEFT (640+160-(PASSBACK_W/2))
#define PASS_LEFT1 (640+100-(PASSBACK_W/2))
#define PASS_LEFT2 (640+80+140-(PASSBACK_W/2))
#define PASS_LENGTH 9
#define PASS_BETWEEN 16
#define PASS_BOX_WIDTH 48
#define PASS_BOX_TMARGIN (PASS_TMARGIN-16)
#define PASS_BOX_LMARGIN (PASS_LMARGIN-3)

#define PASS_SPEED_LEVEL1 10
#define PASS_SPEED_LEVEL2 10





unsigned char password1[PASS_LENGTH] = {0,0,0,0,0,0,0,0,0};
unsigned char password2[PASS_LENGTH] = {0,0,0,0,0,0,0,0,0};
signed long pass_position1;
signed long pass_position2;
signed long pass_hold1;
signed long pass_hold2;
signed long bad_pass1;
signed long bad_pass2;
signed long pass_done1;
signed long pass_done2;

static SPRT peep_sprt1,peep_sprt2;
static DR_MODE peep_mode;


static void DrawPassword()
{
   signed long i;
   unsigned char byte_text[4];

   if(intro_status==INTRO_NEW_PASSWORD) Unpack(NEWPASS1_RLE_A,(unsigned long)unpack_buffer);
   else if(!bad_pass1) Unpack(PASS1_RLE_A,(unsigned long)unpack_buffer);
   else Unpack(BADPASS_RLE_A,(unsigned long)unpack_buffer);
   if(front_end->num_players==ONE_PLAYER)
   {
      LoadTIM((unsigned long)unpack_buffer,PASS_LEFT,PASS_TOP);
      peep_sprt1.x0 = -640+PASS_LEFT+PASS_LMARGIN/4;
      peep_sprt1.y0 = PASS_TOP+PASS_TMARGIN+pass_position1*16;
      for(i=0;i<PASS_LENGTH;i++)
      {
         if(i==pass_position1 && intro_status!=INTRO_NEW_PASSWORD)
         {
            SetFontColor(1);
         }
         NumberToText(byte_text,password1[i],3);
         DrawText(byte_text,3,PASS_LEFT+PASS_LMARGIN,PASS_TOP+PASS_TMARGIN+i*16,0);
         if(i==pass_position1 && intro_status!=INTRO_NEW_PASSWORD)
         {
            SetFontColor(5);
         }
      }
   }
   else
   {
      LoadTIM((unsigned long)unpack_buffer,PASS_LEFT1,PASS_TOP);
      if(intro_status==INTRO_NEW_PASSWORD) Unpack(NEWPASS2_RLE_A,(unsigned long)unpack_buffer);
      else if(!bad_pass2) Unpack(PASS2_RLE_A,(unsigned long)unpack_buffer);
      else Unpack(BADPASS_RLE_A,(unsigned long)unpack_buffer);
      LoadTIM((unsigned long)unpack_buffer,PASS_LEFT2,PASS_TOP);
      peep_sprt1.x0 = -640+PASS_LEFT1+PASS_LMARGIN/4;
      peep_sprt1.y0 = PASS_TOP+PASS_TMARGIN+pass_position1*16;
      peep_sprt2.x0 = -640+PASS_LEFT2+PASS_LMARGIN/4;
      peep_sprt2.y0 = PASS_TOP+PASS_TMARGIN+pass_position2*16;
      for(i=0;i<PASS_LENGTH;i++)
      {
         if(i==pass_position1 && intro_status!=INTRO_NEW_PASSWORD && !pass_done1)
         {
            SetFontColor(1);
         }
         NumberToText(byte_text,password1[i],3);
         DrawText(byte_text,3,PASS_LEFT1+PASS_LMARGIN,PASS_TOP+PASS_TMARGIN+i*PASS_BETWEEN,0);
         if(i==pass_position1 && intro_status!=INTRO_NEW_PASSWORD && !pass_done1)
         {
            SetFontColor(5);
         }
         if(i==pass_position2 && intro_status!=INTRO_NEW_PASSWORD && !pass_done2)
         {
            SetFontColor(1);
         }
         NumberToText(byte_text,password2[i],3);
         DrawText(byte_text,3,PASS_LEFT2+PASS_LMARGIN,PASS_TOP+PASS_TMARGIN+i*PASS_BETWEEN,0);
         if(i==pass_position2 && intro_status!=INTRO_NEW_PASSWORD && !pass_done2)
         {
            SetFontColor(5);
         }
      }
   }

   if(intro_status!=INTRO_NEW_PASSWORD)
   {
      if(!pass_done1) AddPrim(ordering_table,&peep_sprt1);
      if(!pass_done2 && front_end->num_players==TWO_PLAYER) AddPrim(ordering_table,&peep_sprt2);
      if(!pass_done1 || !pass_done2) AddPrim(ordering_table,&peep_mode);
   }

}




static void StartPassword()
{
	InitFont(FONT2_FNT_A,FONT2_CLT_A);
	SetFontColor(5);

	pass_done1 = 0;
   pass_done2 = 0;
   pass_position1 = pass_hold1 = 0;
   pass_position2 = pass_hold2 = 0;

   bad_pass1 = 0;
   bad_pass2 = 0;

   ClearImage(&clear,0,0,0);
   Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

   Unpack(PASSPEEP_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,240);
   SetSprt(&peep_sprt1);
   peep_sprt1.u0 = 0;
   peep_sprt1.v0 = 240;
   peep_sprt1.w = 23;
   peep_sprt1.h = 16;
   setRGB0(&peep_sprt1,255,255,255);
   SetSprt(&peep_sprt2);
   peep_sprt2.u0 = 0;
   peep_sprt2.v0 = 240;
   peep_sprt2.w = 23;
   peep_sprt2.h = 16;
   setRGB0(&peep_sprt2,255,255,255);
   SetDrawMode(&peep_mode,0,0,GetTPage(2,3,640,0),0);

   DrawPassword();
}




static void EnterPassword(unsigned char* password,signed long* byte,signed long player_flag,signed long* pass_hold)
{
   unsigned char byte_text[4];
   unsigned long tap,joy;
   RECT rect = {0,0,48,16};


   if(player_flag==0 || player_flag==1)
   {
      tap = tappad0;
      joy = joypad0;
   }
   else
   {
      tap = tappad1;
      joy = joypad1;
   }

   if(tap)
   {
      if(player_flag==2) bad_pass2 = 0;
      else bad_pass1 = 0;
   }

   if(tap & PADLup)
   {
      (*byte)--;
   }
   else if(tap & PADLdown)
   {
      (*byte)++;
   }
   if(*byte==PASS_LENGTH) *byte=0;
   else if(*byte<0) *byte = PASS_LENGTH-1;

   if(tap & (PADLleft|PADRup|PADRleft)) password[*byte]--;
   else if(tap & (PADLright|PADRdown|PADRright)) password[*byte]++;

   if(joy&((PADLleft|PADRup|PADRleft)|(PADLright|PADRdown|PADRright))) (*pass_hold)++;
   else *pass_hold  = 0;

   if(*pass_hold >= PASS_SPEED_LEVEL2)
   {
      if(joy&(PADLleft|PADRup|PADRleft)) password[*byte]-=5;
      if(joy&(PADLright|PADRdown|PADRright)) password[*byte]+=5;
      *pass_hold = PASS_SPEED_LEVEL2;
      tap = 1;
   }
   else if(*pass_hold >= PASS_SPEED_LEVEL1)
   {
      if(joy&(PADLleft|PADRup|PADRleft)) password[*byte]-=1;
      if(joy&(PADLright|PADRdown|PADRright)) password[*byte]+=1;
      tap = 1;
   }
}











#define TIME_OUT 30*30

void LoadDoors()
{
	Unpack(LEFT1_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,LEFT_DOOR_VX,LEFT_DOOR_VY);
	Unpack(RIGHT1_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,RIGHT_DOOR_VX,RIGHT_DOOR_VY);
}

/* closure:
		0 is closed.
		160 is open*/
void DrawDoors(signed long closure)
{
   if(closure!=160) DisplayBitmap(0,0,LEFT_DOOR_VX+closure,LEFT_DOOR_VY,DOOR_VW-closure+1,DOOR_VH+1,2,0);
   DisplayBitmap(160+closure,0,RIGHT_DOOR_VX,RIGHT_DOOR_VY,DOOR_VW-closure+1,DOOR_VH+1,2,0);
}


#define STARTING_CASH 300

void ResetStandings()
{
   front_end->race = 0;

   if(front_end->season_mode==NEW_SEASON)
	{
		front_end->player1.cash = STARTING_CASH;
		front_end->player1.inline_skates = 0;
   	front_end->player1.mountain_bike = 0;
   	front_end->player1.street_luge = 0;
   	front_end->player1.skate_board = 0;
	}

   front_end->player1.gate_points = 0;
   front_end->player1.race_result = 0;

   if(front_end->season_mode==NEW_SEASON)
	{
		front_end->player2.cash = STARTING_CASH;
		front_end->player2.inline_skates = 0;
 	  	front_end->player2.mountain_bike = 0;
	   front_end->player2.street_luge = 0;
	   front_end->player2.skate_board = 0;
	}

   front_end->player2.gate_points = 0;
   front_end->player2.race_result = 0;
}


void InitDefaults()
{
	front_end->use_mountain_bike = 1;
	front_end->use_street_luge = 1;
	front_end->use_skate_board = 1;
	front_end->use_inline_skates = 1;

	extreme_scores->high_scores[SAN_FRANCISCO] = 1000;
	extreme_scores->high_scores[ROME] = 2000;
	extreme_scores->high_scores[SOUTH_AMERICA] = 3000;
	extreme_scores->high_scores[UTAH] = 4000;
	extreme_scores->high_scores[LAKE_TAHOE] = 5000;

	strncpy(extreme_scores->high_initials[SAN_FRANCISCO],"AAA",3);
	strncpy(extreme_scores->high_initials[ROME],"BBB",3);
	strncpy(extreme_scores->high_initials[SOUTH_AMERICA],"CCC",3);
	strncpy(extreme_scores->high_initials[UTAH],"DDD",3);
	strncpy(extreme_scores->high_initials[LAKE_TAHOE],"EEE",3);

	front_end->course = SAN_FRANCISCO;
   front_end->num_players = ONE_PLAYER;
   front_end->difficulty = MEDIUM;
   front_end->season_mode = EXIBITION;
   front_end->race = 0;
   front_end->music_volume = MAX_MUSIC_VOLUME/2;
   front_end->sound_volume = MAX_SOUND_VOLUME/2;
   front_end->video = 1;
	front_end->use_ram_card = 0;

   SetSoundVol(front_end->sound_volume);


   front_end->player1.character_index = 0;
   front_end->player1.vehicle = INLINE_SKATES;
   front_end->player1.cash = 300;
   front_end->player1.gate_points = 0;
   front_end->player1.race_result = 0;
   front_end->player1.seed = 0;
   front_end->player1.inline_skates = 0;
   front_end->player1.mountain_bike = 0;
   front_end->player1.street_luge = 0;
   front_end->player1.skate_board = 0;
	front_end->player1.initials[0] = 'A';
	front_end->player1.initials[1] = 'A';
	front_end->player1.initials[2] = 'A';


   front_end->player2.character_index = 1;
   front_end->player2.vehicle = INLINE_SKATES;
   front_end->player2.cash = 0;
   front_end->player2.gate_points = 0;
   front_end->player2.race_result = 0;
   front_end->player2.seed = front_end->player1.seed;
   front_end->player2.inline_skates = 0;
   front_end->player2.mountain_bike = 0;
   front_end->player2.street_luge = 0;
   front_end->player2.skate_board = 0;
	front_end->player2.initials[0] = 'B';
	front_end->player2.initials[1] = 'B';
	front_end->player2.initials[2] = 'B';
}





void InitIntro()
{
	InitLogos();

	front_end->flag = FEF_FRONTEND;

   position_index = 0;
   config_player = &front_end->player1;

	current_choices[0] = &players_rle;
	current_choices[1] = &season_rle;
	current_choices[2] = &difficulty_rle;
   current_choices[3] = &sound_rle;
   current_choices[4] = &music_rle;
	current_choices[5] = &video_rle;


	whites[0] = players_white;
	whites[1] = season_white;
	whites[2] = difficulty_white;
	whites[3] = sound_white;
	whites[4] = music_white;
	whites[5] = video_white;

	yellows[0] = players_yellow;
	yellows[1] = season_yellow;
	yellows[2] = difficulty_yellow;
	yellows[3] = sound_yellow;
	yellows[4] = music_yellow;
	yellows[5] = video_yellow;

	load_booleans[0] = &players_loaded;
	load_booleans[1] = &season_loaded;
	load_booleans[2] = &difficulty_loaded;
	load_booleans[3] = &sound_loaded;
	load_booleans[4] = &music_loaded;
	load_booleans[5] = &video_loaded;

	players_white[0] = ONEPLAY_RLE_A;
	players_white[1] = TWOPLAY_RLE_A;
	players_yellow[0] = YONEPLAY_RLE_A;
	players_yellow[1] = YTWOPLAY_RLE_A;

	season_white[0] = EXHB_RLE_A;
	season_white[1] = CONTSESN_RLE_A;
	season_white[2] = NEWSSN_RLE_A;
	season_yellow[0] = YEXHB_RLE_A;
	season_yellow[1] = YCONTSES_RLE_A;
	season_yellow[2] = YNEWSSN_RLE_A;

	difficulty_white[0]= EASY_RLE_A;
	difficulty_white[1]= MEDIUM_RLE_A;
	difficulty_white[2]= HARD_RLE_A;
	difficulty_white[3]= EXTRM_RLE_A;
	difficulty_yellow[0]= YEASY_RLE_A;
	difficulty_yellow[1]= YMEDIUM_RLE_A;
	difficulty_yellow[2]= YHARD_RLE_A;
	difficulty_yellow[3]= YEXTRM_RLE_A;

   sound_white[1] = SOUNDVOL_RLE_A;
   sound_white[0] = SOUNDVOL_RLE_A;
   sound_yellow[1] = SOUNDVOY_RLE_A;
   sound_yellow[0] = SOUNDVOY_RLE_A;

   music_white[1] = MUSICVOL_RLE_A;
   music_white[0] = MUSICVOL_RLE_A;
   music_yellow[1] = MUSICVOY_RLE_A;
   music_yellow[0] = MUSICVOY_RLE_A;

   video_white[1] = VIDON_RLE_A;
   video_white[0] = VIDOFF_RLE_A;
   video_yellow[1] = YVIDON_RLE_A;
   video_yellow[0] = YVIDOFF_RLE_A;


	intro_status = INTRO_SIGNIN;

	ClearImage(&clear,0,0,0);

   players_rle = front_end->num_players;
   season_rle = front_end->season_mode;
   difficulty_rle = front_end->difficulty;
   if(front_end->music_volume) music_rle = 1;
   else music_rle = 0;
   if(front_end->sound_volume) sound_rle = 1;
   else sound_rle = 0;
   video_rle = front_end->video;

	players_loaded = 0;
	season_loaded = 0;
	difficulty_loaded = 0;
	music_loaded = 0;
	sound_loaded = 0;
	video_loaded = 0;

	Unpack(SETTINGS_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,20);

   Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);


}

#define INITIALS_SX1 136
#define INITIALS_SX2 152
#define INITIALS_SX3 168

#define INITIALS_SY1 90
#define INITIALS_SY2 150
#define INITIALS_SYC 120
#define UNDERLINE_SY1 94
#define UNDERLINE_SY2 154
#define UNDERLINE_SYC 124


#define UNDERLINE '_'

unsigned short initials_x[3] = {INITIALS_SX1,INITIALS_SX2,INITIALS_SX3};
unsigned short initials_index1,initials_index2;
signed long initials_done1,initials_done2;

void InitNewHighScore()
{
	InitFont(FONT2_FNT_A,FONT2_CLT_A);
	SetFontColor(5);
   ClearImage(&clear,0,0,0);


	initials_index1 = 0;
	initials_done1 = 0;
	initials_done2 = 1;
	if(front_end->new_high_player==ONE_PLAYER)
   {
      Unpack(YEL1_RLE_A,(unsigned long)unpack_buffer);
      LoadTIM((unsigned long)unpack_buffer,640+160-75,120-25);
   }
   else
   {
      Unpack(YEL2_RLE_A,(unsigned long)unpack_buffer);
      LoadTIM((unsigned long)unpack_buffer,640+160-75,120-25);
   }

	if(front_end->new_high_player==ONE_PLAYER)
	{
		Unpack(NEWHIGH1_RLE_A,(unsigned long)unpack_buffer);
	}
	else Unpack(NEWHIGH2_RLE_A,(unsigned long)unpack_buffer);

   LoadTIM((unsigned long)unpack_buffer,640,20);

	Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

	intro_status = INTRO_HIGH_INITIALS;
}

void InitShowHighScores()
{
	signed long i;
	unsigned char number[8];
	signed long number_length;


	InitFont(FONT1_FNT_A,FONT1_CLT_A);
	SetFontColor(WHITE_ON_BLACK);
   ClearImage(&clear,0,0,0);

	Unpack(HIGH_RLE_A,(unsigned long)unpack_buffer);
	LoadTIM((unsigned long)unpack_buffer,640+160-128,120-64);

	Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

	for(i=0;i<NUM_COURSES;i++)
	{
		if(front_end->new_high_score && i==front_end->new_high_course) SetFontColor(YELLOW_ON_BLACK);
		DrawText(course_names[i],16,640+160-120,i*16+120-24,1);
		DrawText(extreme_scores->high_initials[i],3,640+160,i*16+120-24,0);
		number_length = NumberToText(number,extreme_scores->high_scores[i],0);
		DrawTextBackward(number,number_length,640+160+120,i*16+120-24,1);
		if(front_end->new_high_score && i==front_end->new_high_course) SetFontColor(WHITE_ON_BLACK);
	}
	intro_status = INTRO_HIGH_SCORES;
}


void InitNewPassword()
{
	if(front_end->season_mode==EXIBITION)
	{
		InitIntro();
	}
	else
	{
		InitFont(FONT2_FNT_A,FONT2_CLT_A);
		SetFontColor(5);
	   ClearImage(&clear,0,0,0);
	   intro_status = INTRO_NEW_PASSWORD;
	   CodePassword(front_end,&front_end->player1,password1);
	   CodePassword(front_end,&front_end->player2,password2);
	   Unpack(START_RLE_A,(unsigned long)unpack_buffer);
	   LoadTIM((unsigned long)unpack_buffer,640,202);
	   DrawPassword();
		intro_status = INTRO_NEW_PASSWORD;
	}
}







void IntroDone()
{
	if(front_end->season_mode!=EXIBITION)
	{
		front_end->use_mountain_bike = 1;
		front_end->use_street_luge = 1;
		front_end->use_skate_board = 1;
		front_end->use_inline_skates = 1;
	}
	Unpack(MAIN_RLE_A,(unsigned long)unpack_buffer);
   SetBackground((unsigned long)unpack_buffer,255,255,255);
   BGCourse();
   Unpack(DOORMB1_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,320+224,0+40);
   intro_status = INTRO_OPEN_DOORS;
   PlaySound(SND_GATEOPEN,0,0x3FFF,0x3FFF);
   door_closure = 0;
   if(front_end->season_mode!=CONTINUE_SEASON)
   {
      front_end->player1.seed = front_end->player2.seed = (~(0xFF<<3))&rand();
   }

	if(front_end->season_mode==EXIBITION)
	{
		front_end->use_ram_card = 0;
	}
}

void StartFrontEnd()
{
	players_rle = front_end->num_players;
   season_rle = front_end->season_mode;
   difficulty_rle = front_end->difficulty;
   if(front_end->music_volume) music_rle = 1;
   else music_rle = 0;
   if(front_end->sound_volume) sound_rle = 1;
   else sound_rle = 0;
   video_rle = front_end->video;

	SetSoundVol(front_end->sound_volume);

	door_closure =  160;
   intro_status = INTRO_START;
	InitFont(FONT2_FNT_A,FONT2_CLT_A);
	SetFontColor(5);
	InitLogos();
}




signed long Initials(unsigned char* initials)
{
   unsigned short i;
   unsigned short offx,offy;
   unsigned short underline_sy,initials_sy,initials_index;
   unsigned long tappad;
   signed long initials_done;


   offx = current_drawenv->ofs[0];
   offy = current_drawenv->ofs[1];

   if(front_end->num_players==ONE_PLAYER || intro_status==INTRO_HIGH_INITIALS)
   {
      underline_sy = UNDERLINE_SYC;
      initials_sy = INITIALS_SYC;
      tappad = tappad0;
      initials_index = initials_index1;
      initials_done = initials_done1;
		if(intro_status==INTRO_HIGH_INITIALS && front_end->new_high_player==TWO_PLAYER)
		{
			tappad = tappad1;
		}
   }
   else
   {
      if(initials == front_end->player1.initials)
      {
         underline_sy = UNDERLINE_SY1;
         initials_sy = INITIALS_SY1;
         tappad = tappad0;
         initials_index = initials_index1;
         initials_done = initials_done1;
      }
      else
      {
         underline_sy = UNDERLINE_SY2;
         initials_sy = INITIALS_SY2;
         tappad = tappad1;
         initials_index = initials_index2;
         initials_done = initials_done2;
      }
   }



   if(!initials_done)
   {
      if(tappad & PADLleft)
      {
         initials_index+=2;
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
      }
      if(tappad & PADLright)
      {
         initials_index++;
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
      }
      initials_index %= 3;

      if(initials[initials_index]==' ')
      {
         if(tappad & (PADRup|PADRleft))
         {
            initials[initials_index]='Z';
            PlaySound(SND_SWITCH1,CH_SWITCH1,0x1FFF,0x1FFF);
         }
         if(tappad & (PADRdown|PADRright))
         {
            initials[initials_index]='A';
            PlaySound(SND_SWITCH1,CH_SWITCH1,0x1FFF,0x1FFF);
         }

      }
      else
      {
         if(tappad & (PADRup|PADRleft))
         {
            initials[initials_index]--;
            PlaySound(SND_SWITCH1,CH_SWITCH1,0x1FFF,0x1FFF);
         }
         if(tappad & (PADRdown|PADRright))
         {
            initials[initials_index]++;
            PlaySound(SND_SWITCH1,CH_SWITCH1,0x1FFF,0x1FFF);
         }
         if(initials[initials_index] > 'Z') initials[initials_index] = ' ';
         if(initials[initials_index] < 'A') initials[initials_index] = ' ';
      }

      if((total_time%10)<5) DrawLetter(UNDERLINE,offx+initials_x[initials_index],offy+underline_sy);
      for(i=0;i<3;i++)
      {
         DrawLetter(initials[i],offx+initials_x[i],offy+initials_sy);
      }

		if(intro_status==INTRO_HIGH_INITIALS)
		{
			initials_index1 = initials_index;
		}
		else
		{

	      if(initials==front_end->player1.initials)
	      {
	         initials_index1 = initials_index;
	      }
	      else initials_index2 = initials_index;
		}

      if(tappad & PADh)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         return(1);
      }
      else return(0);
   }
   else
   {
      for(i=0;i<3;i++)
      {
         DrawLetter(initials[i],offx+initials_x[i],offy+initials_sy);
      }
      return(0);
   }
}



void StartInitials(signed long already)
{
   intro_status = INTRO_INITIALS;
   start_select = 0;

   initials_index1 = 0;
   initials_index2 = 0;
   ClearImage(&clear,0,0,0);

	InitFont(FONT2_FNT_A,FONT2_CLT_A);
	SetFontColor(5);

	Unpack(INITIALS_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,20);

   Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

   initials_done1 = 0;
   if(front_end->num_players==ONE_PLAYER)
   {
      initials_done2 = 1;
      if(already) Unpack(CHOSEN_RLE_A,(unsigned long)unpack_buffer);
      else Unpack(YEL1_RLE_A,(unsigned long)unpack_buffer);
      LoadTIM((unsigned long)unpack_buffer,640+160-75,120-25);
   }
   else
   {
      initials_done2 = 0;
      if(already) Unpack(CHOSEN_RLE_A,(unsigned long)unpack_buffer);
      else Unpack(YEL1_RLE_A,(unsigned long)unpack_buffer);
      LoadTIM((unsigned long)unpack_buffer,640+160-75,120-55);

      if(already&&0) Unpack(CHOSEN_RLE_A,(unsigned long)unpack_buffer);
      else Unpack(YEL2_RLE_A,(unsigned long)unpack_buffer);
      LoadTIM((unsigned long)unpack_buffer,640+160-75,120+5);
   }

}
#define SEASLIST_VX (640-(196/2)+160)
#define SEASLIST_VY ((-128/2)+120)
#define FILES_VX (SEASLIST_VX+20)
#define FILES_VY (SEASLIST_VY+30)
#define FILES_HEIGHT 16

struct DIRENTRY season_files[MAX_SEASON_FILES];
signed long num_season_files;
signed long season_selected;


void DrawSeasonFiles()
{
   signed short t,x;
   unsigned char* file_name;


   for(t=0;t<num_season_files;t++)
   {
      if(t==season_selected) SetFontColor(1);

      file_name = season_files[t].name+SEASON_FILE_PREFIX_LENGTH;
      x = DrawLetter(49+t,FILES_VX,FILES_VY+t*FILES_HEIGHT);
      x = DrawText(".   ",4,x,FILES_VY+t*FILES_HEIGHT,1);
      DrawText(file_name,strlen(file_name),x,FILES_VY+t*FILES_HEIGHT,1);

      if(t==season_selected) SetFontColor(5);
   }
}

signed long CreateSeasonFile(signed long write,signed long just_checking)
{
   unsigned char full_name[128];
	signed long i;

	for(i=0;i<128;i++) full_name[i] = 0;

   strncpy(full_name,SEASON_FILE_PREFIX,SEASON_FILE_PREFIX_LENGTH);
   strncat(full_name,front_end->player1.initials,3);
   /*if(front_end->num_players==TWO_PLAYER)
   {
      strcat(full_name,"&");
      strncat(full_name,front_end->player2.initials,3);
   } */
	full_name[15] = 0;

   if(RAMCardFileExists(full_name,RAM_CARD_CHANNEL)) return(0);
   else if(!just_checking)
   {
      if(CreateRAMCardFile(full_name,RAM_CARD_CHANNEL))
		{
			if(write)
			{
				if(WriteRAMCardFile(full_name,RAM_CARD_CHANNEL,
										  CARDICON_CLT_A,CARDICON_BIT_A,
										  (unsigned char*)front_end,FRONT_END_SIZE,0))
				{
					return(1);
				}
				else return(-1);
			}
			else return(1);
		}
		else return(-1);
	}
	else return(1);
}


void StartReplaceSeason()
{
   ClearImage(&clear,0,0,0);

   Unpack(REPLACE_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,20);

   Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

   Unpack(SEASONS_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,SEASLIST_VX,SEASLIST_VY);

   DrawSeasonFiles();

   intro_status = INTRO_REPLACE_SEASON;
}


void StartChooseSeason()
{
   ClearImage(&clear,0,0,0);

   Unpack(CHOSSSN_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,20);

   Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

   Unpack(SEASONS_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,SEASLIST_VX,SEASLIST_VY);

   DrawSeasonFiles();

   intro_status = INTRO_CHOOSE_SEASON;

	InitFont(FONT2_FNT_A,FONT2_CLT_A);
	SetFontColor(5);
}


void StartRAMCardError(unsigned char* message)
{
   intro_status = INTRO_ERROR;

   ClearImage(&clear,0,0,0);

   Unpack(RAMCARD_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,SEASLIST_VX,SEASLIST_VY);

   Unpack(START_RLE_A,(unsigned long)unpack_buffer);
   LoadTIM((unsigned long)unpack_buffer,640,202);

   DrawText(message,strlen(message),FILES_VX,FILES_VY+32,1);

	PlaySound(SND_GUITARDOWN,CH_GUITARDOWN,0x1FFF,0x1FFF);
}



void DoIntro()
{
	unsigned long i;
   signed long max_season_selected;
   unsigned long compute;
	unsigned char full_name[128];
	signed long bool;
	signed long old_music_volume,old_sound_volume,old_video;


   if(intro_status!=INTRO_OPEN_DOORS && intro_status!=INTRO_CLOSE_DOORS && intro_status!=INTRO_START && intro_status!=INTRO_RESTART)
   {
      DrawDoors(0);
      DisplayBitmap(0,0,640,0,65,220,1,1);
      DisplayBitmap(64,0,640+64,0,65,220,1,1);
      DisplayBitmap(128,0,640+128,0,65,220,1,1);
		DisplayBitmap(128+64,0,640+128+64,0,128,220,1,1);
   }

   if(intro_status==INTRO_SIGNIN
		/*intro_status==INTRO_CHOOSE_SEASON &&
		intro_status!=INTRO_GET_PASSWORD &&
		intro_status!=INTRO_REPLACE_SEASON &&
		intro_status!=INTRO_REPLACE_WAIT &&
		intro_status!=INTRO_ERROR &&
		intro_status!=INTRO_INITIALS &&
		intro_status!=INTRO_NEW_SEASON &&
		intro_status!=INTRO_CONTINUE_SEASON &&
		intro_status!=INTRO_NEW_PASSWORD &&
		intro_status!=INTRO_START &&
		intro_status!=INTRO_CLOSE_DOORS*/)
   {
      for(i=0;i<NUM_POSITIONS;i++)
      {
         if(!(*load_booleans[i]))
         {
            if(position_index==i)
            {
               Unpack(yellows[i][*current_choices[i]],(unsigned long)unpack_buffer);
            }
            else
            {
               Unpack(whites[i][*current_choices[i]],(unsigned long)unpack_buffer);
            }
            LoadTIM((unsigned long)unpack_buffer,640+85,positions[i]);
            *load_booleans[i] = 1;
         }
      }

      Unpack(SLIDER_RLE_A,(unsigned long)unpack_buffer);
      compute = front_end->sound_volume;
      compute <<= 16;
      compute /= MAX_SOUND_VOLUME;
      compute *= SLIDER_MAX_X-SLIDER_MIN_X;
      compute >>= 16;
      compute += SLIDER_MIN_X;
      LoadTIM((unsigned long)unpack_buffer,compute,SOUND_SLIDER_Y);
      compute = front_end->music_volume;
      compute <<= 16;
      compute /= MAX_MUSIC_VOLUME;
      compute *= SLIDER_MAX_X-SLIDER_MIN_X;
      compute >>= 16;
      compute += SLIDER_MIN_X;
      LoadTIM((unsigned long)unpack_buffer,compute,MUSIC_SLIDER_Y);

   }


	if(!doors_loaded)
	{
		LoadDoors();
		doors_loaded = 1;
	}
	if(intro_status==INTRO_SIGNIN)
	{
		if(bothtap & PADh)
		{
			PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
			if(front_end->season_mode==CONTINUE_SEASON)
         {
				InitUseMemCard();
            intro_status = INTRO_CONTINUE_SEASON;
         }
			else if(front_end->season_mode==NEW_SEASON)
			{
				intro_status = INTRO_NEW_SEASON;
				InitUseMemCard();
			}
			else
			{
				ResetStandings();
				SetupFrontEnd();
				IntroDone();
			}
		}
		else if(bothtap & PADLup)
		{
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         *load_booleans[position_index] = 0;
			position_index--;
         if(position_index<0) position_index=NUM_POSITIONS-1;
			*load_booleans[position_index] = 0;
		}
		else if(bothtap & PADLdown)
		{
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
			*load_booleans[position_index] = 0;
			position_index++;
         if(position_index==NUM_POSITIONS) position_index = 0;
			*load_booleans[position_index] = 0;
		}
      else if(bothtap & (PADLright|PADRright|PADRdown|PADRleft|PADRup) && position_index!=3 && position_index!=4)
		{
         PlaySound(SND_SWITCH1,CH_SWITCH1,0x1FFF,0x1FFF);

         *current_choices[position_index] += 1;
         *current_choices[position_index] %= num_choices[position_index];
         *load_booleans[position_index] = 0;
      }
		else if(bothtap & (PADLleft) && position_index!=3 && position_index!=4)
		{
			PlaySound(SND_SWITCH1,CH_SWITCH1,0x1FFF,0x1FFF);
			if(*current_choices[position_index]==0)
			{
				*current_choices[position_index] = num_choices[position_index]-1;
			}
			else *current_choices[position_index] -= 1;
			*load_booleans[position_index] = 0;
		}

      else if(position_index==3)
      {
         if(bothtap & (PADRright|PADRdown|PADRleft|PADRup))
         {
            PlaySound(SND_GUITAR,CH_GUITAR,0x1FFF,0x1FFF);
         }
         else if(bothjoy & PADLleft && front_end->sound_volume>0)
         {
            if(front_end->sound_volume > SLIDER_MOVE) front_end->sound_volume-=SLIDER_MOVE;
            else front_end->sound_volume = 0;
            *load_booleans[position_index] = 0;
            SetSoundVol(front_end->sound_volume);
				SetPan(CH_GUITAR,0x1FFF,0x1FFF);
         }
         else if(bothjoy & PADLright && front_end->sound_volume < MAX_SOUND_VOLUME)
         {
            if(front_end->sound_volume < MAX_SOUND_VOLUME-SLIDER_MOVE) front_end->sound_volume+=SLIDER_MOVE;
            else front_end->sound_volume = MAX_SOUND_VOLUME;
            *load_booleans[position_index] = 0;
            SetSoundVol(front_end->sound_volume);
				SetPan(CH_GUITAR,0x1FFF,0x1FFF);
         }
      }
      else if(position_index==4)
      {
			compute = MAX_SOUND_VOLUME<<16;
			compute /= MAX_MUSIC_VOLUME;
			compute *= front_end->music_volume;
			compute >>= 16;
			SetSoundVol(compute);
			if(bothtap & (PADRright|PADRdown|PADRleft|PADRup))
         {
				PlaySound(SND_MUSICTEST,CH_MUSICTEST,0x3FFF,0x3FFF);
         }
         else if(bothjoy & PADLleft && front_end->music_volume>0)
         {
            if(front_end->music_volume > SLIDER_MOVE/2) front_end->music_volume-=SLIDER_MOVE/2;
            else front_end->music_volume = 0;
            *load_booleans[position_index] = 0;
				compute = MAX_SOUND_VOLUME<<16;
				compute /= MAX_MUSIC_VOLUME;
				compute *= front_end->music_volume;
				compute >>= 16;
				SetSoundVol(compute);
				SetPan(CH_MUSICTEST,0x3FFF,0x3FFF);
         }
         else if(bothjoy & PADLright && front_end->music_volume < MAX_MUSIC_VOLUME)
         {
            if(front_end->music_volume < MAX_MUSIC_VOLUME-SLIDER_MOVE/2) front_end->music_volume+=SLIDER_MOVE/2;
            else front_end->music_volume = MAX_MUSIC_VOLUME;
            *load_booleans[position_index] = 0;
				compute = MAX_SOUND_VOLUME<<16;
				compute /= MAX_MUSIC_VOLUME;
				compute *= front_end->music_volume;
				compute >>= 16;
				SetSoundVol(compute);
				SetPan(CH_MUSICTEST,0x3FFF,0x3FFF);
         }

			SetSoundVol(front_end->sound_volume);
      }
   }
	else if(intro_status==INTRO_SAVE_SEASON)
	{
		if(front_end->flag==FEF_SEASONDONE)
		{
			front_end->flag=FEF_FRONTEND;
			InitIntro();
		}
		else
		{
			#if RAM_CARD_WORKS
			YesOrNo();
			if(bothtap & PADh)
			{
				PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
				if(yes_or_no)
				{
					if(!RAMCardPresent(RAM_CARD_CHANNEL))
					{
						StartRAMCardError("Card not found.");
						intro_status = INTRO_SAVE_ERROR;
					}
					else if(!RAMCardFormatted(RAM_CARD_CHANNEL))
					{
						StartRAMCardError("Not formatted.");
/*						intro_status = INTRO_SAVE_ERROR;*/
						saving_season = 1;
						intro_status = INTRO_FORMAT_ERROR;
					}
					else
					{
						strcpy(full_name,SEASON_FILE_PREFIX);
		   			strncat(full_name,front_end->player1.initials,3);
		   			/*if(front_end->num_players==TWO_PLAYER)
		   			{
		      			strcat(full_name,"&");
		      			strncat(full_name,front_end->player2.initials,3);
		   			} */
						full_name[15] = 0;

						CreateRAMCardFile(full_name,RAM_CARD_CHANNEL);
						if(WriteRAMCardFile(full_name,RAM_CARD_CHANNEL,
											  	  CARDICON_CLT_A,CARDICON_BIT_A,
												  (unsigned char*)front_end,FRONT_END_SIZE,0))
						{
							InitNewPassword();
						}
						else
						{
							StartRAMCardError("Write failed.");
							intro_status = INTRO_SAVE_ERROR;
						}
					}
				}
				else
				{
					InitNewPassword();
				}
			}
			#else
			InitNewPassword();
			#endif
		}
	}
	else if(intro_status==INTRO_NEW_SEASON)
	{
		#if RAM_CARD_WORKS
		YesOrNo();
		if(bothtap & PADk)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         InitIntro();
         intro_status = INTRO_SIGNIN;
      }
		else if(bothtap & PADh)
		{
			PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
			if(!yes_or_no)
			{
				front_end->use_ram_card = 0;
				ResetStandings();
				SetupFrontEnd();
				IntroDone();
			}
			else
			{
				if(!RAMCardPresent(RAM_CARD_CHANNEL))
				{
					StartRAMCardError("Card not found.");
				}
				else if(!RAMCardFormatted(RAM_CARD_CHANNEL))
				{
					StartRAMCardError("Not formatted.");
					intro_status = INTRO_FORMAT_ERROR;
				}
				else
				{
					StartInitials(0);
					front_end->use_ram_card = 1;
				}
			}
		}
		#else
		front_end->use_ram_card = 0;
		ResetStandings();
		SetupFrontEnd();
		IntroDone();
		#endif
	}
	else if(intro_status==INTRO_FORMAT)
	{
		YesOrNo();
		if(bothtap & PADh)
		{
			PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
			if(yes_or_no) InitVerify();
			else
			{
		     	intro_status = INTRO_SIGNIN;
         	InitIntro();
			}
		}
	}
	else if(intro_status==INTRO_FORMAT_ERROR)
   {
      if(bothtap & PADh)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
			InitFormatCard();
      }
   }
	else if(intro_status==INTRO_VERIFY)
	{
		YesOrNo();
		if(bothtap&PADh)
		{
			PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);

			if(yes_or_no)
			{
				FormatRAMCard(RAM_CARD_CHANNEL);
			}
			if(saving_season)
			{
				saving_season=0;
				InitSaveSeason();
			}
			else
			{
				intro_status = INTRO_SIGNIN;
         		InitIntro();
			}
		}
	}
	else if(intro_status==INTRO_ERROR)
   {
      if(bothtap & PADh)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         intro_status = INTRO_SIGNIN;
         InitIntro();
      }
   }
	else if(intro_status==INTRO_SAVE_ERROR)
   {
      if(bothtap & PADh)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
			InitSaveSeason();
      }
   }
	else if(intro_status==INTRO_OPEN_DOORS)
	{
		DrawDoors(door_closure);
		door_closure += DOOR_SPEED;
		if(door_closure==160)
		{
			intro_status = INTRO_GO_MAIN;
			doors_loaded = 0;
		}
	}
   else if(intro_status==INTRO_CLOSE_DOORS || intro_status==INTRO_START || intro_status==INTRO_RESTART)
	{
      if(intro_status==INTRO_START && door_closure==160-3*12) PlaySound(SND_GATECLOSE,CH_GATECLOSE,0x3FFF,0x3FFF);
      if(intro_status==INTRO_START) door_closure -= DOOR_SPEED/2;
      else door_closure -= DOOR_SPEED;

		if(intro_status==INTRO_RESTART && door_closure==160-1*12) PlaySound(SND_GATECLOSE,CH_GATECLOSE,0x3FFF,0x3FFF);

		DrawDoors(door_closure);
		if(door_closure==0)
		{
         if(intro_status==INTRO_START || intro_status==INTRO_RESTART)
         {
				InitObjectSystem();
				if(intro_status==INTRO_RESTART)
				{
					if((!front_end->use_ram_card || front_end->season_mode==EXIBITION) && front_end->new_high_score)
					{
						InitNewHighScore();
					}
					else InitShowHighScores();
				}
            else
				{
					InitIntro();
				}
         }
         else InitIntro();
		}
	}
	else if(intro_status==INTRO_HIGH_INITIALS)
	{
		if(front_end->new_high_player==ONE_PLAYER)
		{
			if(Initials(front_end->player1.initials))
      	{
				extreme_scores->high_initials[front_end->new_high_course][0] = front_end->player1.initials[0];
				extreme_scores->high_initials[front_end->new_high_course][1] = front_end->player1.initials[1];
				extreme_scores->high_initials[front_end->new_high_course][2] = front_end->player1.initials[2];
				InitShowHighScores();
			}
		}
		else
		{
			if(Initials(front_end->player2.initials))
      	{
				extreme_scores->high_initials[front_end->new_high_course][0] = front_end->player2.initials[0];
				extreme_scores->high_initials[front_end->new_high_course][1] = front_end->player2.initials[1];
				extreme_scores->high_initials[front_end->new_high_course][2] = front_end->player2.initials[2];
				InitShowHighScores();
			}
		}
	}
	else if(intro_status==INTRO_HIGH_SCORES)
	{

		if(bothtap & PADh)
		{
			PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
			if(front_end->new_high_score)
			{
				#if RAM_CARD_WORKS
				if(RAMCardPresent(RAM_CARD_CHANNEL))
				{
					if(RAMCardFormatted(RAM_CARD_CHANNEL))
					{
                  if(!RAMCardFileExists("BISIPS-60004",RAM_CARD_CHANNEL))
						{
                     CreateRAMCardFile("BISIPS-60004",RAM_CARD_CHANNEL);
						}
                  WriteRAMCardFile("BISIPS-60004",RAM_CARD_CHANNEL,
											CARDICON_CLT_A,CARDICON_BIT_A,
											(unsigned char*)extreme_scores,sizeof(EXTREME_SCORES),
											"High Scores");
					}
				}
				#endif
			}

			if(front_end->season_mode!=EXIBITION && front_end->use_ram_card && front_end->flag!=FEF_SEASONDONE)
			{
				InitSaveSeason();
			}
			else
			{
				if(front_end->flag==FEF_SEASONDONE)
				{
					InitIntro();
					front_end->flag=FEF_FRONTEND;
				}
				else InitNewPassword();
			}
		}
	}
   else if(intro_status==INTRO_NEW_PASSWORD)
   {

		if(bothtap & PADh)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         InitIntro();
      }

   }
   else if(intro_status==INTRO_GET_PASSWORD)
   {
      StartSelect();

      /* Check for go back */
      if(bothtap & PADk)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         InitIntro();
         intro_status = INTRO_SIGNIN;
      }
      else
      {
         if(front_end->num_players==ONE_PLAYER) EnterPassword(password1,&pass_position1,0,&pass_hold1);
         else
         {
            if(!pass_done1) EnterPassword(password1,&pass_position1,1,&pass_hold1);
            if(!pass_done2) EnterPassword(password2,&pass_position2,2,&pass_hold2);
         }
         DrawPassword();

         if(tappad0 & PADh)
         {
            if(DecodePassword(front_end,&front_end->player1,password1))
            {
               pass_done1 = 1;
               PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
            }
            else
            {
               bad_pass1 = 1;
               PlaySound(SND_GUITARDOWN,CH_GUITARDOWN,0x1FFF,0x1FFF);
            }
         }
         if(tappad1 & PADh)
         {
            if(DecodePassword(front_end,&front_end->player2,password2))
            {
               pass_done2 = 1;
               PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
            }
            else
            {
					if(password2[0]==3 && password2[1]==1 && password2[2]==4 &&
						password2[3]==1 && password2[4]==5 && password2[5]==93 &&
						password2[6]==91 && password2[7]==94 && password2[8]==91)
					{
						kerouac=1;
					}

					bad_pass2 = 1;
               PlaySound(SND_GUITARDOWN,CH_GUITARDOWN,0x1FFF,0x1FFF);
            }
         }

         if(pass_done1 && (front_end->num_players==ONE_PLAYER || pass_done2))
         {
            pass_done1 = 0;
            pass_done2 = 0;

            bad_pass1 = 0;
            bad_pass2 = 0;
            if(front_end->num_players==TWO_PLAYER && !CompatiblePasswords(password1,password2))
            {
               bad_pass1 = 1;
               bad_pass2 = 1;
               PlaySound(SND_GUITARDOWN,CH_GUITARDOWN,0x1FFF,0x1FFF);
            }
            else
            {
               SetupFrontEnd();
               IntroDone();
            }
         }
      }
   }
	else if(intro_status==INTRO_CONTINUE_SEASON)
	{
		#if RAM_CARD_WORKS
		YesOrNo();
		if(bothtap & PADk)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         InitIntro();
         intro_status = INTRO_SIGNIN;
      }
		else if(bothtap & PADh)
		{
			PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
			if(!yes_or_no)
			{
				StartPassword();
				intro_status = INTRO_GET_PASSWORD;
				front_end->use_ram_card = 0;
			}
			else
			{
				if(!RAMCardPresent(RAM_CARD_CHANNEL))
				{
					StartRAMCardError("Card not found.");
				}
				else if(!RAMCardFormatted(RAM_CARD_CHANNEL))
				{
					StartRAMCardError("Not formatted.");
					intro_status = INTRO_FORMAT_ERROR;
				}
				else
				{
					num_season_files = RAMCardDirectory(RAM_CARD_CHANNEL,season_files,SEASON_FILE_PREFIX,MAX_SEASON_FILES);
         		if(num_season_files)
         		{
            		season_selected = 0;
						front_end->use_ram_card = 1;
						StartChooseSeason();
         		}
         		else StartRAMCardError("No Season Files");
				}
			}
		}
		#else
		StartPassword();
		intro_status = INTRO_GET_PASSWORD;
		front_end->use_ram_card = 0;
		#endif
	}
	else if(intro_status==INTRO_CHOOSE_SEASON)
	{
      StartSelect();

      /* Check for go back */
      if(bothtap & PADk)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         InitIntro();
         intro_status = INTRO_SIGNIN;
      }
      else
      {
	      max_season_selected = num_season_files-1;
         if(bothtap & (PADLup|PADLdown))
         {
            if(bothtap & PADLup)
            {
               season_selected--;
               if(season_selected<0) season_selected = max_season_selected;
            }
            else
            {
               season_selected++;
               if(season_selected > max_season_selected) season_selected = 0;
            }
            PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
            DrawSeasonFiles();
         }
         else if(bothtap & PADh)
         {
            PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);

				if(!RAMCardPresent(RAM_CARD_CHANNEL))
				{
					StartRAMCardError("Card not found.");
				}
				else if(!RAMCardFormatted(RAM_CARD_CHANNEL))
				{
					StartRAMCardError("Not formatted.");
					intro_status = INTRO_FORMAT_ERROR;
				}
				else
				{
					old_video = front_end->video;
					old_music_volume = front_end->music_volume;
					old_sound_volume = front_end->sound_volume;
					if(ReadRAMCardFile(season_files[season_selected].name,RAM_CARD_CHANNEL,
                               (unsigned char*)front_end,FRONT_END_SIZE))
					{
						front_end->flag = FEF_FRONTEND;
						front_end->use_mountain_bike = 1;
						front_end->use_inline_skates = 1;
						front_end->use_street_luge = 1;
						front_end->use_skate_board =1;
						front_end->use_ram_card = 1;
						front_end->video = old_video;
						front_end->music_volume = old_music_volume;
						front_end->sound_volume = old_sound_volume;
						players_rle = front_end->num_players;
	               season_rle = front_end->season_mode = CONTINUE_SEASON;
	               difficulty_rle = front_end->difficulty;
	               video_rle = front_end->video;
						SetupFrontEnd();
	               IntroDone();
					}
					else StartRAMCardError("Read failed.");
				}
	      }
      }

	}
	else if(intro_status==INTRO_INITIALS)
   {
      /* Check for go back */
      StartSelect();
      if(bothtap & PADk)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         InitIntro();
         intro_status = INTRO_SIGNIN;
      }
      else
      {
         if(Initials(front_end->player1.initials))
         {
            initials_done1 = 1;
            if(front_end->num_players==TWO_PLAYER)
            {
               Unpack(WHT1_RLE_A,(unsigned long)unpack_buffer);
               LoadTIM((unsigned long)unpack_buffer,640+160-75,120-55);
            }
         }

         if(front_end->num_players==TWO_PLAYER && Initials(front_end->player2.initials))
         {
            initials_done2 = 1;
            Unpack(WHT2_RLE_A,(unsigned long)unpack_buffer);
            LoadTIM((unsigned long)unpack_buffer,640+160-75,120+5);
         }

         if(initials_done1 && initials_done2)
         {
				if(!RAMCardPresent(RAM_CARD_CHANNEL)) StartRAMCardError("Card not found");
            else if(!RAMCardFormatted(RAM_CARD_CHANNEL))
				{
					StartRAMCardError("Not formatted.");
					intro_status = INTRO_FORMAT_ERROR;
				}
            else
            {
               num_season_files = RAMCardDirectory(RAM_CARD_CHANNEL,season_files,SEASON_FILE_PREFIX,MAX_SEASON_FILES);
               if(num_season_files < MAX_SEASON_FILES)
               {
						ResetStandings();
						SetupFrontEnd();
						bool = CreateSeasonFile(1,0);
						if(bool==1)
						{
							ResetStandings();
							SetupFrontEnd();
							IntroDone();
						}
                  else if(bool==0)
                  {
                     StartInitials(1);
                     intro_status=INTRO_INITIALS;
                  }
						else
						{
							StartRAMCardError("Can't create.");
                     DrawText("Card full.",10,FILES_VX,FILES_VY+16+32,1);
						}
               }
               else
               {
                  if(!CreateSeasonFile(1,1))
                  {
                     StartInitials(1);
                     intro_status=INTRO_INITIALS;
                  }
                  else StartReplaceSeason();
               }
            }
         }
      }
   }
	else if(intro_status==INTRO_REPLACE_SEASON)
   {
      StartSelect();

      /* Check for go back */
      if(bothtap & PADk)
      {
         PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
         InitIntro();
         intro_status = INTRO_SIGNIN;
      }
      else
      {
	      max_season_selected = num_season_files-1;
         if(bothtap & (PADLup|PADLdown))
         {
            if(bothtap & PADLup)
            {
               season_selected--;
               if(season_selected<0) season_selected = max_season_selected;
            }
            else
            {
               season_selected++;
               if(season_selected > max_season_selected) season_selected = 0;
            }
            PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);
            DrawSeasonFiles();
         }
         else if(bothtap & PADh)
         {
            PlaySound(SND_SWITCH2,CH_SWITCH2,0x1FFF,0x1FFF);

            DeleteRAMCardFile(season_files[season_selected].name,RAM_CARD_CHANNEL);
				ResetStandings();
				SetupFrontEnd();
            if(CreateSeasonFile(1,0)==1)
				{
            	RAMCardDirectory(RAM_CARD_CHANNEL,season_files,SEASON_FILE_PREFIX,MAX_SEASON_FILES);

            	StartReplaceSeason();
            	intro_status = INTRO_REPLACE_WAIT;
            	replace_wait = 0;
				}
            else
            {
               StartRAMCardError("Creation failed.");
            }
	      }
      }
   }
	else if(intro_status==INTRO_REPLACE_WAIT)
   {
      if(replace_wait < REPLACE_WAIT && !bothtap) replace_wait++;
      else
		{
			ResetStandings();
			SetupFrontEnd();
			IntroDone();
		}
   }
	if(intro_status!=INTRO_GO_MAIN && intro_status!=INTRO_OPEN_DOORS && intro_status!=INTRO_CLOSE_DOORS && intro_status!=INTRO_START && intro_status!=INTRO_RESTART)
	{
		AnimateLogos();
	}

	front_end->num_players = players_rle;
   front_end->season_mode = season_rle;
   front_end->difficulty = difficulty_rle;
   front_end->video = video_rle;
}