void FrameShowHelpScreen(int sx, int sy) // sx, sy - sizes of current window (screen)
{
	// on pressing F1 button shows help screen

   const char * HelpStrings[] = {
	   "Welcome to LinApple - Apple][ emulator for Linux!",
    	   "Conf file is linapple.conf in ~/.linapple directory by default",
    	   "Hugest archive of Apple][ stuff you can find at ftp.apple.asimov.net",
    	   " F1 - This help",
    	   " F2 - Cold reset, Shift+F2 - Reload conf file and restart",
    	   " F3, F4 - Choose an image file name for floppy disk",
	   "             in Slot 6 drive 1 or 2 respectively",
	   " Shift+F3, Shift+F4 - The same thing for Apple hard disks",
    	   "                         (in Slot 7)",
	   " F5 - Swap drives for Slot 6",
	   " F6 - Toggle fullscreen mode",
           " F7 - Reserved for Debugger!",
	   " F8 - Save current screen as a .bmp file",
    	   " Shift+F8 - Save settings changable at runtime in conf file",
    	   " F9 - Cycle through various video modes",
	   " F10 - Quit emulator",
    	   " F11 - Save current state to file, Alt+F11 - quick save",
	   " F12 - Reload it from file, Alt+F12 - quick load",
	   " Ctrl+F12 - Hot reset",
    	   "  Pause - Pause emulator",
    	   "  Scroll Lock - Toggle full speed",
	   "Num pad keys:",
	   "  Grey + - Speed up emulator",
     	   "  Grey - - Speed it down",
	   "  Grey * - Normal speed"
   };

//   const int PositionsY[] = { 7, 15, 26 };

   SDL_Surface *my_screen;	// for background
   SDL_Surface *tempSurface = NULL;	// temporary surface

   if(font_sfc == NULL)
	   if(!fonts_initialization()) {
	   	fprintf(stderr, "Font file was not loaded.\n");
	   	return;		//if we don't have a fonts, we just can do none
	   }
	if(!g_WindowResized) {
	   if(g_nAppMode == MODE_LOGO) tempSurface = g_hLogoBitmap;	// use logobitmap
	   else tempSurface = g_hDeviceBitmap;
	 }
	 else tempSurface = g_origscreen;

	   if(tempSurface == NULL) tempSurface = screen;	// use screen, if none available
	   my_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, tempSurface->w, tempSurface->h,
					    tempSurface->format->BitsPerPixel, 0, 0, 0, 0);
	   if(tempSurface->format->palette && my_screen->format->palette)
		   SDL_SetColors(my_screen, tempSurface->format->palette->colors,
				 0, tempSurface->format->palette->ncolors);

	   surface_fader(my_screen, 0.2F, 0.2F, 0.2F, -1, 0);	// fade it out to 20% of normal
	   SDL_BlitSurface(tempSurface, NULL, my_screen, NULL);

	   SDL_BlitSurface(my_screen, NULL, screen, NULL);		// show background

		double facx = double(g_ScreenWidth) / double(SCREEN_WIDTH);
		double facy = double(g_ScreenHeight) / double(SCREEN_HEIGHT);

	   font_print_centered(sx/2, int(5*facy), (char*)HelpStrings[0], screen, 1.5*facx, 1.3*facy);
	   font_print_centered(sx/2, int(20*facy), (char*)HelpStrings[1], screen, 1.3*facx, 1.2*facy);
	   font_print_centered(sx/2, int(30*facy), (char*)HelpStrings[2], screen, 1.2*facx, 1.0*facy);

   int Help_TopX = int(45*facy);
   int i;
	   for(i =  3; i < 25; i++)
		   font_print(4, Help_TopX + (i - 3) * 15 * facy, (char*)HelpStrings[i], screen, 1.5*facx, 1.5*facy); // show keys

	   // show frames
	   rectangle(screen, 0, Help_TopX - 5, /*SCREEN_WIDTH*/g_ScreenWidth - 1, int(335*facy), SDL_MapRGB(screen->format, 255, 255, 255));
	   rectangle(screen, 1, Help_TopX - 4, /*SCREEN_WIDTH*/g_ScreenWidth, int(335*facy), SDL_MapRGB(screen->format, 255, 255, 255));

	   rectangle(screen, 1, 1, /*SCREEN_WIDTH*/g_ScreenWidth - 2, (Help_TopX - 8), SDL_MapRGB(screen->format, 255, 255, 0));

	   if(apple_icon != NULL) {	// display Apple logo
		   tempSurface = SDL_DisplayFormat(apple_icon);
		   SDL_Rect logo, scrr;
		   logo.x = logo.y = 0;
		   logo.w = tempSurface->w;
		   logo.h = tempSurface->h;
		   scrr.x = int(460*facx);
		   scrr.y = int(270*facy);
		   scrr.w = scrr.h = int(100*facy);
		   SDL_SoftStretchOr(tempSurface, &logo, screen, &scrr);
	   }

	   SDL_Flip(screen);	// show the screen
	   SDL_Delay(1000);	// wait 1 second to be not too fast

	   //////////////////////////////////
	   // Wait for keypress
	   //////////////////////////////////
	   SDL_Event event;	// event

	   event.type = SDL_QUIT;
	   while(event.type != SDL_KEYDOWN /*&& event.key.keysym.sym != SDLK_ESCAPE*/) {// wait for ESC-key pressed
		   usleep(100);
		   SDL_PollEvent(&event);
	   }

	   DrawFrameWindow(); // restore screen
}
bool state_keyredefinition_cycle(SDL_Surface *screen,int sx,int sy,unsigned char *keyboard)
{
	int i;

	if (SUBSTATE==0) {
		if (image!=0) SDL_FreeSurface(image);
		if (image2!=0) SDL_FreeSurface(image);
		image=IMG_Load("graphics/tittle.png");
	} /* if */ 

	SDL_BlitSurface(image,0,screen,0);
	surface_fader(screen,0.5F,0.5F,0.5F,-1,0);

	font_print_centered(sx/2,20,"REDEFINE CONTROLS:",screen);
	font_print_centered(sx/2,40,"[PRESS SELECT TO SKIP]",screen);

	if (SUBSTATE<32) {
		surface_fader(screen,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,-1,0);
		SUBSTATE++;
	} /* if */ 
	if (SUBSTATE>39) {
		surface_fader(screen,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,-1,0);
		SUBSTATE++;
		if (SUBSTATE==64) {
			save_configuration();

			SDL_FreeSurface(image);
			image=0;

			STATE=1;
			SUBSTATE=0;
		} /* if */ 
	} /* if */ 

	if (SUBSTATE>=32) {
		bool found;
		char keystr[256];
		char *upstr;

		SUBSTATE-=32;
		if (SUBSTATE>=0) {
			font_print(16,60,"PRESS A BUTTON FOR THRUST:",screen);
		} /* if */ 
		if (SUBSTATE>=1) {
			strcpy(keystr,get_key_name((SDLKey)THRUST_KEY)); 
			upstr=strupr(keystr);
			font_print(200,60,upstr,screen);
			font_print(16,70,"PRESS A BUTTON FOR ANTITHRUST:",screen);
		} /* if */ 
		if (SUBSTATE>=2) { 
                        strcpy(keystr,get_key_name((SDLKey)ANTITHRUST_KEY));
                        upstr=strupr(keystr);
			font_print(200,70,upstr,screen);
			font_print(16,80,"PRESS A BUTTON FOR LEFT:",screen);
		} /* if */ 
		if (SUBSTATE>=3) {  
			strcpy(keystr,get_key_name((SDLKey)LEFT_KEY));
			upstr=strupr(keystr);
			font_print(200,80,upstr,screen);
			font_print(16,90,"PRESS A BUTTON FOR RIGHT:",screen);
		} /* if */ 
		if (SUBSTATE>=4) { 
			strcpy(keystr,get_key_name((SDLKey)RIGHT_KEY));
			upstr=strupr(keystr);
			font_print(200,90,upstr,screen);
			font_print(16,100,"PRESS A BUTTON FOR FIRE:",screen);
		} /* if */ 
		if (SUBSTATE>=5) { 
			strcpy(keystr,get_key_name((SDLKey)FIRE_KEY));
			upstr=strupr(keystr);
			font_print(200,100,upstr,screen);
			font_print(16,110,"PRESS A BUTTON FOR ATRACTOR:",screen);
		} /* if */ 
		if (SUBSTATE>=6) {
			strcpy(keystr,get_key_name((SDLKey)ATRACTOR_KEY));
			upstr=strupr(keystr);
			font_print(200,110,upstr,screen);
			font_print(16,120,"PRESS A BUTTON FOR PAUSE:",screen);
		} /* if */ 
		if (SUBSTATE>=7) { 
			strcpy(keystr,get_key_name((SDLKey)PAUSE_KEY));
			upstr=strupr(keystr);
			font_print(200,120,upstr,screen);
			font_print(32,140,"PRESS ANY BUTTON",screen);
		} /* if */ 

		found=SUBSTATE < 7 ? false : true;
		for(i=0;!found && i<SDLK_LAST;i++) {
			if (keyboard[i] && !old_keyboard[i]) {
				if ((SDLKey)i == SDLK_ESCAPE) {
					keyboard[i] = 0;
					SUBSTATE++;
					break;
				}

				switch(SUBSTATE) {
				case 0:THRUST_KEY=(SDLKey)i;
					   SUBSTATE++;
					   found=true;
					   break;
				case 1:ANTITHRUST_KEY=(SDLKey)i;
					   SUBSTATE++;
					   found=true;
					   break;
				case 2:LEFT_KEY=(SDLKey)i;
					   SUBSTATE++;
					   found=true;
					   break;
				case 3:RIGHT_KEY=(SDLKey)i;
					   SUBSTATE++;
					   found=true;
					   break;
				case 4:FIRE_KEY=(SDLKey)i;
					   SUBSTATE++;
					   found=true;
					   break;
				case 5:ATRACTOR_KEY=(SDLKey)i;
					   SUBSTATE++;
					   found=true;
					   break;
				case 6:PAUSE_KEY=(SDLKey)i;
					   SUBSTATE++;
					   found=true;
					   break;
				} /* switch */ 
			} /* if */ 
		} /* for */ 

		if (SUBSTATE==7 && 
			((keyboard[SDLK_ESCAPE] && !old_keyboard[SDLK_ESCAPE]) ||
			 (keyboard[FIRE_KEY] && !old_keyboard[FIRE_KEY])
			)) {
			SUBSTATE++;
		} /* if */ 
		SUBSTATE+=32;
	} /* if */ 

	return true;
} /* state_keyredefinition_cycle */ 
//===========================================================================
void DrawStatusArea (/*HDC passdc,*/ int drawflags)
{// status area not used now (yet?) --bb
/*	FrameReleaseDC();
	HDC  dc     = (passdc ? passdc : GetDC(g_hFrameWindow));
	int  x      = buttonx;
	int  y      = buttony+BUTTONS*BUTTONCY+1;
	int  iDrive1Status = DISK_STATUS_OFF;
	int  iDrive2Status = DISK_STATUS_OFF;
	bool bCaps   = KeybGetCapsStatus();
	DiskGetLightStatus(&iDrive1Status,&iDrive2Status);

	if (fullscreen)
	{
		SelectObject(dc,smallfont);
		SetBkMode(dc,OPAQUE);
		SetBkColor(dc,RGB(0,0,0));
		SetTextAlign(dc,TA_LEFT | TA_TOP);
		SetTextColor(dc,RGB((iDrive1Status==2 ? 255 : 0),(iDrive1Status==1 ? 255 : 0),0));
		TextOut(dc,x+ 3,y+2,TEXT("1"),1);
		SetTextColor(dc,RGB((iDrive2Status==2 ? 255 : 0),(iDrive2Status==1 ? 255 : 0),0));
		TextOut(dc,x+13,y+2,TEXT("2"),1);
		if (!IS_APPLE2)
		{
			SetTextAlign(dc,TA_RIGHT | TA_TOP);
			SetTextColor(dc,(bCaps
				? RGB(128,128,128)
				: RGB(  0,  0,  0) ));
			TextOut(dc,x+BUTTONCX,y+2,TEXT("Caps"),4);
		}
		SetTextAlign(dc,TA_CENTER | TA_TOP);
		SetTextColor(dc,(g_nAppMode == MODE_PAUSED || g_nAppMode == MODE_STEPPING
			? RGB(255,255,255)
			: RGB(  0,  0,  0)));
		TextOut(dc,x+BUTTONCX/2,y+13,(g_nAppMode == MODE_PAUSED
			? TITLE_PAUSED
			: TITLE_STEPPING) ,8);
	}
	else
	{*/
	if(font_sfc == NULL)
		if(!fonts_initialization()) {
		fprintf(stderr, "Font file was not loaded.\n");
		return;		//if we don't have a fonts, we just can do none
		}

	SDL_Rect srect;

	Uint32 mybluez = SDL_MapRGB(screen->format, 10, 10, 255);	// bluez color, know that?
	Uint32 myyell  = SDL_MapRGB(screen->format, 255, 255, 0);	// yellow color?

	SDL_SetColors(g_hStatusSurface, screen->format->palette->colors,
							 0, 256);
//	Uint32 myblack  = SDL_MapRGB(screen->format, 0, 0, 0);	// black color
//	SDL_SetColorKey(g_hStatusSurface,SDL_SRCCOLORKEY/* | SDL_RLEACCEL*/, myblack);
							 
	if (drawflags & DRAW_BACKGROUND)
	{
/* Code moved to Video.cpp in CreateDIBSections()
		srect.x = srect.y = 0;
		srect.w = STATUS_PANEL_W;
		srect.h = STATUS_PANEL_H;
		SDL_FillRect(g_hStatusSurface, &srect, mybluez);	// fill status panel
		rectangle(g_hStatusSurface, 0, 0, STATUS_PANEL_W - 1, STATUS_PANEL_H - 1, myyell);
		rectangle(g_hStatusSurface, 2, 2, STATUS_PANEL_W - 5, STATUS_PANEL_H - 5, myyell);
		font_print(7, 6, "FDD1", g_hStatusSurface, 1.3, 1.5); // show signs
		font_print(40, 6, "FDD2", g_hStatusSurface, 1.3, 1.5);
		font_print(74, 6, "HDD", g_hStatusSurface, 1.3, 1.5);
*/
//		SDL_SetColors(g_hStatusSurface, screen->format->palette->colors,
//							 0, 256);
		g_iStatusCycle = SHOW_CYCLES;	// start cycle for panel showing
	}
	if (drawflags & DRAW_LEDS)
	{
		srect.x = 4;
		srect.y = 22;
		srect.w = STATUS_PANEL_W - 8;
		srect.h = STATUS_PANEL_H - 25;
		SDL_FillRect(g_hStatusSurface, &srect, mybluez);	// clear

		char leds[2] = "\x64";
#define LEDS	1
		int  iDrive1Status = DISK_STATUS_OFF;
		int  iDrive2Status = DISK_STATUS_OFF;
		int iHDDStatus = DISK_STATUS_OFF;

//		bool bCaps   = KeybGetCapsStatus();
		DiskGetLightStatus(&iDrive1Status,&iDrive2Status);
		iHDDStatus = HD_GetStatus();

		leds[0] = LEDS + iDrive1Status;
//		printf("Leds are %d\n",leds[0]);
		font_print(8, 23, leds, g_hStatusSurface, 4, 2.7);

		leds[0] = LEDS + iDrive2Status;
		font_print(40, 23, leds, g_hStatusSurface, 4, 2.7);

		leds[0] = LEDS + iHDDStatus;
		font_print(71, 23, leds, g_hStatusSurface, 4, 2.7);

		if(iDrive1Status | iDrive2Status | iHDDStatus) g_iStatusCycle = SHOW_CYCLES; // show status panel
	}
//	surface_fader(g_hStatusSurface, nowleds, nowleds, nowleds, -1, 0);
/*		if (drawflags & DRAW_TITLE)
		{
			TCHAR title[40];
			switch (g_Apple2Type)
			{
			case A2TYPE_APPLE2:			_tcscpy(title, TITLE_APPLE_2); break;
			case A2TYPE_APPLE2PLUS:		_tcscpy(title, TITLE_APPLE_2_PLUS); break;
			case A2TYPE_APPLE2E:		_tcscpy(title, TITLE_APPLE_2E); break;
			case A2TYPE_APPLE2EEHANCED:	_tcscpy(title, TITLE_APPLE_2E_ENHANCED); break;
			}

			switch (g_nAppMode)
			{
				case MODE_PAUSED  : _tcscat(title,TEXT(" [")); _tcscat(title,TITLE_PAUSED  ); _tcscat(title,TEXT("]")); break;
				case MODE_STEPPING: _tcscat(title,TEXT(" [")); _tcscat(title,TITLE_STEPPING); _tcscat(title,TEXT("]")); break;
			}

			SendMessage(g_hFrameWindow,WM_SETTEXT,0,(LPARAM)title);
		}
		if (drawflags & DRAW_BUTTON_DRIVES)
		{
			DrawButton(dc, BTN_DRIVE1);
			DrawButton(dc, BTN_DRIVE2);
		}
	}

	if (!passdc)
	ReleaseDC(g_hFrameWindow,dc);*/
}
Beispiel #4
0
bool state_mainmenu_cycle(SDL_Surface *screen,int sx,int sy,unsigned char *keyboard)
{
	if (SUBSTATE==0) {
		if (image!=0) SDL_FreeSurface(image);
		image=IMG_Load("graphics/tittle.png");
		SDL_SetColorKey(image,SDL_SRCCOLORKEY,SDL_MapRGB(image->format,0,0,0));
		demotimer=0;
		demoon=false;
	} /* if */ 

	if (demoon) {
		int retval;
		int i;
		unsigned char tmp[SDLK_LAST];

		for(i=0;i<SDLK_LAST;i++) tmp[i]=0;
		tmp[THRUST_KEY]=fgetc(replayfile);
		tmp[ANTITHRUST_KEY]=fgetc(replayfile);
		tmp[LEFT_KEY]=fgetc(replayfile);
		tmp[RIGHT_KEY]=fgetc(replayfile);
		tmp[FIRE_KEY]=fgetc(replayfile);
		tmp[ATRACTOR_KEY]=fgetc(replayfile);
		game->cycle(tmp);
		retval=fgetc(replayfile);

		game->render(screen,sx,sy);

		if (retval!=0) {
			delete game;
			game=0;

			fclose(replayfile);
			replayfile=0;
			demoon=false;
		} /* if */ 
	} else {
		SDL_FillRect(screen,0,0);
	} /* if */ 

	if (demoon) {
		SDL_SetAlpha(image,SDL_SRCALPHA,tittle_alpha--);
		if (tittle_alpha<=0) tittle_alpha=0;
	} else {
		SDL_SetAlpha(image,SDL_SRCALPHA,tittle_alpha);
		tittle_alpha+=2;
		if (tittle_alpha>=255) tittle_alpha=255;
	} /* if */ 
	SDL_BlitSurface(image,0,screen,0);

	{
		SDL_Rect r;

		r.x=SCREEN_X/2-80;
		r.w=160;
		r.y=sy-80;
		r.h=64;
		surface_fader(screen,0.5F,0.5F,0.5F,-1,&r);

		r.x=0;
		r.w=SCREEN_X;
		r.y=sy-16;
		r.h=16;
		surface_fader(screen,0.5F,0.5F,0.5F,-1,&r);

		r.x=SCREEN_X/2-80;
		r.w=160;
		r.y=sy-72+cursor*8;
		r.h=8;
		SDL_FillRect(screen,&r,SDL_MapRGB(screen->format,255,0,0));
	}

	font_print_centered(SCREEN_X/2,sy-72,"START GAME",screen);
	font_print_centered(SCREEN_X/2,sy-64,"ENTER CODE",screen);
	font_print_centered(SCREEN_X/2,sy-56,"CHANGE LEVEL-PACK",screen);
	font_print_centered(SCREEN_X/2,sy-48,"REDEFINE CONTROLS",screen);
	font_print_centered(SCREEN_X/2,sy-40,"INSTRUCTIONS",screen);
	font_print_centered(SCREEN_X/2,sy-32,"REPLAYS",screen);
	font_print_centered(SCREEN_X/2,sy-24,"QUIT GAME",screen);

	{
		char tmp[256];

		sprintf(tmp,"LEVELPACK: %s",levelpack);
		font_print(SCREEN_X/2-strlen(tmp)*3,sy-12,tmp,screen);
	}

	if (SUBSTATE<32) {
		surface_fader(screen,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,-1,0);
		SUBSTATE++;
	} /* if */ 
	if (SUBSTATE==32) {
		if (!demoon) demotimer++;
		if (demotimer>=256) {
			int i;
			char tmp[80];
			char levelname[256];
			int fuel;
			int v1,v2;

			
			demoon=true;
			demotimer=0;
			tittle_alpha=255;

			sprintf(tmp,"demos/demo%i.rpl",((rand()%40)/10)+1);
			replayfile=fopen(tmp,"rb");
			v1=fgetc(replayfile);
			v2=fgetc(replayfile);	// To maintain compatibility with a previous version

			level=0;
			for(i=0;i<256;i++) levelname[i]=fgetc(replayfile);
			fuel=fgetc(replayfile);

			ship_type=fgetc(replayfile);
			if (game!=0) delete game;
			game=new TRANSBALL("graphics/","sound/","maps/",fuel,levelname,ship_type);
		} /* if */ 

		if (keyboard[SDLK_UP]) {
			keyboard[SDLK_UP] = 0;
			cursor--;
			if (cursor < 0) cursor = 6;
		} /* if */
		else if (keyboard[SDLK_DOWN]) {
			keyboard[SDLK_DOWN] = 0;
			cursor++;
			if (cursor > 6) cursor = 0;
		} /* if */

		if ((keyboard[FIRE_KEY] && !old_keyboard[FIRE_KEY]) || (keyboard[SDLK_LCTRL] && !old_keyboard[SDLK_LCTRL])) {
			switch (cursor)
			{
				case 0:
					SUBSTATE++;
					SUBSTATE2=0;
				break;
				case 1:
					SUBSTATE++;
					SUBSTATE2=3;
				break;
				case 2:
					SUBSTATE++;
					SUBSTATE2=6;
				break;
				case 3:
					SUBSTATE++;
					SUBSTATE2=5;
				break;
				case 4:
					SUBSTATE++;
					SUBSTATE2=2;
				break;
				case 5:
					SUBSTATE++;
					SUBSTATE2=4;
				break;
				case 6:
					SUBSTATE++;
					SUBSTATE2=1;
				break;

				default:
				break;
			}

			timer=0;
		} /* if */ 
		if (keyboard[SDLK_ESCAPE] && !old_keyboard[SDLK_ESCAPE]) {
			SUBSTATE++;
			SUBSTATE2=1;
		} /* if */ 
	} /* if */ 
	if (SUBSTATE>32) {
		surface_fader(screen,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,-1,0);
		SUBSTATE++;
		if (SUBSTATE==64) {
			SDL_FreeSurface(image);
			image=0;

			if (game!=0) delete game;
			game=0;
			if (replayfile!=0) fclose(replayfile);
			replayfile=0;
			demoon=false;
			demotimer=0;

			if (SUBSTATE2==0) {
				int i;

				for(i=0;i<1000;i++) {
					char tmp[256];
					snprintf(tmp,sizeof(tmp),"%s/replay%.3i.rpl",replay_dir, i);
					remove(tmp);
				} /* for */ 

				STATE=4;
				SUBSTATE=0;
				level=0;
				replaynum=0;
			} /* if */ 
			if (SUBSTATE2==1) {
				return false;
			} /* if */ 
			if (SUBSTATE2==2) {
				STATE=2;
				SUBSTATE=0;
			} /* if */ 
			if (SUBSTATE2==3) {
				STATE=3;
				SUBSTATE=0;
				SUBSTATE2=0;
				edit_text[0]=0;
				edit_position=0;
			} /* if */ 
			if (SUBSTATE2==4) {
				STATE=7;
				SUBSTATE=0;
			} /* if */ 
			if (SUBSTATE2==5) {
				STATE=11;
				SUBSTATE=0;
			} /* if */ 
			if (SUBSTATE2==6) {
				STATE=12;
				SUBSTATE=0;
			} /* if */ 
		} /* if */ 
	} /* if */ 


	return true;
} /* state_mainmenu_cycle */ 
Beispiel #5
0
// render stuff
void display_update() {
	int gx, gy;
	char buffer[20];
	char time_buffer[8];
	Particle *current_particle = NULL;
	ParticleCollection *current_collection = NULL;
	SDL_Color grid_color;

	// TODO: make grid color settable
	grid_color.r = 255;
	grid_color.g = 255;
	grid_color.b = 255;

	graphics_clear();

  // draw texture for the grid
	if (grid) {
		graphics_drawGrid(20, 0, GRID_BLOCK_SIZE, GRID_WIDTH, GRID_HEIGHT, &grid_color);	
	}

  // draw grid
  if (grid && block_texture) {
		for (gy = 0; gy < GRID_HEIGHT; gy++) { // TODO: cater for realtime grid width/height settings
			for (gx = 0; gx < GRID_WIDTH; gx++) {
				// red
				if (*(grid->data + gx + (gy * GRID_WIDTH)) == 1) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx),
          0 + (GRID_BLOCK_SIZE * gy), GRID_BLOCK_SIZE,
          GRID_BLOCK_SIZE, red_block_texture);
				}
				// green
				if (*(grid->data + gx + (gy * GRID_WIDTH)) == 2) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx),
          0 + (GRID_BLOCK_SIZE * gy), GRID_BLOCK_SIZE,
          GRID_BLOCK_SIZE, green_block_texture);
				}
				// blue
				if (*(grid->data + gx + (gy * GRID_WIDTH)) == 3) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx),
          0 + (GRID_BLOCK_SIZE * gy), GRID_BLOCK_SIZE,
          GRID_BLOCK_SIZE, blue_block_texture);
				}
				// orange
				if (*(grid->data + gx + (gy * GRID_WIDTH)) == 4) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx),
          0 + (GRID_BLOCK_SIZE * gy), GRID_BLOCK_SIZE,
          GRID_BLOCK_SIZE, orange_block_texture);
				}
				// yellow
				if (*(grid->data + gx + (gy * GRID_WIDTH)) == 5) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx),
          0 + (GRID_BLOCK_SIZE * gy), GRID_BLOCK_SIZE,
          GRID_BLOCK_SIZE, yellow_block_texture);
				}
				// cyan
				if (*(grid->data + gx + (gy * GRID_WIDTH)) == 6) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx),
          0 + (GRID_BLOCK_SIZE * gy), GRID_BLOCK_SIZE,
          GRID_BLOCK_SIZE, cyan_block_texture);
				}
				// purple
				if (*(grid->data + gx + (gy * GRID_WIDTH)) == 7) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx),
          0 + (GRID_BLOCK_SIZE * gy), GRID_BLOCK_SIZE,
          GRID_BLOCK_SIZE, purple_block_texture);
				}
			}
		}
  }

  // draw tetromino
  if (block_texture && current_tetromino) {
    for (gy = 0; gy < 4; gy++) { // TODO: cater for realtime grid width/height settings
			for (gx = 0; gx < 4; gx++) {
			  // red
				if (*(current_tetromino->data+gx+(4*gy)) == 1) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx) +
          (GRID_BLOCK_SIZE * current_tetromino->x),
            0 + (GRID_BLOCK_SIZE * gy) + (GRID_BLOCK_SIZE *
            current_tetromino->y), GRID_BLOCK_SIZE, GRID_BLOCK_SIZE, red_block_texture);
				}
				// green
				if (*(current_tetromino->data+gx+(4*gy)) == 2) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx) +
          (GRID_BLOCK_SIZE * current_tetromino->x),
            0 + (GRID_BLOCK_SIZE * gy) + (GRID_BLOCK_SIZE *
            current_tetromino->y), GRID_BLOCK_SIZE, GRID_BLOCK_SIZE, green_block_texture);
				}
				// blue
				if (*(current_tetromino->data+gx+(4*gy)) == 3) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx) +
          (GRID_BLOCK_SIZE * current_tetromino->x),
            0 + (GRID_BLOCK_SIZE * gy) + (GRID_BLOCK_SIZE *
            current_tetromino->y), GRID_BLOCK_SIZE, GRID_BLOCK_SIZE, blue_block_texture);
				}
				// orange
				if (*(current_tetromino->data+gx+(4*gy)) == 4) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx) +
          (GRID_BLOCK_SIZE * current_tetromino->x),
            0 + (GRID_BLOCK_SIZE * gy) + (GRID_BLOCK_SIZE *
            current_tetromino->y), GRID_BLOCK_SIZE, GRID_BLOCK_SIZE, orange_block_texture);
				}
				// yellow
				if (*(current_tetromino->data+gx+(4*gy)) == 5) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx) +
          (GRID_BLOCK_SIZE * current_tetromino->x),
            0 + (GRID_BLOCK_SIZE * gy) + (GRID_BLOCK_SIZE *
            current_tetromino->y), GRID_BLOCK_SIZE, GRID_BLOCK_SIZE, yellow_block_texture);
				}
				// cyan
				if (*(current_tetromino->data+gx+(4*gy)) == 6) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx) +
          (GRID_BLOCK_SIZE * current_tetromino->x),
            0 + (GRID_BLOCK_SIZE * gy) + (GRID_BLOCK_SIZE *
            current_tetromino->y), GRID_BLOCK_SIZE, GRID_BLOCK_SIZE, cyan_block_texture);
				}
				// purple
				if (*(current_tetromino->data+gx+(4*gy)) == 7) {
					graphics_drawTextureScaled(20 + (GRID_BLOCK_SIZE * gx) +
          (GRID_BLOCK_SIZE * current_tetromino->x),
            0 + (GRID_BLOCK_SIZE * gy) + (GRID_BLOCK_SIZE *
            current_tetromino->y), GRID_BLOCK_SIZE, GRID_BLOCK_SIZE, purple_block_texture);
				}
			}
		}
  } 

  // draw text
  font_print(280, 35, "SCORE", NULL);
	sprintf(buffer, "%d", game.score);
  font_print(280, 55, buffer, NULL);
  font_print(280, 75, "TIME", NULL);
  game_getTime(time_buffer);
  font_print(280, 95, time_buffer, NULL);
  font_print(280, 115, "LEVEL", NULL);
	sprintf(buffer, "%d", game.level);
  font_print(280, 135, buffer, NULL);
  font_print(280, 155, "LINES", NULL);
	sprintf(buffer, "%d", game.lines);
  font_print(280, 175, buffer, NULL); 

  // render any particles if they're not currently being modified
	if (SDL_SemTryWait(sem) == 0) {
		current_collection = particle_getActiveCollections();
		if (current_collection) {
 	  	while (current_collection) {
      	current_particle = current_collection->first;
	
      	while (current_particle) {
      		glColor4f(1.0f, 1.0f, 1.0f, current_particle->alpha);
    	    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
  	      glEnable(GL_BLEND);
	
  	      graphics_drawTexture(current_particle->x, current_particle->y, current_particle->texture);
	        glDisable(GL_BLEND);

        	current_particle = current_particle->next;
      	}

      	current_collection = current_collection->next;
    	}
  	}
		SDL_SemPost(sem);
	}

  // draw the menu if its needed
	if (ui_isMenuVisible()) {
		if (grid && current_tetromino) {
			ui_drawMainMenu(MENU_IN_GAME);
		}
		else {
			ui_drawMainMenu(MENU_MAIN);
		}
	}

	SDL_GL_SwapBuffers();
}
bool ChooseAnImageFTP(int sx,int sy, char *ftp_dir, int slot, char **filename, bool *isdir, int *index_file)
{
/*	Parameters:
 sx, sy - window size,
 ftp_dir - what FTP directory to use,
 slot - in what slot should an image go (common: #6 for 5.25' 140Kb floppy disks, and #7 for hard-disks).
 	slot #5 - for 800Kb floppy disks, but we do not use them in Apple][?
	(They are as a rule with .2mg extension)
 index_file	- from which file we should start cursor (should be static and 0 when changing dir)

 Out:	filename	- chosen file name (or dir name)
	isdir		- if chosen name is a directory
*/
		double facx = double(g_ScreenWidth) / double(SCREEN_WIDTH);
		double facy = double(g_ScreenHeight) / double(SCREEN_HEIGHT);

	SDL_Surface *my_screen;	// for background
	struct ftpparse FTP_PARSE; // for parsing ftp directories
	
#ifndef _WIN32
	struct stat info;
#endif

	if(font_sfc == NULL)
		if(!fonts_initialization()) return false;	//if we don't have a fonts, we just can do none
	char tmpstr[512];
	char ftpdirpath [MAX_PATH];
	snprintf(ftpdirpath, MAX_PATH, "%s/%s%s", g_sFTPLocalDir, g_sFTPDirListing, md5str(ftp_dir));	// get path for FTP dir listing
//	printf("Dir: %s, MD5(dir)=%s\n",ftp_dir,ftpdirpath);

	List<char> files;		// our files
	List<char> sizes;		// and their sizes (or 'dir' for directories)

	int act_file;		// current file
	int first_file;		// from which we output files
	char ch = 0;
// prepare screen
	SDL_Surface *tempSurface;

	if(!g_WindowResized) {
		if(g_nAppMode == MODE_LOGO) tempSurface = g_hLogoBitmap;	// use logobitmap
			else tempSurface = g_hDeviceBitmap;
	}
	else tempSurface = g_origscreen;

	my_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, tempSurface->w, tempSurface->h, tempSurface->format->BitsPerPixel, 0, 0, 0, 0);
	if(tempSurface->format->palette && my_screen->format->palette)
		SDL_SetColors(my_screen, tempSurface->format->palette->colors,
			      0, tempSurface->format->palette->ncolors);

	surface_fader(my_screen, 0.2F, 0.2F, 0.2F, -1, 0);	// fade it out to 20% of normal
	SDL_BlitSurface(tempSurface, NULL, my_screen, NULL);
	SDL_BlitSurface(my_screen, NULL, screen, NULL);		// show background
//	ch = 0;
	#define	NORMAL_LENGTH 60
	if(strlen(ftp_dir) > NORMAL_LENGTH) { ch = ftp_dir[NORMAL_LENGTH]; ftp_dir[NORMAL_LENGTH] = 0;} //cut-off too long string
	font_print_centered(sx/2 ,5 * facy , ftp_dir, screen, 1.5 * facx, 1.3 * facy);
	if(ch) ftp_dir[NORMAL_LENGTH] = ch; //restore cut-off char	

	font_print_centered(sx/2,20 * facy, "Connecting to FTP server... Please wait.", screen, 1 * facx, 1 * facy);
	SDL_Flip(screen);	// show the screen

	bool OKI;
#ifndef _WIN32
	if(stat(ftpdirpath,&info) == 0 && info.st_mtime > time(NULL) - RENEW_TIME) {
		OKI = false; // use this file
	}
	else {
		OKI = ftp_get(ftp_dir, ftpdirpath); // get ftp dir listing
	}
#else
// in WIN32 let's use constant caching? -- need to be redone using file.mtime
	if(GetFileAttributes(ftpdirpath) != DWORD(-1)) OKI = false;
		else OKI = ftp_get(ftp_dir,ftpdirpath); // get ftp dir listing
#endif

	if(OKI) {	// error
		printf("Failed getting FTP directory %s to %s\n",ftp_dir,ftpdirpath);	
		font_print_centered(sx/2,30 * facy, "Failure. Press any key!",screen, 1.4 * facx, 1.1 * facy);
		SDL_Flip(screen);	// show the screen
		SDL_Delay(KEY_DELAY);	// wait some time to be not too fast
		//////////////////////////////////
		// Wait for keypress
		//////////////////////////////////
		SDL_Event event;	// event
		Uint8 *keyboard;	// key state

		event.type = SDL_QUIT;
		while(event.type != SDL_KEYDOWN) {	// wait for key pressed
					SDL_Delay(100);
					SDL_PollEvent(&event);
		}
		SDL_FreeSurface(my_screen);		
		return false;	
	 }

		FILE *fdir = fopen(ftpdirpath,"r");
	
		char *tmp;
		int i,j, B, N;	// for cycles, beginning and end of list

// build prev dir
	if(strcmp(ftp_dir, "ftp://")) {
		tmp = new char[3];
		strcpy(tmp, "..");
		files.Add(tmp);
		tmp = new char[5];
		strcpy(tmp, "<UP>");
		sizes.Add(tmp);	// add sign of directory
		B = 1;
	}
	else	B = 0;	// for sorting dirs 

			while (tmp = fgets(tmpstr,512,fdir)) // first looking for directories
			{
				// clear and then try to fill in FTP_PARSE struct
				memset(&FTP_PARSE,0,sizeof(FTP_PARSE));
				ftpparse(&FTP_PARSE, tmp, strlen(tmp));
				
				int what = getstatFTP(&FTP_PARSE, NULL);
				
				if (strlen(FTP_PARSE.name) > 0 &&  what == 1) // is directory!
				{
					tmp = new char[strlen(FTP_PARSE.name)+1];	// add entity to list
					strcpy(tmp, FTP_PARSE.name);
					files.Add(tmp);
					tmp = new char[6];
					strcpy(tmp, "<DIR>");
					sizes.Add(tmp);	// add sign of directory
				} /* if */

			}
// sort directories. Please, don't laugh at my bubble sorting - it the simplest thing I've ever seen --bb
			if(files.Length() > 2)
			{
				N = files.Length() - 1;
//				B = 1; - defined above
				for(i = N; i > B; i--)
					for(j = B; j < i; j++)
						if(strcasecmp(files[j], files[j + 1]) > 0)
						{
							files.Swap(j,j + 1);
							sizes.Swap(j,j + 1);
						}

			}
			B = files.Length();	// start for files

			(void) rewind (fdir);	// to the start
				// now get all regular files
			while (tmp = fgets(tmpstr,512,fdir))
			{
				int fsize;
				// clear and then try to fill in FTP_PARSE struct
				memset(&FTP_PARSE,0,sizeof(FTP_PARSE));
				ftpparse(&FTP_PARSE, tmp, strlen(tmp));
				
				if ((getstatFTP(&FTP_PARSE, &fsize) == 2)) // is normal file!
				{
					tmp = new char[strlen(FTP_PARSE.name)+1];	// add this entity to list
					strcpy(tmp, FTP_PARSE.name);
					files.Add(tmp);
					tmp = new char[10];	// 1400000KB
					snprintf(tmp, 9, "%dKB", fsize);
					sizes.Add(tmp);	// add this size to list
				} /* if */
			}
			(void) fclose (fdir);
// do sorting for files
			if(files.Length() > 2 && B < files.Length())
			{
				N = files.Length() - 1;
//				B = 1;
				for(i = N; i > B; i--)
					for(j = B; j < i; j++)
						if(strcasecmp(files[j], files[j + 1]) > 0)
						{
							files.Swap(j,j + 1);
							sizes.Swap(j,j + 1);
						}
			}
//	Count out cursor position and file number output
	act_file = *index_file;
	if(act_file >= files.Length()) act_file = 0;		// cannot be more than files in list
	first_file = act_file - (FILES_IN_SCREEN / 2);
	if (first_file < 0) first_file = 0;	// cannot be negativ...

// Show all directories (first) and files then
//	char *tmp;
	char *siz;
//	int i;

	while(true)
	{
		SDL_BlitSurface(my_screen, NULL, screen, NULL);		// show background
		font_print_centered(sx/2 ,5 * facy , ftp_dir, screen, 1.5 * facx, 1.3 * facy);
		if (slot == 6) font_print_centered(sx/2,20 * facy,"Choose image for floppy 140KB drive", screen, 1 * facx, 1 * facy);
		else
			if (slot == 7) font_print_centered(sx/2,20 * facy,"Choose image for Hard Disk", screen, 1 * facx, 1 * facy);
		else
			if (slot == 5) font_print_centered(sx/2,20 * facy,"Choose image for floppy 800KB drive", screen, 1 * facx, 1 * facy);
		else
			if (slot == 1) font_print_centered(sx/2,20 * facy,"Select file name for saving snapshot", screen, 1 * facx, 1 * facy);
		else
			if (slot == 0) font_print_centered(sx/2,20 * facy,"Select snapshot file name for loading", screen, 1 * facx, 1 * facy);

		font_print_centered(sx/2,30 * facy, "Press ENTER to choose, or ESC to cancel",screen, 1.4 * facx, 1.1 * facy);

		files.Rewind();	// from start
		sizes.Rewind();
		i = 0;

//		printf("We've printed some messages, go to file list!\n");
// show all fetched dirs and files
// topX of first fiel visible
		int TOPX	= 45 * facy;

		while(files.Iterate(tmp)) {
			sizes.Iterate(siz);	// also fetch size string

			if (i >= first_file && i < first_file + FILES_IN_SCREEN)
			{ // FILES_IN_SCREEN items on screen
//				char tmp2[80],tmp3[256];

				if (i == act_file) { // show item under cursor (in inverse mode)
					SDL_Rect r;
					r.x= 2;
					r.y= TOPX + (i-first_file) * 15 * facy - 1;
					if(strlen(tmp) > 46) r.w = 46 * 6 * 1.7 * facx + 2;
					   else r.w= strlen(tmp) * 6 * 1.7 * facx + 2;	// 6- FONT_SIZE_X
					r.h= 9 * 1.5 * facy;
					SDL_FillRect(screen, &r, SDL_MapRGB(screen->format,255,0,0));// in RED
				} /* if */

				// print file name with enlarged font
				ch = 0;
				if(strlen(tmp) > 46) { ch = tmp[46]; tmp[46] = 0;} //cut-off too long string
				font_print(4, TOPX + (i - first_file) * 15 * facy, tmp, screen, 1.7 * facx, 1.5 * facy); // show name
				font_print(sx - 70*facx, TOPX + (i - first_file) * 15 * facy, siz, screen, 1.7 * facx, 1.5 * facy);// show info (dir or size)
				if(ch) tmp[46] = ch; //restore cut-off char
			} /* if */
			i++;		// next item
		} /* while */

/////////////////////////////////////////////////////////////////////////////////////////////
// draw rectangles
	rectangle(screen, 0, TOPX - 5, g_ScreenWidth, 320 * facy, SDL_MapRGB(screen->format, 255, 255, 255));
	rectangle(screen, 480 * facx, TOPX - 5, 0, 320 * facy, SDL_MapRGB(screen->format, 255, 255, 255));

	SDL_Flip(screen);	// show the screen
	SDL_Delay(KEY_DELAY);	// wait some time to be not too fast

	//////////////////////////////////
	// Wait for keypress
	//////////////////////////////////
	SDL_Event event;	// event
	Uint8 *keyboard;	// key state

	event.type = SDL_QUIT;
	while(event.type != SDL_KEYDOWN) {	// wait for key pressed
				SDL_Delay(10);
				SDL_PollEvent(&event);
	}

// control cursor
		keyboard = SDL_GetKeyState(NULL);	// get current state of pressed (and not pressed) keys
		if (keyboard[SDLK_UP] || keyboard[SDLK_LEFT]) {
			if (act_file>0) act_file--;	// up one position
			if (act_file<first_file) first_file=act_file;
		} /* if */

		if (keyboard[SDLK_DOWN] || keyboard[SDLK_RIGHT]) {
			if (act_file < (files.Length() - 1)) act_file++;
			if (act_file >= (first_file + FILES_IN_SCREEN)) first_file=act_file - FILES_IN_SCREEN + 1;
		} /* if */

		if (keyboard[SDLK_PAGEUP]) {
			act_file-=FILES_IN_SCREEN;
			if (act_file<0) act_file=0;
			if (act_file<first_file) first_file=act_file;
		} /* if */

		if (keyboard[SDLK_PAGEDOWN]) {
			act_file+=FILES_IN_SCREEN;
			if (act_file>=files.Length()) act_file=(files.Length()-1);
			if (act_file>=(first_file+FILES_IN_SCREEN)) first_file=act_file-FILES_IN_SCREEN + 1;
		} /* if */

		// choose an item?
		if (keyboard[SDLK_RETURN]) {
			// dup string from selected file name
			*filename = strdup(php_trim(files[act_file],strlen(files[act_file])));
//			printf("files[act_file]=%s, *filename=%s\n\n", files[act_file], *filename);
			if(!strcmp(sizes[act_file], "<DIR>") || !strcmp(sizes[act_file], "<UP>"))
			   		*isdir = true;
				else *isdir = false;	// this is directory (catalog in Apple][ terminology)
			*index_file = act_file;	// remember current index
			files.Delete();
			sizes.Delete();
			SDL_FreeSurface(my_screen);

			return true;
		} /* if */

		if (keyboard[SDLK_ESCAPE]) {
			files.Delete();
			sizes.Delete();
			SDL_FreeSurface(my_screen);
			return false;		// ESC has been pressed
		} /* if */

		if (keyboard[SDLK_HOME]) {	// HOME?
			act_file=0;
			first_file=0;
		} /* if */
		if (keyboard[SDLK_END]) {	// END?
			act_file=files.Length() - 1;	// go to the last possible file in list
			first_file=act_file - FILES_IN_SCREEN + 1;
			if(first_file < 0) first_file = 0;
		} /* if */

	}
} /* ChooseAnImageFTP */
Beispiel #7
0
int main(void)
{
	video_init();

	int ret = SifLoadModule("mass:/ds3ps2.irx", 0, NULL);
	if (ret < 0) {
		char *txt = "Could not find 'mass:/ds3ps2.irx'";
		while (1) {
			clear_screen();
			font_print(5, 10, txt);
			flip_screen();
		}
	}

	struct ds3_input ds3_1, ds3_2;
	memset(&ds3_1, 0x0, sizeof(struct ds3_input));
	memset(&ds3_2, 0x0, sizeof(struct ds3_input));

	ds3ps2_init();

	float pos_x = gsGlobal->Width/2, pos_y = gsGlobal->Height/2;
	char text_connected[64];
	int led = 1, old_r1 = 0;

	while (!(ds3_1.PS && ds3_1.start)) {
		clear_screen();

		ds3ps2_get_input(DS3PS2_SLOT_1, (void*)&ds3_1);
		ds3ps2_get_input(DS3PS2_SLOT_2, (void*)&ds3_2);

		if (ds3_1.L1) {
			pos_x = gsGlobal->Width/2;
			pos_y = gsGlobal->Height/2;
		}
		if (ds3_1.R1 && !old_r1) {
			led++;
			if (led > 7) led = 0;
			ds3ps2_set_led(DS3PS2_SLOT_1, led);
			ds3ps2_send_ledsrumble(DS3PS2_SLOT_1);
		}
		old_r1 = ds3_1.R1;

		#define THRESHOLD 5.0f
		if (fabs(ds3_1.accelY) > THRESHOLD)
			pos_y -= ds3_1.accelY;
		if (fabs(ds3_1.gyroZ) > THRESHOLD)
			pos_x -= ds3_1.gyroZ/5.0f;

		draw_circle(gsGlobal, pos_x, pos_y, 19, CircleColor, 0);
		draw_circle(gsGlobal, pos_x, pos_y, 18, CircleColor, 0);
		draw_circle(gsGlobal, pos_x, pos_y, 17, CircleColor, 0);
		draw_circle(gsGlobal, pos_x, pos_y, 16, CircleColor, 0);

		sprintf(text_connected, "connected: SLOT_1 %i	SLOT_2 %i",
			ds3ps2_slot_connected(DS3PS2_SLOT_1),
			ds3ps2_slot_connected(DS3PS2_SLOT_2));
		font_print(5, 10, text_connected);

		int y = print_data(30, &ds3_1);
		print_data(y+10, &ds3_2);

		flip_screen();
	}

	return 0;
}
bool state_chooseship_cycle(SDL_Surface *screen,int sx,int sy,unsigned char *keyboard)
{
	if (SUBSTATE==0) {
		if (image!=0) SDL_FreeSurface(image);
		if (image2!=0) SDL_FreeSurface(image);
		image=IMG_Load("graphics/tittle.pcx");
		image2=IMG_Load("graphics/tiles.pcx");
		SDL_SetColorKey(image2,SDL_SRCCOLORKEY,SDL_MapRGB(image2->format,0,0,0));
	} /* if */ 


	SDL_BlitSurface(image,0,screen,0);
	surface_fader(screen,0.5F,0.5F,0.5F,-1,0);

	font_print_centered(sx/2,40,"CHOOSE YOUR SHIP:",screen);
	font_print(100,60,"SHADOW RUNNER:",screen);
	font_print(100,70," - HIGH SPEED AND RETRO THRUSTERS.",screen);
	font_print(100,80," - LOW POWERED WEAPONS.",screen);

	font_print(100,100,"V-PANTHER 2:",screen);
	font_print(100,110," - MODERATE SPEED.",screen);
	font_print(100,120," - MEDIUM POWERED WEAPONS.",screen);

	font_print(100,140,"X-TERMINATOR:",screen);
	font_print(100,150," - LOW SPEED.",screen);
	font_print(100,160," - HIGH POWERED WEAPONS.",screen);

	rectangle(screen,60,56+40*ship_type,32,32,SDL_MapRGB(screen->format,255,255,255));

	{
		SDL_Rect r,d;

		r.x=96; r.y=272;
		r.w=32; r.h=32;
		d.x=60; d.y=60;
		SDL_BlitSurface(image2,&r,screen,&d);
		r.x=32; r.y=240;
		r.w=32; r.h=32;
		d.x=60; d.y=100;
		SDL_BlitSurface(image2,&r,screen,&d);
		r.x=96; r.y=336;
		r.w=32; r.h=32;
		d.x=60; d.y=140;
		SDL_BlitSurface(image2,&r,screen,&d);
	}
	
	if (SUBSTATE<32) {
		surface_fader(screen,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,-1,0);
		SUBSTATE++;
	} /* if */ 
	if (SUBSTATE>32) {
		surface_fader(screen,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,-1,0);
		SUBSTATE++;
		if (SUBSTATE==64) {
			SDL_FreeSurface(image);
			image=0;
			SDL_FreeSurface(image2);
			image2=0;

			if (SUBSTATE2==0) {
				STATE=5;
				SUBSTATE=0;
			} /* if */ 
			if (SUBSTATE2==1) {
				STATE=1;
				SUBSTATE=0;
			} /* if */ 
		} /* if */ 
	} /* if */ 

	if (SUBSTATE==32) {
		if (keyboard[SDLK_LEFT] && !old_keyboard[SDLK_LEFT] && ship_type>0) ship_type--;
		if (keyboard[SDLK_RIGHT] && !old_keyboard[SDLK_RIGHT] && ship_type<2) ship_type++;
		if (keyboard[SDLK_UP] && !old_keyboard[SDLK_UP] && ship_type>0) ship_type--;
		if (keyboard[SDLK_DOWN] && !old_keyboard[SDLK_DOWN] && ship_type<2) ship_type++;
		if (keyboard[SDLK_SPACE] && !old_keyboard[SDLK_SPACE]) {
			SUBSTATE++;
			SUBSTATE2=0;
		} /* if */ 
		if (keyboard[SDLK_ESCAPE] && !old_keyboard[SDLK_ESCAPE]) {
			SUBSTATE++;
			SUBSTATE2=1;
		} /* if */ 
	} /* if */ 	

	return true;
} /* state_chooseship_cycle */ 
Beispiel #9
0
void TheGooniesApp::howtoplay_draw(void)
{
    glClearColor(0, 0, 0, 1);
    glClear(GL_COLOR_BUFFER_BIT);

    switch (m_howtoplay_state) {
	case 0:
	case 1:
		if (m_test_game != 0) {
			float f = 1;

			if (m_howtoplay_state == 0)
				f = float(m_howtoplay_cycle) / 50;
			if (m_howtoplay_state == 1)
				f = 1;

			m_test_game->draw(m_GLTM);

			if (m_howtoplay_cycle > 50 && m_howtoplay_cycle < 200) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "move sloth around using", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "the right and left key", -2);
			}
			if (m_howtoplay_cycle > 225 && m_howtoplay_cycle < 325) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "press up to jump", -2);
			}
			if (m_howtoplay_cycle > 350 && m_howtoplay_cycle < 475) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "pick up keys by", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "walking over them", -2);
			}
			if (m_howtoplay_cycle > 500 && m_howtoplay_cycle < 700) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "climb vines by walking", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "to them and using the up", -2);
				font_print_c(320, 390, 0, 0, 0.5f, "font_hl", "and down keys", -2);
			}
			if (m_howtoplay_cycle > 725 && m_howtoplay_cycle < 850) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "avoid contact with enemies", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "to prevent damage", -2);
			}
			if (m_howtoplay_cycle > 875 && m_howtoplay_cycle < 1000) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "make sloth attack using", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "the fire key", -2);
			}
			if (m_howtoplay_cycle > 1050 && m_howtoplay_cycle < 1250) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "kill enemies by punching", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "them", -2);
			}
			if (m_howtoplay_cycle > 1250 && m_howtoplay_cycle < 1350) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "locks can be opened if", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "you have a key", -2);
			}
			if (m_howtoplay_cycle > 1400 && m_howtoplay_cycle < 1550) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "rescue the seven goonies", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "to complete a level", -2);
			}
			if (m_howtoplay_cycle > 1600 && m_howtoplay_cycle < 1750) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "you can enter skull doors", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "with the up key", -2);
			}
			if (m_howtoplay_cycle > 1850 && m_howtoplay_cycle < 2100) {
				font_print_c(320, 350, 0, 0, 0.5f, "font_hl", "once you have rescued the", -2);
				font_print_c(320, 370, 0, 0, 0.5f, "font_hl", "seven goonies, head to the", -2);
				font_print_c(320, 390, 0, 0, 0.5f, "font_hl", "exit door and enter", -2);
			}

			if (f != 1) {
				m_GLTM->get
				("bg_copyright")->draw(1, 1, 1, 1 - f, 0, 0, 0, 0, 1);
				m_GLTM->get_smooth("title_logo")->draw(1, 1, 1, 1 - f, 46, 17, 0, 0, 1);
			}
		} else {
			m_GLTM->get
			("bg_copyright")->draw(0, 0, 0, 0, 1);
			m_GLTM->get_smooth("title_logo")->draw(46, 17, 0, 0, 1);
		}
		break;
	case 2:
		{
			m_test_game->draw(m_GLTM);

			float f = 1;
			f = float(m_howtoplay_cycle) / 50;
            glColor4f(0, 0, 0, f);
			glNormal3f(0.0, 0.0, 1.0);
#ifndef HAVE_GLES
			glBegin(GL_QUADS);
			glVertex3f(0, 0, 0);
			glVertex3f(0, 480, 0);
			glVertex3f(640, 480, 0);
			glVertex3f(640, 0, 0);
			glEnd();
#else
		GLfloat vtx1[] = {
		0, 0, 0,
		0, 480, 0,
		640, 480, 0,
		640, 0, 0
		};

      glEnableClientState(GL_VERTEX_ARRAY);
 
      glVertexPointer(3, GL_FLOAT, 0, vtx1);
      glDrawArrays(GL_TRIANGLE_FAN,0,4);
 
      glDisableClientState(GL_VERTEX_ARRAY);
#endif
		}
		break;
	case 3:
	case 4:
	case 5:
		{
			int i;
			float f1 = 0;
			char *item_tiles[]={"it_bag",
								"it_shoes",
								"it_hammer",
								"it_lamp",
								"it_clock",
								"it_purpleshield",
								"it_yellowshield",
								"it_whiteshield"
								};
			char *item_descriptions[]={"increases life or experience",
									   "let you run faster",
									   "drops will turn into coins",
									   "shows hidden bags",
									   "stops time!",
									   "protects you from bones",
									   "protects you from gunshots",
									   "protects you from musical notes"
									   	};

			if (m_howtoplay_state==3) {
				f1 = (m_howtoplay_cycle -75)/50.0f;
				if (f1>0) f1 = 0;
			} // if 
			if (m_howtoplay_state==5) {
				f1 = (m_howtoplay_cycle)/50.0f;
				if (f1<0) f1 = 0;
			} // if 
			if (f1>0) f1=f1*f1;
				 else f1=-f1*f1;
			font_print_c(int(320 - 640*f1), 10, 0, 0, 0.5f, "font_hl", "effect of special objects (1/3)", -2);

			for(i=0;i<8;i++) {
				if (m_howtoplay_state==3) {
					f1 = (m_howtoplay_cycle - 75 - i*5)/50.0f;
					if (f1>0) f1 = 0;
				} // if 
				if (m_howtoplay_state==4) {
					f1 = (m_howtoplay_cycle - i*5)/50.0f;
					if (f1>0) f1 = 0;
				} // if 
				if (m_howtoplay_state==5) {
					f1 = (m_howtoplay_cycle - i*5)/50.0f;
					if (f1<0) f1 = 0;
				} // if 
				if (f1>0) f1=f1*f1;
					 else f1=-f1*f1;
				m_GLTM->get(item_tiles[i])->draw(float(75 - 640*f1), float(50+52*i), 0, 0, 2);
				font_print(int(140 - 640*f1), int(58+52*i), 0, 0, 0.5f, "font", item_descriptions[i], -2);
			} // for
		}
		break;
	case 6:
	case 7:
	case 8:
		{
			int i;
			float f1 = 0;
			char *item_tiles[]={
								"it_yellowhelmet",
								"it_lightbluehelmet",
								"it_greencoat",
								"it_greycoat",
								"it_yellowcoat",
								"it_lightbluecoat",
								"it_redbook",
								"it_lightbluebook",
								};
			char *item_descriptions[]={
									   "protects you from falling rocks",
									   "protects you from bats",
									   "protects you from flames",
									   "protects you from water drops",
									   "protects you from steam",
									   "protects you from waterfalls",
									   "easily kill ghosts",
									   "kills bats by touch",
										};

			if (m_howtoplay_state==6) {
				f1 = (m_howtoplay_cycle -75)/50.0f;
				if (f1>0) f1 = 0;
			} // if 
			if (m_howtoplay_state==8) {
				f1 = (m_howtoplay_cycle)/50.0f;
				if (f1<0) f1 = 0;
			} // if 
			if (f1>0) f1=f1*f1;
				 else f1=-f1*f1;
			font_print_c(int(320 - 640*f1), 10, 0, 0, 0.5f, "font_hl", "effect of special objects (2/3)", -2);

			for(i=0;i<8;i++) {
				if (m_howtoplay_state==6) {
					f1 = (m_howtoplay_cycle - 75 - i*5)/50.0f;
					if (f1>0) f1 = 0;
				} // if 
				if (m_howtoplay_state==7) {
					f1 = (m_howtoplay_cycle - i*5)/50.0f;
					if (f1>0) f1 = 0;
				} // if 
				if (m_howtoplay_state==8) {
					f1 = (m_howtoplay_cycle - i*5)/50.0f;
					if (f1<0) f1 = 0;
				} // if 
				if (f1>0) f1=f1*f1;
					 else f1=-f1*f1;
				m_GLTM->get(item_tiles[i])->draw(float(75 - 640*f1), float(50+52*i), 0, 0, 2);
				font_print(int(140 - 640*f1), int(58+52*i), 0, 0, 0.5f, "font", item_descriptions[i], -2);
			} // for
		}
		break;
	case 9:
	case 10:
	case 11:
		{
			int i;
			float f1 = 0;
			char *item_tiles[]={"it_bluebook",
								"it_whitebook",
								"it_greenbook",
								"it_purplebook",
								"it_yellowbook",
								"it_purpleanti",
								"it_redanti",
								"it_blueanti"};
			char *item_descriptions[]={"protects you from skulls",
									   "kills skeletons by touch",
									   "kills skulls by touch",									
									   "fratellies won't be able to shoot",
									   "protects you from skeletons",
									   "skeletons will walk faster",
									   "fratellies will walk faster",
									   "will awake ghosts"
										};

			if (m_howtoplay_state==9) {
				f1 = (m_howtoplay_cycle -75)/50.0f;
				if (f1>0) f1 = 0;
			} // if 
			if (m_howtoplay_state==11) {
				f1 = (m_howtoplay_cycle)/50.0f;
				if (f1<0) f1 = 0;
			} // if 
			if (f1>0) f1=f1*f1;
				 else f1=-f1*f1;
			font_print_c(int(320 - 640*f1), 10, 0, 0, 0.5f, "font_hl", "effect of special objects (3/3)", -2);

			for(i=0;i<8;i++) {
				if (m_howtoplay_state==9) {
					f1 = (m_howtoplay_cycle - 75 - i*5)/50.0f;
					if (f1>0) f1 = 0;
				} // if 
				if (m_howtoplay_state==10) {
					f1 = (m_howtoplay_cycle - i*5)/50.0f;
					if (f1>0) f1 = 0;
				} // if 
				if (m_howtoplay_state==11) {
					f1 = (m_howtoplay_cycle - i*5)/50.0f;
					if (f1<0) f1 = 0;
				} // if 
				if (f1>0) f1=f1*f1;
					 else f1=-f1*f1;
				m_GLTM->get(item_tiles[i])->draw(float(75 - 640*f1), float(50+52*i), 0, 0, 2);
				font_print(int(140 - 640*f1), int(58+52*i), 0, 0, 0.5f, "font", item_descriptions[i], -2);
			} // for
		}
		break;

	case 100:
		{
			float f = 1;
			f = float(m_howtoplay_cycle) / 50;

			m_GLTM->get
			("bg_copyright")->draw(1, 1, 1, f, 0, 0, 0, 0, 1);
			m_GLTM->get_smooth("title_logo")->draw(1, 1, 1, f, 46, 17, 0, 0, 1);
		}
		break;
	} // switch
}
bool state_replaymanager_cycle(SDL_Surface *screen,int sx,int sy,unsigned char *keyboard)
{
	if (SUBSTATE==0) {
		if (image!=0) SDL_FreeSurface(image);
		image=IMG_Load("graphics/tittle.png");
		refind_files=true;
		SUBSTATE2=0;
	} /* if */ 

	if (refind_files) {

		refind_files=false;
		files.Delete();
#ifdef _WIN32
		/* Find files: */ 
		WIN32_FIND_DATA finfo;
		HANDLE h;

		if (replay_source==0) h=FindFirstFile("replays/*.rpl",&finfo);
						 else h=FindFirstFile("high/*.rpl",&finfo);
		if (h!=INVALID_HANDLE_VALUE) {
			char *tmp;

			tmp=new char[strlen(finfo.cFileName)+1];
			strcpy(tmp,finfo.cFileName);
			files.Add(tmp);

			while(FindNextFile(h,&finfo)==TRUE) {
				char *tmp;

				tmp=new char[strlen(finfo.cFileName)+1];
				strcpy(tmp,finfo.cFileName);
				files.Add(tmp);
			} /* while */ 
		} /* if */ 
#else
		DIR *dp;
		struct dirent *ep;
		  
		if (replay_source==0) dp = opendir (replay_dir);
						 else dp = opendir (high_dir);
		if (dp != NULL)
		 {
			while (ep = readdir (dp))
			 {
                            char *tmp;
                         
                            if (strlen(ep->d_name)>4 &&
                                ep->d_name[strlen(ep->d_name)-4]=='.' &&
                                ep->d_name[strlen(ep->d_name)-3]=='r' &&
                                ep->d_name[strlen(ep->d_name)-2]=='p' &&
                                ep->d_name[strlen(ep->d_name)-1]=='l') {
                                tmp=new char[strlen(ep->d_name)+1];
                                strcpy(tmp,ep->d_name);
                                files.Add(tmp);                                    
                            } /* if */
                               
			 }
			(void) closedir (dp);
		 }
#endif                          
		first_file=0;
		act_file=0;		
	} /* if */ 

	SDL_BlitSurface(image,0,screen,0);
	surface_fader(screen,0.5F,0.5F,0.5F,-1,0);


	if (replay_source==0) font_print_centered(sx/2,20,"REPLAY FILES [L - CHANGE SOURCE]:",screen);
					 else font_print_centered(sx/2,20,"HIGH SCORE FILES [L - CHANGE SOURCE]:",screen);
	if (replay_source!=0) font_print_centered(sx/2,30,"PRESS FIRE TO VIEW OR R TO REBUILD",screen);
	
	{
		char *tmp;
		int i;

		files.Rewind();
		i=0;
		while(files.Iterate(tmp)) {
			if (i>=first_file &&
				i<first_file+18) {
				char *sname[3]={"SH.RNR.","PNTR.2","X-TRM."};
				int ship,length;
				char tmp2[256],tmp3[256];

				if (i==act_file) {
					SDL_Rect r;
					r.x=2;
					r.y=42+(i-first_file)*10-1;
					r.w=strlen(tmp)*6+2;
					r.h=9;
					SDL_FillRect(screen,&r,SDL_MapRGB(screen->format,255,0,0));
				} /* if */ 
				font_print(4,42+(i-first_file)*10,tmp,screen);
				
				if (replay_source==0) snprintf(tmp2, sizeof(tmp2), "%s/%s",replay_dir, tmp);
								 else snprintf(tmp2, sizeof(tmp2), "%s/%s",high_dir, tmp);
				replay_parameters(tmp2,&ship,&length,tmp3);
				{
					int min,sec,dec;

					dec=(length*18)/10;
					sec=dec/100;
					dec=dec%100;
					min=sec/60;
					sec=sec%60;
					sprintf(tmp2,"%.2i:%.2i'%.2i %s",min,sec,dec,sname[ship]);
					font_print(220,42+(i-first_file)*10,tmp2,screen);
				}

			} /* if */ 
			i++;
		} /* while */ 
	} 

	rectangle(screen,-1,40,321,185,SDL_MapRGB(screen->format,255,255,255));
	rectangle(screen,214,40,0,185,SDL_MapRGB(screen->format,255,255,255));

	if (SUBSTATE<32) {
		surface_fader(screen,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,float(SUBSTATE)/32.0F,-1,0);
		SUBSTATE++;
	} /* if */ 
	if (SUBSTATE>32) {
		surface_fader(screen,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,float(64-SUBSTATE)/32.0F,-1,0);
		SUBSTATE++;
		if (SUBSTATE==64) {
			SDL_FreeSurface(image);
			image=0;

			if (SUBSTATE2==0) {
				STATE=1;
				SUBSTATE=0;
			} /* if */ 
			if (SUBSTATE2==1) {
				int i;
				char tmp[256];
				char levelname[256];
				int v1,v2;
				int fuel;
				STATE=8;
				SUBSTATE=0;

				if (replay_source==0) snprintf(tmp,sizeof(tmp), "%s/%s", replay_dir, files[act_file]);
								 else snprintf(tmp, sizeof(tmp), "%s/%s",high_dir, files[act_file]);
				replayfile=fopen(tmp,"rb");
				v1=fgetc(replayfile);
				v2=fgetc(replayfile);	// To maintain compatibility with a previous version

				level=0;
				for(i=0;i<256;i++) levelname[i]=fgetc(replayfile);
				fuel=fgetc(replayfile);

				ship_type=fgetc(replayfile);
				game=new TRANSBALL("graphics/","sound/","maps/",fuel,levelname,ship_type);

				timer=0;
			} /* if */ 
		} /* if */ 
	} /* if */ 

	if (SUBSTATE==32) {
		if ((keyboard[SDLK_UP] && !old_keyboard[SDLK_UP]) ||
			(keyboard[SDLK_LEFT] && !old_keyboard[SDLK_LEFT])) {
			if (act_file>0) act_file--;
			if (act_file<first_file) first_file=act_file;
		} /* if */ 

		if ((keyboard[SDLK_DOWN] && !old_keyboard[SDLK_DOWN]) ||
			(keyboard[SDLK_RIGHT] && !old_keyboard[SDLK_RIGHT])) {
			if (act_file<(files.Length()-1)) act_file++;
			if (act_file>=(first_file+18)) first_file=act_file-17;
		} /* if */ 

		if (keyboard[SDLK_PAGEUP] && !old_keyboard[SDLK_PAGEUP]) {
			act_file-=18;
			if (act_file<0) act_file=0;
			if (act_file<first_file) first_file=act_file;
		} /* if */ 

		if (keyboard[SDLK_PAGEDOWN] && !old_keyboard[SDLK_PAGEDOWN]) {
			act_file+=18;
			if (act_file>=files.Length()) act_file=(files.Length()-1);
			if (act_file>=(first_file+18)) first_file=act_file-17;
		} /* if */ 

		if (keyboard[SDLK_LCTRL] && !old_keyboard[SDLK_LCTRL]) {
			SUBSTATE2=1;
			if (files.EmptyP()) SUBSTATE2=0;
			SUBSTATE++;
		} /* if */ 

		if (keyboard[SDLK_ESCAPE] && !old_keyboard[SDLK_ESCAPE]) {
			SUBSTATE2=0;
			SUBSTATE++;
		} /* if */ 

		if (keyboard[SDLK_TAB] && !old_keyboard[SDLK_TAB]) {
			if (replay_source==0) replay_source=1;
							 else replay_source=0;
			act_file=0;
			first_file=0;
			refind_files=true;
		} /* if */ 
		
		if (keyboard[SDLK_BACKSPACE] && !old_keyboard[SDLK_BACKSPACE] && replay_source==1) {
			{
				List<char> replays;
				char *replay;
				char complete_replayname[256];

				/* look for files: */ 
#ifdef _WIN32
				WIN32_FIND_DATA finfo;
				HANDLE h;

				h=FindFirstFile("replays/*.rpl",&finfo);
				if (h!=INVALID_HANDLE_VALUE) {
					char *tmp;

					tmp=new char[strlen(finfo.cFileName)+1];
					strcpy(tmp,finfo.cFileName);
					files.Add(tmp);

					while(FindNextFile(h,&finfo)==TRUE) {
						char *tmp;

						tmp=new char[strlen(finfo.cFileName)+1];
						strcpy(tmp,finfo.cFileName);
						replays.Add(tmp);
					} /* while */ 
				} /* if */ 
#else
				DIR *dp;
				struct dirent *ep;
				  
				dp = opendir (replay_dir);
				if (dp != NULL)
				 {
					while (ep = readdir (dp))
					 {
									char *tmp;
                         
									if (strlen(ep->d_name)>4 &&
										ep->d_name[strlen(ep->d_name)-4]=='.' &&
										ep->d_name[strlen(ep->d_name)-3]=='r' &&
										ep->d_name[strlen(ep->d_name)-2]=='p' &&
										ep->d_name[strlen(ep->d_name)-1]=='l') {
										tmp=new char[strlen(ep->d_name)+1];
										strcpy(tmp,ep->d_name);
										replays.Add(tmp);                                    
									} /* if */
                               
					 }
					(void) closedir (dp);
				 }
#endif                  
				
				/* Check if this replay is a highscore: */ 
				replays.Rewind();
				while(replays.Iterate(replay)) {
					int level;
					int ship,current_time,previous_high=-1;
					char levelname[256];
					
					snprintf(complete_replayname, sizeof(complete_replayname), "%s/%s",replay_dir, replay);
					if (replay_parameters(complete_replayname,&ship,&current_time,levelname)==2) {
						for(level=0;level<NLEVELS;level++) {
							if (strcmp(levelname,levelnames[level])==0) {
								/* the replay corresponds to level 'i' of the current level pack: */ 

								/* UPDATE THE HIGHSCORES: */ 
								int best_time=-1;
								int i,j;
								char highname[256],filename2[256];

								previous_high=-1;

								j=0;

								snprintf(highname, sizeof(highname), "%s/", high_dir);
								j+=strlen(highname);
								for(i=0;levelpack[i]!='.' && levelpack[i]!=0;i++) highname[j++]=levelpack[i];
								highname[j++]='-';
								sprintf(highname+j,"%.3i",level);
								j+=3;
								highname[j++]='-';
								if (ship==0) highname[j++]='S';
								if (ship==0) highname[j++]='R';
								if (ship==1) highname[j++]='V';
								if (ship==1) highname[j++]='P';
								if (ship==2) highname[j++]='X';
								if (ship==2) highname[j++]='T';
								highname[j++]='.';
								highname[j++]='r';
								highname[j++]='p';
								highname[j++]='l';
								highname[j++]=0;

								{
									int retval;
									int s,l;
									char levelname[256];
									
									retval=replay_parameters(highname,&s,&l,levelname);

									if (retval==2) {
										previous_high=l;
									} /* if */ 
								}

								if (previous_high==-1 || previous_high>current_time) {
									snprintf(filename2, sizeof(filename2), "%s/%s",replay_dir, replay);
									replay_copy(filename2,highname);
								} /* if */ 

							} /* if */ 
						} /* if */ 

					} /* if */ 

				} /* while */ 
				
			}
			act_file=0;
			first_file=0;
			refind_files=true;
		} /* if */ 

	} /* if */ 

	return true;
} /* state_replaymanager_cycle */ 
Beispiel #11
0
bool state_game_cycle(SDL_Surface *screen,int sx,int sy,unsigned char *keyboard)
{
	int retval=0;

	if (keyboard[PAUSE_KEY] && !old_keyboard[PAUSE_KEY]) {
		if (pause) pause=false;
			  else pause=true;
	} /* if */ 

	if (!pause) {
		retval=game->cycle(keyboard);
		if (replayfile!=0) {
			fputc(keyboard[THRUST_KEY],replayfile);
			fputc(keyboard[ANTITHRUST_KEY],replayfile);
			fputc(keyboard[LEFT_KEY],replayfile);
			fputc(keyboard[RIGHT_KEY],replayfile);
			fputc(keyboard[FIRE_KEY],replayfile);
			fputc(keyboard[ATRACTOR_KEY],replayfile);
			fputc(retval,replayfile);
		} /* if */ 
	} /* if */ 

	game->render(screen,sx,sy);

	if (pause) {
		surface_fader(screen,0.5F,0.5F,0.5F,-1,0);
		font_print(sx/2,sy/2-16,"PAUSE",screen);
	} else {
		timer++;
	} /* if */ 

	/* Print time */ 
	{
		char tmp[128];
		int min,sec,dec;

		dec=(timer*18)/10;
		sec=dec/100;
		dec=dec%100;
		min=sec/60;
		sec=sec%60;
		sprintf(tmp,"%.2i:%.2i",min,sec);
		font_print_right(sx,0,tmp,screen);
	}

	if (retval!=0) {
		/* Retrieve statistics: */ 
//				timmer=game->get_statistics(0);
		used_fuel=game->get_statistics(1);
		remaining_fuel=game->get_statistics(2);
		n_shots=game->get_statistics(3);
		n_hits=game->get_statistics(4);
		enemies_destroyed=game->get_statistics(5);

		delete game;
		game=0;
		fclose(replayfile);
		replayfile=0;
	} /* if */ 
	if (retval==1) {
		STATE=5;
		SUBSTATE=0;
	} /* if */ 
	if (retval==2) {
		STATE=13;
		SUBSTATE=0;
	} /* if */ 
	if (retval==3) {
		STATE=9;
		SUBSTATE=0;
	} /* if */ 

	return true;
} /* state_game_cycle */ 
Beispiel #12
0
void G_Browser::draw(float alpha)
{
	glColor4f(0,0,0,alpha*0.5f);
#if !defined(HAVE_GLES)
	glBegin(GL_QUADS);
	glVertex3f(m_x,m_y,0);
	glVertex3f(m_x+m_dx,m_y,0);
	glVertex3f(m_x+m_dx,m_y+m_dy,0);
	glVertex3f(m_x,m_y+m_dy,0);

	glVertex3f(m_x,m_y,0);
	glVertex3f(m_x+m_dx,m_y,0);
	glVertex3f(m_x+m_dx,m_y+4,0);
	glVertex3f(m_x,m_y+4,0);

	glVertex3f(m_x,m_y,0);
	glVertex3f(m_x+4,m_y,0);
	glVertex3f(m_x+4,m_y+m_dy,0);
	glVertex3f(m_x,m_y+m_dy,0);

	glVertex3f(m_x+m_dx-4,m_y,0);
	glVertex3f(m_x+m_dx,m_y,0);
	glVertex3f(m_x+m_dx,m_y+m_dy,0);
	glVertex3f(m_x+m_dx-4,m_y+m_dy,0);

	glVertex3f(m_x,m_y+m_dy-4,0);
	glVertex3f(m_x+m_dx,m_y+m_dy-4,0);
	glVertex3f(m_x+m_dx,m_y+m_dy,0);
	glVertex3f(m_x,m_y+m_dy,0);	
	glEnd();
#else
	GLfloat vtx3[] = {
	m_x,m_y,0,
	m_x+m_dx,m_y,0,
	m_x+m_dx,m_y+m_dy,0,
	m_x,m_y+m_dy,0,

	m_x,m_y,0,
	m_x+m_dx,m_y,0,
	m_x+m_dx,m_y+4,0,
	m_x,m_y+4,0,

	m_x,m_y,0,
	m_x+4,m_y,0,
	m_x+4,m_y+m_dy,0,
	m_x,m_y+m_dy,0,

	m_x+m_dx-4,m_y,0,
	m_x+m_dx,m_y,0,
	m_x+m_dx,m_y+m_dy,0,
	m_x+m_dx-4,m_y+m_dy,0,

	m_x,m_y+m_dy-4,0,
	m_x+m_dx,m_y+m_dy-4,0,
	m_x+m_dx,m_y+m_dy,0,
	m_x,m_y+m_dy,0
	};
      glEnableClientState(GL_VERTEX_ARRAY);
 
      glVertexPointer(3, GL_FLOAT, 0, vtx3);
      glDrawArrays(GL_TRIANGLE_FAN,0,4*5);

      glDisableClientState(GL_VERTEX_ARRAY);
#endif
	// Draw the slider:
	{
		if (m_entries.Length()>0) {
			m_slider_height = (m_dy-8)/(m_entries.Length()*ROW_HEIGHT);
			if (m_slider_height>=1) {
				m_slider_pos = 0;
				m_slider_height = -1;
			} else {
				m_slider_height = m_slider_height*(m_dy-8);
			    if (m_slider_pos + m_slider_height>m_dy-8) {
					m_slider_pos = m_dy-8 - m_slider_height;
				} // if
			} // if

		} else {
			m_slider_pos = 0;
			m_slider_height = -1;
		} // if

		if (m_slider_height>0) {

glColor4f(0.5f,1,0.5f,alpha*0.5f);
#if !defined(HAVE_GLES)
			glBegin(GL_QUADS);
			glVertex3f(m_x+m_dx-20,m_y+4+m_slider_pos,0);
			glVertex3f(m_x+m_dx-4,m_y+4+m_slider_pos,0);
			glVertex3f(m_x+m_dx-4,m_y+4+m_slider_pos+m_slider_height,0);
			glVertex3f(m_x+m_dx-20,m_y+4+m_slider_pos+m_slider_height,0);
			glEnd();
#else
			GLfloat vtx1[] = {
			m_x+m_dx-20,m_y+4+m_slider_pos,0,
			m_x+m_dx-4,m_y+4+m_slider_pos,0,
			m_x+m_dx-4,m_y+4+m_slider_pos+m_slider_height,0,
			m_x+m_dx-20,m_y+4+m_slider_pos+m_slider_height,0
			};
      glEnableClientState(GL_VERTEX_ARRAY);
 
      glVertexPointer(3, GL_FLOAT, 0, vtx1);
      glDrawArrays(GL_TRIANGLE_FAN,0,4);
 
      glDisableClientState(GL_VERTEX_ARRAY);
#endif
		} // if
	}

	// Draw the entries:
	{
        GLint bb[4];
        glGetIntegerv(GL_SCISSOR_BOX, bb);
		glScissor(int(m_x+4),int(SCREEN_Y-(m_y+4+(m_dy-8))),int(m_dx-(8 + 20)),int(m_dy-8));
        glEnable(GL_SCISSOR_TEST);

		int i=0;
		int y;
		char *entry;

		y = int(int(m_y) - (m_slider_pos/(m_dy-8))*(m_entries.Length()*ROW_HEIGHT));

		m_entries.Rewind();
		while(m_entries.Iterate(entry) && (y<m_y+m_dy)) {

			if (m_mouse_over == i) {

glColor4f(0.5f,1,0.5f,alpha*0.5f);
#if !defined(HAVE_GLES)
				glBegin(GL_QUADS);
				glVertex3f(m_x+4,float(y+4),0);
				glVertex3f(m_x+m_dx-4,float(y+4),0);
				glVertex3f(m_x+m_dx-4,float(y+ROW_HEIGHT+4),0);
				glVertex3f(m_x+4,float(y+ROW_HEIGHT+4),0);
				glEnd();
#else
				GLfloat vtx2[] = {
				m_x+4,float(y+4),0,
				m_x+m_dx-4,float(y+4),0,
				m_x+m_dx-4,float(y+ROW_HEIGHT+4),0,
				m_x+4,float(y+ROW_HEIGHT+4),0
				};

      glEnableClientState(GL_VERTEX_ARRAY);
 
      glVertexPointer(3, GL_FLOAT, 0, vtx2);
      glDrawArrays(GL_TRIANGLE_FAN,0,4);
 
      glDisableClientState(GL_VERTEX_ARRAY);
#endif
			} // if

			if (m_selected == i) font_print(int(m_x+8), y-2, 0, 0, 1, alpha, "font_hl", entry, -2);
							else font_print(int(m_x+8), y, 0, 0, 1, alpha, "font", entry, -4);
			y+=ROW_HEIGHT;
			i++;
		} // while

        glDisable(GL_SCISSOR_TEST);
		glScissor(bb[0],bb[1],bb[2],bb[3]);
	}
} /* G_Browser::draw */
bool ChooseAnImage(int sx,int sy, char *incoming_dir, int slot, char **filename, bool *isdir, int *index_file)
{
/*	Parameters:
 sx, sy - window size,
 incoming_dir - in what dir find files,
 slot - in what slot should an image go (common: #6 for 5.25' 140Kb floppy disks, and #7 for hard-disks).
 	slot #5 - for 800Kb floppy disks, but we do not use them in Apple][?
	(They are as a rule with .2mg extension)
 index_file	- from which file we should start cursor (should be static and 0 when changing dir)

 Out:	filename	- chosen file name (or dir name)
	isdir		- if chosen name is a directory
*/
	/* Surface: */
	SDL_Surface *my_screen;	// for background

	if(font_sfc == NULL)
		if(!fonts_initialization()) return false;	//if we don't have a fonts, we just can do none

	List<char> files;		// our files
	List<char> sizes;		// and their sizes (or 'dir' for directories)

	int act_file;		// current file
	int first_file;		// from which we output files
	printf("Disckchoose! We are here: %s\n",incoming_dir);
//	files.Delete();
//	sizes.Delete();
#ifndef _WIN32
/* POSIX specific routines of reading directory structure */
		DIR *dp;
		struct dirent *ep;

		dp = opendir (incoming_dir);	// open and read incoming directory
		char *tmp;

		int i,j, B, N;	// for cycles, beginning and end of list

// build prev dir
	if(strcmp(incoming_dir, "/")) {
		tmp = new char[3];
		strcpy(tmp, "..");
		files.Add(tmp);
		tmp = new char[5];
		strcpy(tmp, "<UP>");
		sizes.Add(tmp);	// add sign of directory
		B = 1;
	}
	else	B = 0;	// for sorting dirs
		if (dp != NULL)
		{
			while (ep = readdir (dp)) // first looking for directories
			{
				int what = getstat(incoming_dir, ep->d_name, NULL);
				if (strlen(ep->d_name) > 0 && /*strcmp(ep->d_name,".")*/// omit "." (cur dir)
					 ep->d_name[0] != '.'/*strcmp(ep->d_name,"..")*/ && what == 1) // is directory!
				{
					tmp = new char[strlen(ep->d_name)+1];	// add entity to list
					strcpy(tmp, ep->d_name);
					files.Add(tmp);
					tmp = new char[6];
					strcpy(tmp, "<DIR>");
					sizes.Add(tmp);	// add sign of directory
				} /* if */

			}
		}
#else
/* Windows specific functions of reading directory structure */
		/* Find subdirs: */
	if(strcmp(incoming_dir, "/")) {
	// we are not in upper direcory
		tmp = new char[3];
		strcpy(tmp, "..");
		files.Add(tmp);
		tmp = new char[5];
		strcpy(tmp, "<UP>");
		sizes.Add(tmp);	// add sign of directory
		B = 1;
	}
	else	B = 0;	// for sorting dirs


		WIN32_FIND_DATA finfo;
		HANDLE h;



		h=FindFirstFile(incoming_dir,&finfo);

		if (h!=INVALID_HANDLE_VALUE) {
			char *tmp;
			if(finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0) {
			// add this entry if it is directory
				tmp=new char[strlen(finfo.cFileName)+1];
				strcpy(tmp,finfo.cFileName);
				files.Add(tmp);
				tmp = new char[6];
				strcpy(tmp, "<DIR>");
				sizes.Add(tmp);	// add sign of directory
			}
			while(FindNextFile(h,&finfo)==TRUE) {
				if(finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY != 0) {
				// add this entry if it is directory
					tmp=new char[strlen(finfo.cFileName)+1];
					strcpy(tmp,finfo.cFileName);
					files.Add(tmp);
					tmp = new char[6];
					strcpy(tmp, "<DIR>");
					sizes.Add(tmp);	// add sign of directory
				}
			} /* while */
		} /* if */

#endif
// sort directories. Please, don't laugh at my bubble sorting - it the simplest thing I've ever seen --bb
			if(files.Length() > 2)
			{
				N = files.Length() - 1;
//				B = 1;`- defined above
				for(i = N; i > B; i--)
					for(j = B; j < i; j++)
						if(strcasecmp(files[j], files[j + 1]) > 0)
						{
							files.Swap(j,j + 1);
							sizes.Swap(j,j + 1);
						}

			}
			B = files.Length();	// start for files
#ifndef _WIN32
/* POSIX specific routines of reading directory structure */

			(void) rewinddir (dp);	// to the start
				// now get all regular files
			while (ep = readdir (dp))
			{
				int fsize;

				if (strlen(ep->d_name) > 4 && ep->d_name[0] != '.'
					&& (getstat(incoming_dir, ep->d_name, &fsize) == 2)) // is normal file!
				{
					tmp = new char[strlen(ep->d_name)+1];	// add this entity to list
					strcpy(tmp, ep->d_name);
					files.Add(tmp);
					tmp = new char[10];	// 1400000KB
					snprintf(tmp, 9, "%dKB", fsize);
					sizes.Add(tmp);	// add this size to list
				} /* if */

			}
			(void) closedir (dp);
#else
/* Windows specific functions of reading directory structure */
		/* Find files: */

		h=FindFirstFile(incoming_dir,&finfo);

		if (h!=INVALID_HANDLE_VALUE) {
//			char *tmp; - must be defined in previous section, when searching subdirs
			if(finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == 0) {
			// add this entry if it is NOT directory!
				tmp=new char[strlen(finfo.cFileName)+1];
				strcpy(tmp,finfo.cFileName);
				files.Add(tmp);
				tmp = new char[10];	// 1400000KB
				snprintf(tmp, 9, "%dKB",
					((finfo.nFileSizeHigh * (MAXDWORD+1)) + finfo.nFileSizeLow));
				sizes.Add(tmp);	// add this size to list
			}
			while(FindNextFile(h,&finfo)==TRUE) {
				if(finfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY == 0) {
				// add this entry if it is NOT directory!
					tmp=new char[strlen(finfo.cFileName)+1];
					strcpy(tmp,finfo.cFileName);
					files.Add(tmp);
					tmp = new char[10];	// 1400000KB
					snprintf(tmp, 9, "%dKB",
						((finfo.nFileSizeHigh * (MAXDWORD+1)) + finfo.nFileSizeLow));
					sizes.Add(tmp);	// add this size to list
				}
			} /* while */
		} /* if */

#endif
// do sorting for files
			if(files.Length() > 2 && B < files.Length())
			{
				N = files.Length() - 1;
//				B = 1;
				for(i = N; i > B; i--)
					for(j = B; j < i; j++)
						if(strcasecmp(files[j], files[j + 1]) > 0)
						{
							files.Swap(j,j + 1);
							sizes.Swap(j,j + 1);
						}
			}


//	Count out cursor position and file number output
	act_file = *index_file;
	if(act_file >= files.Length()) act_file = 0;		// cannot be more than files in list
	first_file = act_file - (FILES_IN_SCREEN / 2);
	if (first_file < 0) first_file = 0;	// cannot be negativ...

// Show all directories (first) and files then
//	char *tmp;
	char *siz;
//	int i;

// prepare screen
		double facx = double(g_ScreenWidth) / double(SCREEN_WIDTH);
		double facy = double(g_ScreenHeight) / double(SCREEN_HEIGHT);

	SDL_Surface *tempSurface = NULL;
	if(!g_WindowResized) {
		if(g_nAppMode == MODE_LOGO) tempSurface = g_hLogoBitmap;	// use logobitmap
			else tempSurface = g_hDeviceBitmap;
	}
	else tempSurface = g_origscreen;

	if(tempSurface == NULL)
		tempSurface = screen;	// use screen, if none available

	my_screen = SDL_CreateRGBSurface(SDL_SWSURFACE, tempSurface->w, tempSurface->h, tempSurface->format->BitsPerPixel, 0, 0, 0, 0);
	if(tempSurface->format->palette && my_screen->format->palette)
		SDL_SetColors(my_screen, tempSurface->format->palette->colors,
			      0, tempSurface->format->palette->ncolors);

	surface_fader(my_screen, 0.2F, 0.2F, 0.2F, -1, 0);	// fade it out to 20% of normal
	SDL_BlitSurface(tempSurface, NULL, my_screen, NULL);

	while(true)
	{

		SDL_BlitSurface(my_screen, NULL, screen, NULL);		// show background

		font_print_centered(sx/2 ,5*facy , incoming_dir, screen, 1.5*facx, 1.3*facy);
		if (slot == 6) font_print_centered(sx/2,20*facy,"Choose image for floppy 140KB drive", screen, 1*facx, 1*facy);
		else
			if (slot == 7) font_print_centered(sx/2,20*facy,"Choose image for Hard Disk", screen, 1*facx, 1*facy);
		else
			if (slot == 5) font_print_centered(sx/2,20*facy,"Choose image for floppy 800KB drive", screen, 1*facx, 1*facy);
		else
			if (slot == 1) font_print_centered(sx/2,20*facy,"Select file name for saving snapshot", screen, 1*facx, 1*facy);
		else
			if (slot == 0) font_print_centered(sx/2,20*facy,"Select snapshot file name for loading", screen, 1*facx, 1*facy);

		font_print_centered(sx/2,30*facy, "Press ENTER to choose, or ESC to cancel",screen, 1.4*facx, 1.1*facy);

		files.Rewind();	// from start
		sizes.Rewind();
		i = 0;

//		printf("We've printed some messages, go to file list!\n");
// show all fetched dirs and files
// topX of first fiel visible
		int TOPX	= int(45*facy);

		while(files.Iterate(tmp)) {

			sizes.Iterate(siz);	// also fetch size string

			if (i >= first_file && i < first_file + FILES_IN_SCREEN)
			{ // FILES_IN_SCREEN items on screen
//				char tmp2[80],tmp3[256];

				if (i == act_file) { // show item under cursor (in inverse mode)
					SDL_Rect r;
					r.x= 2;
					r.y= TOPX + (i-first_file) * 15 * facy - 1;
					if(strlen(tmp) > 46) r.w = 46 * FONT_SIZE_X /* 6 */ * 1.7 * facx + 2;
					   else r.w= strlen(tmp) * FONT_SIZE_X /* 6 */ * 1.7 * facx + 2;	// 6- FONT_SIZE_X
					r.h= 9 * 1.5 * facy;
					SDL_FillRect(screen, &r, SDL_MapRGB(screen->format,255,0,0));// in RED
				} /* if */

				// print file name with enlarged font
				char ch;
				ch = 0;
				if(strlen(tmp) > 46) { ch = tmp[46]; tmp[46] = 0;} //cut-off too long string
				font_print(4, TOPX + (i - first_file) * 15 * facy, tmp, screen, 1.7*facx, 1.5*facy); // show name
				font_print(sx - 70 * facx, TOPX + (i - first_file) * 15 * facy, siz, screen, 1.7*facx, 1.5*facy);// show info (dir or size)
				if(ch) tmp[46] = ch; //restore cut-off char

			} /* if */
			i++;		// next item
		} /* while */

/////////////////////////////////////////////////////////////////////////////////////////////
// draw rectangles
	rectangle(screen, 0, TOPX - 5, sx, 320*facy, SDL_MapRGB(screen->format, 255, 255, 255));
	rectangle(screen, 480*facx, TOPX - 5, 0, 320*facy, SDL_MapRGB(screen->format, 255, 255, 255));

	SDL_Flip(screen);	// show the screen
	SDL_Delay(KEY_DELAY);	// wait some time to be not too fast

	//////////////////////////////////
	// Wait for keypress
	//////////////////////////////////
	SDL_Event event;	// event
	Uint8 *keyboard;	// key state

	event.type = SDL_QUIT;
	while(event.type != SDL_KEYDOWN) {	// wait for key pressed
				SDL_Delay(10);
				SDL_PollEvent(&event);
	}

// control cursor
		keyboard = SDL_GetKeyState(NULL);	// get current state of pressed (and not pressed) keys

		if (keyboard[SDLK_UP] || keyboard[SDLK_LEFT]) {
			if (act_file>0) act_file--;	// up one position
			if (act_file<first_file) first_file=act_file;
		} /* if */

		if (keyboard[SDLK_DOWN] || keyboard[SDLK_RIGHT]) {
			if (act_file < (files.Length() - 1)) act_file++;
			if (act_file >= (first_file + FILES_IN_SCREEN)) first_file=act_file - FILES_IN_SCREEN + 1;
		} /* if */

		if (keyboard[SDLK_PAGEUP]) {
			act_file-=FILES_IN_SCREEN;
			if (act_file<0) act_file=0;
			if (act_file<first_file) first_file=act_file;
		} /* if */

		if (keyboard[SDLK_PAGEDOWN]) {
			act_file+=FILES_IN_SCREEN;
			if (act_file>=files.Length()) act_file=(files.Length()-1);
			if (act_file>=(first_file+FILES_IN_SCREEN)) first_file=act_file-FILES_IN_SCREEN + 1;
		} /* if */

		// choose an item?
		if (keyboard[SDLK_RETURN]) {
			// dup string from selected file name
			*filename = strdup(files[act_file]);
//			printf("files[act_file]=%s, *filename=%s\n\n", files[act_file], *filename);
			if(!strcmp(sizes[act_file], "<DIR>") || !strcmp(sizes[act_file], "<UP>"))
			   		*isdir = true;
				else *isdir = false;	// this is directory (catalog in Apple][ terminology)
			*index_file = act_file;	// remember current index
			files.Delete();
			sizes.Delete();
			SDL_FreeSurface(my_screen);

			return true;
		} /* if */

		if (keyboard[SDLK_ESCAPE]) {
			files.Delete();
			sizes.Delete();
			SDL_FreeSurface(my_screen);

			return false;		// ESC has been pressed
		} /* if */

		if (keyboard[SDLK_HOME]) {	// HOME?
			act_file=0;
			first_file=0;
		} /* if */
		if (keyboard[SDLK_END]) {	// END?
			act_file=files.Length() - 1;	// go to the last possible file in list
			first_file=act_file - FILES_IN_SCREEN + 1;
			if(first_file < 0) first_file = 0;
		} /* if */

	}
} /* ChooseAnImage */
Beispiel #14
0
bool state_instructions_cycle(SDL_Surface *screen,int sx,int sy,unsigned char *keyboard)
{
	if (SUBSTATE==0) {
		if (image!=0) SDL_FreeSurface(image);
		image=IMG_Load("graphics/tittle.png");
	} /* if */ 
	SDL_BlitSurface(image,0,screen,0);
	surface_fader(screen,0.5F,0.5F,0.5F,-1,0);
	if (SUBSTATE<64) {
		font_print(16,10,"              SUPER TRANSBALL 2 V1.5",screen);

		font_print(16,30,"  THE FUTURE, THE SUN DOES NOT SHINE ANYMORE",screen);
		font_print(16,40,"AND THE ONLY ENERGY SOURCE ARE \"THE SPHERES\".",screen);
		font_print(16,50,"THE SPHERES CONTAIN ENOUGH ENERGY FOR A PLANET",screen);
		font_print(16,60,"TO SURVIVE. THEY ARE CHARGED WITH THE ENERGY",screen);
		font_print(16,70,"OF OTHER STARS.",screen);
		font_print(16,90,"  AS THE HUMANS ARE HIGHLY DEPENDENT ON THE",screen);
		font_print(16,100,"SPHERES, AN OPORTUNIST CIVILIZATION HAS STOLEN",screen);
		font_print(16,110,"ALL THE CHARGED SPHERES FROM THE EARTH EXPECTING",screen);
		font_print(16,120,"TO COLONIZE THE PLANET. AS A LAST CHANCE, THE",screen);
		font_print(16,130,"LAST ENERGY HAS BEEN TRANSFERED TO A SCOUT SHIP",screen);
		font_print(16,140,"AND SENT TO RECOVER THE SPHERES...",screen);

		font_print(16,160,"YOU COMMAND THIS SHIP, YOU ARE THE LAST CHANCE",screen);
		font_print(16,170,"FOR THE SURVIVAL OF THE HUMAN RACE...",screen);
	} /* if */ 
	if (SUBSTATE>64 && SUBSTATE<128) {
		font_print(16,10,"              SUPER TRANSBALL 2 V1.5",screen);

		font_print(16,30,"  THE CONTROLS OF THE SHIP ARE [REDEFINIBLE]:",screen);
		font_print(16,50,"  UP    - PROPULSORS",screen);
		font_print(16,60,"  DOWN  - RETROPROPULSORS [NOT ALL THE SHIPS]",screen);
		font_print(16,70,"  LEFT  - TURN LEFT",screen);
		font_print(16,80,"  RIGHT - TURN RIGHT",screen);
		font_print(16,90,"  A     - FIRE",screen);
		font_print(16,100,"  B     - BALL ATRACTOR",screen);

		font_print(16,120,"TO ACHIEVE YOUR GOAL, YOU CAN CHOOSE BETWEEN",screen);
		font_print(16,130,"THREE DIFFERENT SHIPS, EACH ONE WITH ITS OWN",screen);
		font_print(16,140,"CHARACTERISTICS:",screen);
		font_print(16,160," THE SHADOW RUNNER: HIGH SPEED, FEW WEAPONS",screen);
		font_print(16,170," THE V-PANTHER 2  : MEDIUM SPEED, MEDIUM WEAPONS",screen);
		font_print(16,180," THE X-TERMINATOR : LOW SPEED, DEFINITIVE WEAPONS",screen);
	} /* if */ 

	if (SUBSTATE>128 && SUBSTATE<192) {
		font_print(16,10,"              SUPER TRANSBALL 2 V1.5",screen);

		font_print(16,30, "GUIDE[1]:",screen);
		font_print(16,50, " - YOUR SHIP IS UNDER THE EFFECT OF THE GRAVITY.",screen);
		font_print(16,60, " - WITH YOUR THRUSTER, YOU MUST AVOID TO COLLIDE",screen);
		font_print(16,70, "   WITH THE BACKGROUND.",screen);
		font_print(16,80, " - YOU MUST FIND THE WHITE BALL, THEN USE THE",screen);
		font_print(16,90, "   ATRACTOR OVER IT DURING A WHILE. IT WILL TURN",screen);
		font_print(16,100,"   BLUE. ",screen);
		font_print(16,110," - WHEN THE BALL IS BLUE, YOUR SHIP ATRACTS IT.",screen);
		font_print(16,120," - TO COMPLETE A LEVEL YOU MUST CARRY THE BALL",screen);
		font_print(16,130,"   TO THE UPPER PART.",screen);
		font_print(16,140," - YOU CAN KILL THE MANY ENEMIES YOU WILL FIND",screen);
		font_print(16,150,"   USING YOUR CANONS, SEVERAL SHOTS ARE NEEDED",screen);
		font_print(16,160,"   TO KILL THE ENEMIES [DEPENDING ON THE SHIP].",screen);
	} /* if */ 

	if (SUBSTATE>192 && SUBSTATE<256) {
		font_print(16,10,"              SUPER TRANSBALL 2 V1.5",screen);

		font_print(16,30, "GUIDE[2]:",screen);
		font_print(16,50, " - YOU WILL FIND DOORS THAT OPEN OR CLOSE WHEN",screen);
		font_print(16,60, "   YOU TAKE THE BALL.",screen);
		font_print(16,70, " - SOME OTHER DOORS ARE ACTIVATED BY SWITCHES.",screen);
		font_print(16,80, " - TO PRESS A SWITCH, YOU MUST MAKE THE BALL TO",screen);
		font_print(16,90, "   BOUNCE ON IT.",screen);
		font_print(16,100," - YOUR THRUSTER AND WEAPONS USE FUEL, YOU MUST ",screen);
		font_print(16,110,"   RECHARGE IT WHENEVER POSSIBLE.",screen);
		font_print(16,120," - SOME LEVELS MAY SEEM VERY DIFFICULT THE FIRST",screen);
		font_print(16,130,"   TIME, BUT WITH PRACTICE, EVERY LEVEL BECOMES",screen);
		font_print(16,140,"   EASY... :]",screen);
	} /* if */ 

	if (SUBSTATE>256 && SUBSTATE<320) {
		font_print(16,10,"              SUPER TRANSBALL 2 V1.5",screen);

		font_print(16,30,"THIS GAME IS INSPIRED ON THARA ZHRUSTA FOR THE",screen);
		font_print(16,40,"AMIGA 500, BUT UNFORTUNATELY CANNOT COMPARE WITH",screen);
		font_print(16,50,"IT...",screen);

		font_print(16,100,"                BRAIN 2002-2005",screen);
		font_print(16,110,"             SANTI ONTA~ON VILLAR",screen);
		font_print(16,120,"         SEE README FILE FOR MORE INFO",screen);
		font_print(16,140,"     GCW ZERO PORT 2015 ARTUR \"ZEAR\" ROJEK",screen);
	} /* if */ 
	if ((SUBSTATE%64)<32) {
		surface_fader(screen,float((SUBSTATE%64))/32.0F,float((SUBSTATE%64))/32.0F,float((SUBSTATE%64))/32.0F,-1,0);
		SUBSTATE++;
	} /* if */ 
	if ((SUBSTATE%64)==32) {
		if (keyboard[FIRE_KEY] && !old_keyboard[FIRE_KEY]) SUBSTATE++;
	} /* if */ 
	if ((SUBSTATE%64)>32) {
		surface_fader(screen,float(64-(SUBSTATE%64))/32.0F,float(64-(SUBSTATE%64))/32.0F,float(64-(SUBSTATE%64))/32.0F,-1,0);
		SUBSTATE++;
		if (SUBSTATE==320) {
			SDL_FreeSurface(image);
			image=0;

			STATE=1;
			SUBSTATE=0;
		} /* if */ 
	} /* if */ 

	return true;
} /* state_instructions_cycle */