Esempio n. 1
0
/* not static to circumvent stupid gcc 4 bug */ 
int getfname(const char *fname, char *rbuf, int rsz)
{
#ifndef TRUST_MAIN
  register int status;
#endif

  SL_ENTER(_("getfname"));
  /*
   * do the initial checking
   * NULL pointer
   */
  if (fname == NULL || rbuf == NULL)
    SL_IRETURN(SL_ENULL, _("getfname"));
  if (rsz <= 0)
    SL_IRETURN(SL_ERANGE, _("getfname"));
  
  
  /* already a full path name */
  if (*fname == '/')
    rbuf[0] = '\0';
  else
    {
      if (CURDIR(rbuf, rsz)  == NULL)
	{
#ifdef TRUST_DEBUG
	  fprintf(stderr, "trustfile: getcwd failed\n");
#endif 
	  SL_IRETURN(SL_EBADNAME, _("getfname"));
	}
    }
  
  /*
   * append the file name and reduce
   */
  if (fname != NULL && *fname != '\0')
    {
#ifndef TRUST_MAIN
      status = sl_strlcat(rbuf, "/", rsz);
      if (status == SL_ENONE)
	status = sl_strlcat(rbuf, fname, rsz);
      if (status != SL_ENONE)
	SL_IRETURN(status, _("getfname"));
#else
      strncat(rbuf, "/",   rsz-strlen(rbuf)-1);
      rbuf[rsz-1] = '\0';
      strncat(rbuf, fname, rsz-strlen(rbuf)-1);
      rbuf[rsz-1] = '\0';
#endif
    }
  SL_IRETURN(dirz(rbuf), _("getfname"));
}
Esempio n. 2
0
File: menu.c Progetto: libretro/PUAE
void gui_display (int shortcut){

	void* stor = display ? malloc(display->h * display->pitch) : 0;
	if (stor) memcpy(stor, display->pixels, display->h * display->pitch);

	if (tmpSDLScreen == NULL) {
		tmpSDLScreen = SDL_DisplayFormat(display);
		if (tmpSDLScreen == NULL) {
			write_log ("SDLUI: Failed to create temp screen\n");
			abort();
		} else {
			write_log ("SDLUI: Created temp screen %dx%dx%d\n", display->w, display->h, display->format->BitsPerPixel);
		}
	}
	SDL_Event event;

	int menu_exitcode = -1;
	int mainloopdone = 0;
	int mouse_x = 30;
	int mouse_y = 40;
	int kup = 0;
	int kdown = 0;
	int kleft = 0;
	int kright = 0;
	int ksel = 0;
	int iconpos_x = 0;
	int iconpos_y = 0;

	if (getcwd (launchDir, 256)) {
		strcpy (yol, launchDir);
		write_log ("SDLUI: current dir: %s\n", launchDir);
	} else {
		write_log("getcwd failed with errno %d\n", errno);
		return;
	}

	/* set a proper keyboard delay so we can move through lists without having
	   hammer the keyboard... */
	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);

	int need_redraw = 1;
	while (!mainloopdone) {
		while (SDL_PollEvent(&event)) {
			need_redraw = 1;
			switch(event.type) {
				case SDL_QUIT:
					mainloopdone = 1; break;
				case SDL_JOYBUTTONDOWN:
					switch (event.jbutton.button) {
						case PLATFORM_BUTTON_R: break;
						case PLATFORM_BUTTON_L: break;
						case PLATFORM_BUTTON_UP: kup = 1; break;
						case PLATFORM_BUTTON_DOWN: kdown = 1; break;
						case PLATFORM_BUTTON_LEFT: kleft = 1; break;
						case PLATFORM_BUTTON_RIGHT: kright = 1; break;
						case PLATFORM_BUTTON_CLICK: ksel = 1; break;
						case PLATFORM_BUTTON_B: ksel = 1; break;
						case PLATFORM_BUTTON_Y: break;
						case PLATFORM_BUTTON_START: mainloopdone = 1; break;
					}
					break;
				case SDL_KEYDOWN:
	    				switch (event.key.keysym.sym) {
						case SDLK_RETURN:
						if((event.key.keysym.mod & KMOD_LALT) ||
						   (event.key.keysym.mod & KMOD_RALT)) {
							toggle_fullscreen(0);
							//SDL_Delay(100);
							break;
						} else {
							// enter to select
							ksel = 1; break;
						}
						case SDLK_ESCAPE:	mainloopdone = 1; break;
					 	case SDLK_UP:		kup = 1; break;
						case SDLK_DOWN:		kdown = 1; break;
						case SDLK_LEFT:		kleft = 1; break;
						case SDLK_RIGHT:	kright = 1; break;
						// space to run default
						case SDLK_SPACE:	selected_item = menu_sel_run; ksel =1; break;
						default: break;
					}
					break;
				case SDL_MOUSEMOTION:
					mouse_x += event.motion.xrel;
					mouse_y += event.motion.yrel;
					break;
				case SDL_MOUSEBUTTONDOWN:
					if (selected_item == 0) {
						if (mouse_x >= 0 && mouse_x <= 20) {
							if (mouse_y >= 0 && mouse_y <= 20) {
								mainloopdone = 1;
							}
						}
					} else {
						ksel = 1; break;
					}
					break;
				case SDL_ACTIVEEVENT: case SDL_KEYUP: break;
				default:
					dprintf(2, "got event %lu\n", (long) event.type);
					need_redraw = 0;
			}
		}
		if(!need_redraw) { SDL_Delay(20); continue; }
		if (ksel == 1) {
			if (selected_item == menu_sel_expansion) {
				sprintf (msg, "%s", "Select KickStart ROM");
				sprintf (msg_status, "%s", "EXIT: Back/ESC");
				sprintf (yol, "%s/roms", launchDir);
				dirz(1);
			}
			if (selected_item == menu_sel_floppy) {
				sprintf (msg, "%s", "Select Disk Image");
				sprintf (msg_status, "%s", "DF0: B  DF1: A");
				sprintf (yol, "%s/disks", launchDir);
				dirz(0);
			}
			if (selected_item == menu_sel_prefs) {
				sprintf (msg, "%s", "Emulation Configuration");
				sprintf (msg_status, "%s", "EXIT: Back/ESC");
				prefz(0);
			}
			if (selected_item == menu_sel_reset) {
				uae_reset(0, 1);
				menu_exitcode = 2;
				mainloopdone = 1;
			}
			if (selected_item == menu_sel_keymaps) {
			}
/*			if (selected_item == menu_sel_tweaks) {
				sprintf(msg,"%s","Tweaks");
				sprintf(msg_status,"%s","L/R = -/+  B: Apply");
				tweakz(0);
			}*/
			if (selected_item == menu_sel_storage) {
				strcpy(msg, "Savestates");
				strcpy(msg_status, "LOAD: A SAVE: B");
				sprintf (yol, "%s/saves", launchDir);
				dirz(2);
			}
			if (selected_item == menu_sel_run) {
				menu_exitcode = 1;
				mainloopdone = 1;
			}
			if (selected_item == menu_sel_exit) {
				SDL_Quit();
				exit(0);
			}
			ksel = 0;
		}
	// background
		SDL_BlitSurface (pMenu_Surface, NULL, tmpSDLScreen, NULL);

	// icons
        	iconpos_x = 10;
	        iconpos_y = 33;

        	selected_hilite (iconpos_x, iconpos_y, mouse_x, mouse_y, icon_floppy, menu_sel_floppy);
	        blit_image (icon_floppy, iconpos_x, iconpos_y);

	        iconpos_x += iconsizex + bosluk;
        	selected_hilite (iconpos_x, iconpos_y, mouse_x, mouse_y, icon_preferences, menu_sel_prefs);
	        blit_image (icon_preferences, iconpos_x, iconpos_y);

//	        iconpos_x += iconsizex + bosluk;
//        	selected_hilite (iconpos_x, iconpos_y, mouse_x, mouse_y, icon_tweaks, menu_sel_tweaks);
//	        blit_image (icon_tweaks, iconpos_x, iconpos_y);

        	iconpos_x += iconsizex + bosluk;
	        selected_hilite (iconpos_x, iconpos_y, mouse_x, mouse_y, icon_keymaps, menu_sel_keymaps);
        	blit_image (icon_keymaps, iconpos_x, iconpos_y);

	        iconpos_x += iconsizex + bosluk;
	        selected_hilite (iconpos_x, iconpos_y, mouse_x, mouse_y, icon_expansion, menu_sel_expansion);
        	blit_image (icon_expansion, iconpos_x, iconpos_y);

        	iconpos_x = 10;
	        iconpos_y = iconpos_y + iconsizey + bosluk;

        	selected_hilite (iconpos_x,iconpos_y,mouse_x,mouse_y,icon_storage, menu_sel_storage);
	        blit_image (icon_storage, iconpos_x, iconpos_y);

	        iconpos_x += iconsizex + bosluk;
	        selected_hilite (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_reset, menu_sel_reset);
        	blit_image (icon_reset, iconpos_x, iconpos_y);

	        iconpos_x += iconsizex + bosluk;
        	selected_hilite (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_run, menu_sel_run);
	        blit_image (icon_run, iconpos_x, iconpos_y);

        	iconpos_x += iconsizex + bosluk;
	        selected_hilite (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_exit, menu_sel_exit);
        	blit_image (icon_exit, iconpos_x, iconpos_y);
	// texts
		write_text (TITLE_X, TITLE_Y, "PUAE //GnoStiC");

	// mouse pointer ------------------------------
		if (kleft == 1) {
	                mouse_x -= (iconsizex + bosluk);
        	        kleft = 0;
		}
		if (kright == 1) {
	                mouse_x += (iconsizex + bosluk);
	                kright = 0;
		}
	        if (kup == 1) {
	                mouse_y -= (iconsizey + bosluk);
	                kup = 0;
		}
		if (kdown == 1) {
        	        kdown = 0;
	                mouse_y += (iconsizey + bosluk);
		}

#define _MENU_X 640
#define _MENU_Y 480

		if (mouse_x < 1) { mouse_x = 1; }
		if (mouse_y < 1) { mouse_y = 1; }
/* pMainMenu_Surface->w */
#define MOUSE_MAX_X (_MENU_X - pMouse_Pointer->w)
#define MOUSE_MAX_Y (_MENU_Y - pMouse_Pointer->h)
		if (mouse_x > MOUSE_MAX_X) { mouse_x = MOUSE_MAX_X; }
		if (mouse_y > MOUSE_MAX_Y) { mouse_y = MOUSE_MAX_Y; }
		rect.x = mouse_x;
		rect.y = mouse_y;
		//rect.w = pMouse_Pointer->w;
		//rect.h = pMouse_Pointer->h;
		SDL_BlitSurface (pMouse_Pointer, NULL, tmpSDLScreen, &rect);
		// mouse pointer-end

		SDL_BlitSurface (tmpSDLScreen, NULL, display, NULL);
#ifdef USE_GL
		flush_gl_buffer (&glbuffer, 0, display->h - 1);
		render_gl_buffer (&glbuffer, 0, display->h - 1);
		glFlush ();
		SDL_GL_SwapBuffers ();
#else
		SDL_Flip (display);
#endif
		need_redraw = 0;
		SDL_Delay(20);
	} //while done

	if (stor) {
		memcpy(display->pixels, stor, display->h * display->pitch);
		free(stor);
		SDL_Flip(display);
	}

	SDL_EnableKeyRepeat(0, 0); /* disable keyrepeat again */
//	return menu_exitcode;
}
Esempio n. 3
0
int CTraQ::CalcQ( CModel* srcmodel, TSELEM* tsptr, CTraQ* traqptr, RPSELEM* rpsptr, int frameno, int pivotskel, int skelno, int skipflag )
{
	CQuaternion parq;
	parq = ( traqptr + frameno * SKEL_MAX + pivotskel )->m_totalq;
	CQuaternion invparq;
	parq.inv( &invparq );

	if( skipflag != 0 ){
		( traqptr + frameno * SKEL_MAX + skelno )->m_q.SetParams( 1.0f, 0.0f, 0.0f, 0.0f );
		( traqptr + frameno * SKEL_MAX + skelno )->m_totalq = parq;
		return 0;
	}


	D3DXVECTOR3 befpivpos, aftpivpos, befpos, aftpos;
	befpivpos = ( rpsptr + 0 * SKEL_MAX + pivotskel )->pos;
	aftpivpos = ( rpsptr + frameno * SKEL_MAX + pivotskel )->pos;
	befpos = ( rpsptr + 0 * SKEL_MAX + skelno )->pos;
	aftpos = ( rpsptr + frameno * SKEL_MAX + skelno )->pos;

	D3DXVECTOR3 paftpivpos, paftpos;
	invparq.Rotate( &paftpivpos, aftpivpos );
	invparq.Rotate( &paftpos, aftpos );

	D3DXVECTOR3 vec1, vec2;
	vec1 = befpos - befpivpos;
	vec2 = paftpos - paftpivpos;
	D3DXVECTOR3 nvec1, nvec2;
	DVec3Normalize( &nvec1, vec1 );
	DVec3Normalize( &nvec2, vec2 );


	int ret;
	CQuaternion setq;
	ret = DCalcDiffQ( &nvec1, &nvec2, &setq );
	_ASSERT( !ret );
////////////////


	D3DXVECTOR3 cureul( 0.0f, 0.0f, 0.0f );
	D3DXVECTOR3 befeul( 0.0f, 0.0f, 0.0f );
	befeul = ( traqptr + ( frameno - 1 ) * SKEL_MAX + skelno )->m_befeul;
	CQuaternion za3q;
	ret = QtoEul( srcmodel, setq, befeul, CAX_ZA3, (tsptr + skelno)->jointno, &cureul, &za3q );
	_ASSERT( !ret );

	CQuaternion invza3q;
	za3q.inv( &invza3q );

	float twistdeg;
	if( ( tsptr + skelno )->twistflag == 0 ){

		D3DXVECTOR3 dirx( 1.0f, 0.0f, 0.0f );
		D3DXVECTOR3 diry( 0.0f, 1.0f, 0.0f );
		D3DXVECTOR3 dirz( 0.0f, 0.0f, 1.0f );

		CQuaternion qx, qy, qz;
		qx.SetAxisAndRot( dirx, cureul.x * DEG2PAI );
		qy.SetAxisAndRot( diry, cureul.y * DEG2PAI );
		qz.SetAxisAndRot( dirz, cureul.z * DEG2PAI );
		CQuaternion qxy;
		qxy = qy * qx;


///////////
		
		D3DXVECTOR3 aftdiry;
		qxy.Rotate( &aftdiry, diry );
		DVec3Normalize( &aftdiry, aftdiry );

		double doty;
		DCalcDot( &diry, &aftdiry, &doty );
		double rady;
		rady = acos( doty );

		CQuaternion ya, yb;
		ya.SetAxisAndRot( dirz, rady );
		yb.SetAxisAndRot( dirz, -rady );
		D3DXVECTOR3 afta, aftb;
		ya.Rotate( &afta, diry );
		yb.Rotate( &aftb, diry );
		DVec3Normalize( &afta, afta );
		DVec3Normalize( &aftb, aftb );
		double dotya, dotyb;
		DCalcDot( &aftdiry, &afta, &dotya );
		DCalcDot( &aftdiry, &aftb, &dotyb );
		CQuaternion twistq;
		if( dotya >= dotyb ){
			twistq = ya;
			twistdeg = (float)( rady * PAI2DEG );
		}else{
			twistq = yb;
			twistdeg = (float)( -rady * PAI2DEG );
		}
		
		setq = za3q * qxy * twistq * invza3q;
	}else{
		twistdeg = cureul.z;
	}


	( traqptr + frameno * SKEL_MAX + skelno )->m_q = setq;
	( traqptr + frameno * SKEL_MAX + skelno )->m_totalq = parq * setq;

	( traqptr + frameno * SKEL_MAX + skelno )->m_befeul = cureul;
	( traqptr + frameno * SKEL_MAX + skelno )->m_cureul = D3DXVECTOR3( cureul.x, cureul.y, twistdeg );


	return 0;
}
Esempio n. 4
0
int CTraQ::CalcNeck( CModel* srcmodel, TSELEM* tsptr, CTraQ* traqptr, RPSELEM* rpsptr, int frameno, int skipflag )
{
	CQuaternion parq;
	parq = ( traqptr + frameno * SKEL_MAX + SKEL_TORSO )->m_totalq;
	CQuaternion invparq;
	parq.inv( &invparq );

	if( skipflag == 3 ){
		( traqptr + frameno * SKEL_MAX + SKEL_NECK )->m_q.SetParams( 1.0f, 0.0f, 0.0f, 0.0f );
		( traqptr + frameno * SKEL_MAX + SKEL_NECK )->m_totalq = parq;
		return 0;
	}


	D3DXVECTOR3 befLpos, aftLpos, befRpos, aftRpos;
	befLpos = ( rpsptr + 0 * SKEL_MAX + SKEL_LEFT_SHOULDER )->pos;
	aftLpos = ( rpsptr + frameno * SKEL_MAX + SKEL_LEFT_SHOULDER )->pos;
	befRpos = ( rpsptr + 0 * SKEL_MAX + SKEL_RIGHT_SHOULDER )->pos;
	aftRpos = ( rpsptr + frameno * SKEL_MAX + SKEL_RIGHT_SHOULDER )->pos;

	D3DXVECTOR3 paftLpos, paftRpos;
	invparq.Rotate( &paftLpos, aftLpos );
	invparq.Rotate( &paftRpos, aftRpos );

	double radxz;
	D3DXVECTOR3 vDir0, vDir;
	D3DXVECTOR3 dirY( 0.0f, 1.0f, 0.0f );
	D3DXVECTOR3 diffpos;
	diffpos = paftLpos - paftRpos;
	DVec3Normalize( &diffpos, diffpos );

	DVec3Cross( &diffpos, &dirY, &vDir0 );
	DVec3Normalize( &vDir, vDir0 );
	if( vDir.x == 0.0f ){
		if( vDir.z >= 0.0f )
			radxz = 0.0;
		else
			radxz = PAI;
	}else if( vDir.x > 0.0f ){
		radxz = -atanf( vDir.z / vDir.x ) + PAI / 2;
	}else{
		radxz = -atanf( vDir.z / vDir.x ) - PAI / 2;
	}

///////////////
	D3DXVECTOR3 beftor, afttor, befneck, aftneck;
	beftor = ( rpsptr + 0 * SKEL_MAX + SKEL_TORSO )->pos;
	afttor = ( rpsptr + frameno * SKEL_MAX + SKEL_TORSO )->pos;
	befneck = ( rpsptr + 0 * SKEL_MAX + SKEL_NECK )->pos;
	aftneck = ( rpsptr + frameno * SKEL_MAX + SKEL_NECK )->pos;

	D3DXVECTOR3 pafttor, paftneck;
	invparq.Rotate( &pafttor, afttor );
	invparq.Rotate( &paftneck, aftneck );

	D3DXVECTOR3 vecA, vecB;
	vecA = befneck - beftor;
	vecB = paftneck - pafttor;
	D3DXVECTOR3 nvecA, nvecB;
	DVec3Normalize( &nvecA, vecA );
	DVec3Normalize( &nvecB, vecB );
	int ret;
	CQuaternion q2;
	ret = DCalcDiffQ( &nvecA, &nvecB, &q2 );
	_ASSERT( !ret );
	

	CQuaternion za3q;
	D3DXVECTOR3 cureul( 0.0f, 0.0f, 0.0f );
	D3DXVECTOR3 befeul( 0.0f, 0.0f, 0.0f );
	D3DXVECTOR3 neckbefeul( 0.0f, 0.0f, 0.0f );
	neckbefeul = ( traqptr + ( frameno - 1 ) * SKEL_MAX + SKEL_NECK )->m_neckbefeul;
	ret = QtoEul( srcmodel, q2, neckbefeul, CAX_INI, 0, &cureul, &za3q );
	_ASSERT( !ret );

	CQuaternion invza3q;
	za3q.inv( &invza3q );

	D3DXVECTOR3 dirx( 1.0f, 0.0f, 0.0f );
	D3DXVECTOR3 diry( 0.0f, 1.0f, 0.0f );
	D3DXVECTOR3 dirz( 0.0f, 0.0f, 1.0f );

	CQuaternion qx2, qy2, qz2, qzx2;
	qx2.SetAxisAndRot( dirx, cureul.x * DEG2PAI );
	qy2.SetAxisAndRot( diry, cureul.y * DEG2PAI );
	qz2.SetAxisAndRot( dirz, cureul.z * DEG2PAI );

	CQuaternion q;
	q = qx2 * qz2;


	D3DXVECTOR3 axis;
	q.Rotate( &axis, diry );
	DVec3Normalize( &axis, axis );
	CQuaternion qxz;
	qxz.SetAxisAndRot( axis, radxz );

	CQuaternion setq;
	if( skipflag & 1 ){
		setq = q;
	}else{
		setq = qxz * q;
	}

/////////////////////
	D3DXVECTOR3 setcureul;
	befeul = ( traqptr + ( frameno - 1 ) * SKEL_MAX + SKEL_NECK )->m_befeul;

	ret = QtoEul( srcmodel, setq, befeul, CAX_INI, 0, &setcureul, &za3q );
	_ASSERT( !ret );


	( traqptr + frameno * SKEL_MAX + SKEL_NECK )->m_q = setq;
	( traqptr + frameno * SKEL_MAX + SKEL_NECK )->m_totalq = parq * setq;

	( traqptr + frameno * SKEL_MAX + SKEL_NECK )->m_neckbefeul = cureul;
	( traqptr + frameno * SKEL_MAX + SKEL_NECK )->m_cureul = setcureul;
	( traqptr + frameno * SKEL_MAX + SKEL_NECK )->m_befeul = setcureul;


	return 0;
}
Esempio n. 5
0
int gui_display(int shortcut){
	SDL_Event event;

	int menu_exitcode = -1;
	int mainloopdone = 0;
	int mouse_x = 30;
	int mouse_y = 40;
	int kup = 0;
	int kdown = 0;
	int kleft = 0;
	int kright = 0;
	int ksel = 0;
	int iconpos_x = 0;
	int iconpos_y = 0;

	getcwd(launchDir,256);

	while (!mainloopdone) {
		while (SDL_PollEvent(&event)) {
			if (event.type == SDL_QUIT) {
				mainloopdone = 1;
			}
			if (event.type == SDL_JOYBUTTONDOWN) {
             			switch (event.jbutton.button) {
                 			case GP2X_BUTTON_R: break;
					case GP2X_BUTTON_L: break;
					case GP2X_BUTTON_UP: kup = 1; break;
					case GP2X_BUTTON_DOWN: kdown = 1; break;
					case GP2X_BUTTON_LEFT: kleft = 1; break;
					case GP2X_BUTTON_RIGHT: kright = 1; break;
					case GP2X_BUTTON_CLICK: ksel = 1; break;
					case GP2X_BUTTON_B: ksel = 1; break;
					case GP2X_BUTTON_Y: break;
					case GP2X_BUTTON_START: mainloopdone = 1; break;
				}
			}
      			if (event.type == SDL_KEYDOWN) {
    				switch (event.key.keysym.sym) {
					case SDLK_ESCAPE:	mainloopdone = 1; break;
				 	case SDLK_UP:		kup = 1; break;
					case SDLK_DOWN:		kdown = 1; break;
					case SDLK_LEFT:		kleft = 1; break;
					case SDLK_RIGHT:	kright = 1; break;
					case SDLK_b:		ksel = 1; break;
					default: break;
				}
			}
			if (event.type == SDL_MOUSEMOTION) {
				mouse_x += event.motion.xrel;
				mouse_y += event.motion.yrel;
			}
			if (event.type == SDL_MOUSEBUTTONDOWN) {
				if (seciliolan == 0) {
					if (mouse_x >= 0 && mouse_x <= 20) {
                                		if (mouse_y >= 0 && mouse_y <= 20) {
							mainloopdone = 1;
						}
					}
				} else {
					ksel = 1; break;
				}
			}
		}
		if (ksel == 1) {
			if (seciliolan == menu_sel_expansion) {
				sprintf(msg,"%s","Select KickStart ROM");
				sprintf(msg_status,"%s"," ");
				sprintf(yol,"%s/roms",launchDir);
				dirz(1);
			}
			if (seciliolan == menu_sel_floppy) {
				sprintf(msg,"%s","Select Disk Image");
				sprintf(msg_status,"%s","DF0: B  DF1: A");
				sprintf(yol,"%s/disks",launchDir);
				dirz(0);
			}
			if (seciliolan == menu_sel_prefs) {
				sprintf(msg,"%s"," ");
				sprintf(msg_status,"%s"," ");
				prefz(0);
			}
			if (seciliolan == menu_sel_reset) {
				//reset amiga
				menu_exitcode = 2;
				mainloopdone = 1;
			}
			if (seciliolan == menu_sel_keymaps) {
			}
			if (seciliolan == menu_sel_tweaks) {
				sprintf(msg,"%s","Tweaks");
				sprintf(msg_status,"%s","L/R = -/+  B: Apply");
				tweakz(0);
			}
			if (seciliolan == menu_sel_storage) {

			}
			if (seciliolan == menu_sel_run) {
				menu_exitcode = 1;
				mainloopdone = 1;
			}
			if (seciliolan == menu_sel_exit) {
				SDL_Quit();

#ifdef GP2X
				//remove mmuhack module
				system("/sbin/rmmod mmuhack");

				//menu
				chdir("/usr/gp2x");
				execl("/usr/gp2x/gp2xmenu", "/usr/gp2x/gp2xmenu", NULL);
#endif
				exit(0);
			}
			ksel = 0;
		}
	// background
		SDL_BlitSurface (pMenu_Surface,NULL,tmpSDLScreen,NULL);

	// icons
        	iconpos_x = 10;
	        iconpos_y = 23;

        	secilimi (iconpos_x,iconpos_y,mouse_x,mouse_y,icon_floppy, menu_sel_floppy);
	        blit_image (icon_floppy, iconpos_x, iconpos_y);

	        iconpos_x += iconsizex + bosluk;
        	secilimi (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_preferences, menu_sel_prefs);
	        blit_image (icon_preferences, iconpos_x, iconpos_y);

	        iconpos_x += iconsizex + bosluk;
        	secilimi (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_tweaks, menu_sel_tweaks);
	        blit_image (icon_tweaks, iconpos_x, iconpos_y);

        	iconpos_x += iconsizex + bosluk;
	        secilimi (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_keymaps, menu_sel_keymaps);
        	blit_image (icon_keymaps, iconpos_x, iconpos_y);

	        iconpos_x += iconsizex + bosluk;
	        secilimi (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_expansion, menu_sel_expansion);
        	blit_image (icon_expansion, iconpos_x, iconpos_y);

        	iconpos_x = 10;
	        iconpos_y = 93;

        	secilimi (iconpos_x,iconpos_y,mouse_x,mouse_y,icon_storage, menu_sel_storage);
	        blit_image (icon_storage, iconpos_x, iconpos_y);

	        iconpos_x += iconsizex + bosluk;
	        secilimi (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_reset, menu_sel_reset);
        	blit_image (icon_reset, iconpos_x, iconpos_y);

	        iconpos_x += iconsizex + bosluk;
        	secilimi (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_run, menu_sel_run);
	        blit_image (icon_run, iconpos_x, iconpos_y);

        	iconpos_x += iconsizex + bosluk;
	        secilimi (iconpos_x,iconpos_y,mouse_x,mouse_y, icon_exit, menu_sel_exit);
        	blit_image (icon_exit, iconpos_x, iconpos_y);
	// texts
		write_text (26,3,"UAE2x 0.1 alpha  //GnoStiC");

	// mouse pointer ------------------------------
		if (kleft == 1) {
	                mouse_x -= (iconsizex + bosluk);
        	        kleft = 0;
		}
		if (kright == 1) {
	                mouse_x += (iconsizex + bosluk);
	                kright = 0;
		}
	        if (kup == 1) {
	                mouse_y -= (iconsizey + bosluk);
	                kup = 0;
		}
		if (kdown == 1) {
        	        kdown = 0;
	                mouse_y += (iconsizey + bosluk);
		}

        	if (mouse_x < 1) { mouse_x = 1; }
	        if (mouse_y < 1) { mouse_y = 1; }
        	if (mouse_x > 320) { mouse_x = 320; }
	        if (mouse_y > 240) { mouse_y = 240; }
		rect.x = mouse_x;
		rect.y = mouse_y;
		//rect.w = pMouse_Pointer->w;
		//rect.h = pMouse_Pointer->h;
		SDL_BlitSurface (pMouse_Pointer,NULL,tmpSDLScreen,&rect);
	// mouse pointer-end

		SDL_BlitSurface (tmpSDLScreen,NULL,display,NULL);
		SDL_Flip(display);
	} //while done

	return menu_exitcode;
}